[OpenAFS-devel] bosserver cleanup

Christof Hanke hanke@rzg.mpg.de
Tue, 07 Feb 2006 10:41:42 +0100


This is a multi-part message in MIME format.
--------------060405010401070002040102
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit


> 
> Instead of writing yet another backend logging implementation (we have
> far too many as it is), I think it would be a good idea to rework the
> patch to tie into the util/serverLog and/or the auditing framework.
> Code reuse is a good thing :)
Yes I agree.
> 
> Secondly, we should really be using strlcat and strlcpy in newly
> written code.  For consistency's sake, I'd also suggest using the
> Log(...) variadic style interface, like basically all the other server
> processes do.
> 
Hmmm, I don't like the ptserver calling something named ViceLog.
Also, I don't see the point of the ViceLog-macro. It just forces you to 
export the variable LogLevel, which should be private to util.a IMHO.
Thus, what about following patch (again, also under 
/afs/ipp-garching.mpg.de/u/hanke/public/openafs/)?
I had to call the new function SrvLog() instead of Log(), because Log is 
used for the volserver. Also, I didn't like to use the other function 
FSLog, because bozo is no FS.
Yes, this again is code-replication, but like this, we should be able to 
tie one server after the other into this scheme without much hassle.
Any comments or testing it will be grately appreciated.
> Good luck with porting bosserver to pthreads.  That will definitely be
> a nice contribution.
> 
I thought of tieing it into the build-process in analogy to the couple 
viced/tviced. Is that an acceptable way ?

> Regards,
> 
> -Tom
Regards,

Christof

--------------060405010401070002040102
Content-Type: text/plain;
 name="bozo-patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="bozo-patch"

Index: src/util/serverLog.c
===================================================================
--- src/util/serverLog.c	(revision 2071)
+++ src/util/serverLog.c	(working copy)
@@ -171,6 +171,19 @@
     va_end(args);
 }				/*FSLog */
 
+void
+SrvLog(int level, const char *format, ...)
+{
+	if ((level) > LogLevel)
+		return;
+    va_list args;
+
+    va_start(args, format);
+    vFSLog(format, args);
+    va_end(args);
+}				/*Log */
+
+
 static int
 DebugOn(int loglevel)
 {
@@ -292,7 +305,7 @@
 		strcpy((char *)&ourName, (char *)fileName);
 	}
 	afs_snprintf(FileName, MAXPATHLEN, "%s.%d%02d%02d%02d%02d%02d",
-		     ourName, TimeFields->tm_year + 1900,
+		     ourName, TimeFields->tm_year + 2000,
 		     TimeFields->tm_mon + 1, TimeFields->tm_mday,
 		     TimeFields->tm_hour, TimeFields->tm_min,
 		     TimeFields->tm_sec);
Index: src/util/afsutil.h
===================================================================
--- src/util/afsutil.h	(revision 2071)
+++ src/util/afsutil.h	(working copy)
@@ -35,6 +35,7 @@
 extern void SetLogThreadNumProgram(int (*func) () );
 
 /*@printflike@*/ extern void FSLog(const char *format, ...);
+/*@printflike@*/ extern void SrvLog(int level,const char *format, ...);
 #define ViceLog(level, str)  if ((level) <= LogLevel) (FSLog str)
 #define vViceLog(level, str) if ((level) <= LogLevel) (vFSLog str)
 
Index: src/bozo/fsbnodeops.c
===================================================================
--- src/bozo/fsbnodeops.c	(revision 2071)
+++ src/bozo/fsbnodeops.c	(working copy)
@@ -308,21 +308,21 @@
 
     /* construct local paths from canonical (wire-format) paths */
     if (ConstructLocalBinPath(afilecmd, &fileCmdpath)) {
-	bozo_Log("BNODE: command path invalid '%s'\n", afilecmd);
+	SrvLog(0,"BNODE: command path invalid '%s'\n", afilecmd);
 	bailout = 1;
     }
     if (ConstructLocalBinPath(avolcmd, &volCmdpath)) {
-	bozo_Log("BNODE: command path invalid '%s'\n", avolcmd);
+	SrvLog(0,"BNODE: command path invalid '%s'\n", avolcmd);
 	bailout = 1;
     }
     if (ConstructLocalBinPath(asalcmd, &salCmdpath)) {
-	bozo_Log("BNODE: command path invalid '%s'\n", asalcmd);
+	SrvLog(0,"BNODE: command path invalid '%s'\n", asalcmd);
 	bailout = 1;
     }
 
     if (ascancmd && strlen(ascancmd)) {
 	if (ConstructLocalBinPath(ascancmd, &scanCmdpath)) {
-	    bozo_Log("BNODE: command path invalid '%s'\n", ascancmd);
+	    SrvLog(0,"BNODE: command path invalid '%s'\n", ascancmd);
 	    bailout = 1;
 	}
     }
@@ -333,7 +333,7 @@
 	AppendExecutableExtension(cmdname);
 #endif
 	if (stat(cmdname, &tstat)) {
-	    bozo_Log("BNODE: file server binary '%s' not found\n", cmdname);
+	    SrvLog(0,"BNODE: file server binary '%s' not found\n", cmdname);
 	    bailout = 1;
 	}
 
@@ -342,7 +342,7 @@
 	AppendExecutableExtension(cmdname);
 #endif
 	if (stat(cmdname, &tstat)) {
-	    bozo_Log("BNODE: volume server binary '%s' not found\n", cmdname);
+	    SrvLog(0,"BNODE: volume server binary '%s' not found\n", cmdname);
 	    bailout = 1;
 	}
 
@@ -351,7 +351,7 @@
 	AppendExecutableExtension(cmdname);
 #endif
 	if (stat(cmdname, &tstat)) {
-	    bozo_Log("BNODE: salvager binary '%s' not found\n", cmdname);
+	    SrvLog(0,"BNODE: salvager binary '%s' not found\n", cmdname);
 	    bailout = 1;
 	}
 
@@ -361,7 +361,7 @@
 	    AppendExecutableExtension(cmdname);
 #endif
 	    if (stat(cmdname, &tstat)) {
-		bozo_Log("BNODE: scanner binary '%s' not found\n", cmdname);
+		SrvLog(0,"BNODE: scanner binary '%s' not found\n", cmdname);
 		bailout = 1;
 	    }
 	}
@@ -408,8 +408,8 @@
 	if (!abnode->volKillSent && now - abnode->timeSDStarted > SDTIME) {
 	    bnode_StopProc(abnode->volProc, SIGKILL);
 	    abnode->volKillSent = 1;
-	    bozo_Log
-		("bos shutdown: volserver failed to shutdown within %d seconds\n",
+	    SrvLog
+		(0,"bos shutdown: volserver failed to shutdown within %d seconds\n",
 		 SDTIME);
 	}
     }
@@ -417,8 +417,8 @@
 	if (!abnode->salKillSent && now - abnode->timeSDStarted > SDTIME) {
 	    bnode_StopProc(abnode->salProc, SIGKILL);
 	    abnode->salKillSent = 1;
-	    bozo_Log
-		("bos shutdown: salvager failed to shutdown within %d seconds\n",
+	    SrvLog
+		(0,"bos shutdown: salvager failed to shutdown within %d seconds\n",
 		 SDTIME);
 	}
     }
@@ -426,8 +426,8 @@
 	if (!abnode->fileKillSent && now - abnode->timeSDStarted > FSSDTIME) {
 	    bnode_StopProc(abnode->fileProc, SIGKILL);
 	    abnode->fileKillSent = 1;
-	    bozo_Log
-		("bos shutdown: fileserver failed to shutdown within %d seconds\n",
+	    SrvLog
+		(0,"bos shutdown: fileserver failed to shutdown within %d seconds\n",
 		 FSSDTIME);
 	}
     }
@@ -435,8 +435,8 @@
 	if (!abnode->scanKillSent && now - abnode->timeSDStarted > SDTIME) {
 	    bnode_StopProc(abnode->scanProc, SIGKILL);
 	    abnode->scanKillSent = 1;
-	    bozo_Log
-		("bos shutdown: scanner failed to shutdown within %d seconds\n",
+	    SrvLog
+		(0,"bos shutdown: scanner failed to shutdown within %d seconds\n",
 		 SDTIME);
 	}
     }
@@ -546,8 +546,8 @@
 	 * tells us if we need to run the salvager or not */
 	if (abnode->fileRunning) {
 	    if (abnode->salRunning) {
-		bozo_Log("Salvager running along with file server!\n");
-		bozo_Log("Emergency shutdown\n");
+		SrvLog(0,"Salvager running along with file server!\n");
+		SrvLog(0,"Emergency shutdown\n");
 		emergency = 1;
 		bnode_SetGoal(abnode, BSTAT_SHUTDOWN);
 		bnode_StopProc(abnode->salProc, SIGKILL);
Index: src/bozo/ezbnodeops.c
===================================================================
--- src/bozo/ezbnodeops.c	(revision 2071)
+++ src/bozo/ezbnodeops.c	(working copy)
@@ -106,7 +106,7 @@
     char *cmdpath;
 
     if (ConstructLocalBinPath(acommand, &cmdpath)) {
-	bozo_Log("BNODE: command path invalid '%s'\n", acommand);
+	SrvLog(0,"BNODE: command path invalid '%s'\n", acommand);
 	return NULL;
     }
 
Index: src/bozo/bosoprocs.c
===================================================================
--- src/bozo/bosoprocs.c	(revision 2071)
+++ src/bozo/bosoprocs.c	(working copy)
@@ -54,7 +54,6 @@
 
 extern struct afsconf_dir *bozo_confdir;
 extern int bozo_newKTs;
-extern int DoLogging;
 #ifdef BOS_RESTRICTED_MODE
 extern int bozo_isrestricted;
 #endif
@@ -99,8 +98,7 @@
 	code = BZACCESS;
 	goto fail;
     }
-    if (DoLogging)
-	bozo_Log("%s is executing SetRestartTime\n", caller);
+	SrvLog(0,"%s is executing SetRestartTime\n", caller);
 
     code = 0;			/* assume success */
     switch (atype) {
@@ -147,8 +145,7 @@
 	goto fail;
     }
 #endif
-    if (DoLogging)
-	bozo_Log("%s is executing the shell command '%s'\n", caller, acmd);
+	SrvLog(0,"%s is executing the shell command '%s'\n", caller, acmd);
 
     /* should copy output to acall, but don't yet cause its hard */
     /*  hard... NOT!  Nnow _at least_ return the exit status */
@@ -225,8 +222,7 @@
 	return BZNOENT;
     }
 
-    if (DoLogging)
-	bozo_Log("%s is executing UnInstall '%s'\n", caller, filepath);
+	SrvLog(0,"%s is executing UnInstall '%s'\n", caller, filepath);
 
     strcpy(fpBak, filepath);
     strcat(fpBak, ".BAK");
@@ -328,8 +324,7 @@
     strcpy(filepath, fpp);
     free(fpp);
 
-    if (DoLogging)
-	bozo_Log("%s is executing Install '%s'\n", caller, filepath);
+	SrvLog(0,"%s is executing Install '%s'\n", caller, filepath);
 
     /* open file */
     fpp = filepath + strlen(filepath);
@@ -404,8 +399,7 @@
 	code = BZACCESS;
 	goto fail;
     }
-    if (DoLogging)
-	bozo_Log("%s is executing SetCellName '%s'\n", caller, aname);
+	SrvLog(0,"%s is executing SetCellName '%s'\n", caller, aname);
 
     code =
 	afsconf_GetExtendedCellInfo(bozo_confdir, NULL, NULL, &tcell,
@@ -415,8 +409,8 @@
 
     /* Check that tcell has enough space for the new cellname. */
     if (strlen(aname) > sizeof tcell.name - 1) {
-	bozo_Log
-	    ("ERROR: SetCellName: cell name '%s' exceeds %ld bytes (cell name not changed)\n",
+	SrvLog
+	    (0,"ERROR: SetCellName: cell name '%s' exceeds %ld bytes (cell name not changed)\n",
 	     aname, (long)(sizeof tcell.name - 1));
 	code = BZDOM;
 	goto fail;
@@ -509,8 +503,7 @@
 	code = BZACCESS;
 	goto fail;
     }
-    if (DoLogging)
-	bozo_Log("%s is executing DeleteCellHost '%s'\n", caller, aname);
+	SrvLog(0,"%s is executing DeleteCellHost '%s'\n", caller, aname);
 
     code =
 	afsconf_GetExtendedCellInfo(bozo_confdir, NULL, NULL, &tcell,
@@ -560,8 +553,7 @@
 	code = BZACCESS;
 	goto fail;
     }
-    if (DoLogging)
-	bozo_Log("%s is executing AddCellHost '%s'\n", caller, aname);
+	SrvLog(0,"%s is executing AddCellHost '%s'\n", caller, aname);
 
     code =
 	afsconf_GetExtendedCellInfo(bozo_confdir, NULL, NULL, &tcell,
@@ -595,8 +587,8 @@
 	 */
 	if (tcell.numServers >
 	    sizeof tcell.hostAddr / sizeof tcell.hostAddr[0]) {
-	    bozo_Log
-		("ERROR: AddCellHost: attempt to add more than %ld database servers (database server '%s' not added)\n",
+	    SrvLog
+		(0,"ERROR: AddCellHost: attempt to add more than %ld database servers (database server '%s' not added)\n",
 		 (long)(sizeof tcell.hostAddr / sizeof tcell.hostAddr[0]),
 		 aname);
 	    code = BZDOM;
@@ -605,8 +597,8 @@
 
 	/* Check that tcell has enough space for the new hostname. */
 	if (strlen(aname) > sizeof tcell.hostName[0] - 1) {
-	    bozo_Log
-		("ERROR: AddCellHost: host name '%s' exceeds %ld bytes (not added)\n",
+	    SrvLog
+		(0,"ERROR: AddCellHost: host name '%s' exceeds %ld bytes (not added)\n",
 		 aname, (long)(sizeof tcell.hostName[0] - 1));
 	    code = BZDOM;
 	    goto fail;
@@ -644,8 +636,7 @@
 	code = BZACCESS;
 	goto fail;
     }
-    if (DoLogging)
-	bozo_Log("%s is executing ListKeys\n", caller);
+	SrvLog(0,"%s is executing ListKeys\n", caller);
 
     code = afsconf_GetKeys(bozo_confdir, &tkeys);
     if (code)
@@ -704,8 +695,7 @@
 	code = BZENCREQ;
 	goto fail;
     }
-    if (DoLogging)
-	bozo_Log("%s is executing AddKey\n", caller);
+	SrvLog(0,"%s is executing AddKey\n", caller);
 
     code = afsconf_AddKey(bozo_confdir, an, akey, 0);
     if (code == AFSCONF_KEYINUSE)
@@ -727,8 +717,7 @@
 	code = BZACCESS;
 	goto fail;
     }
-    if (DoLogging)
-	bozo_Log("%s is executing Set No Authentication\n", caller);
+	SrvLog(0,"%s is executing Set No Authentication\n", caller);
 
     afsconf_SetNoAuthFlag(bozo_confdir, aflag);
 
@@ -749,8 +738,7 @@
 	code = BZACCESS;
 	goto fail;
     }
-    if (DoLogging)
-	bozo_Log("%s is executing DeleteKey\n", caller);
+	SrvLog(0,"%s is executing DeleteKey\n", caller);
 
     code = afsconf_DeleteKey(bozo_confdir, an);
 
@@ -790,8 +778,7 @@
 	code = BZACCESS;
 	goto fail;
     }
-    if (DoLogging)
-	bozo_Log("%s is executing Add SuperUser '%s'\n", caller, aname);
+	SrvLog(0,"%s is executing Add SuperUser '%s'\n", caller, aname);
 
     code = afsconf_AddUser(bozo_confdir, aname);
 
@@ -813,8 +800,7 @@
 	goto fail;
     }
 
-    if (DoLogging)
-	bozo_Log("%s is executing Delete SuperUser '%s'\n", caller, aname);
+	SrvLog(0,"%s is executing Delete SuperUser '%s'\n", caller, aname);
 
     code = afsconf_DeleteUser(bozo_confdir, aname);
 
@@ -874,8 +860,7 @@
 	goto fail;
     }
 
-    if (DoLogging)
-	bozo_Log("%s is executing Wait for All\n", caller);
+	SrvLog(0,"%s is executing Wait for All\n", caller);
 
     code = bnode_WaitAll();
 
@@ -902,8 +887,7 @@
 	goto fail;
     }
 #endif
-    if (DoLogging)
-	bozo_Log("%s is executing DeleteBnode '%s'\n", caller, ainstance);
+	SrvLog(0,"%s is executing DeleteBnode '%s'\n", caller, ainstance);
 
     code = bnode_DeleteName(ainstance);
 
@@ -966,8 +950,7 @@
 	code = BZACCESS;
 	goto fail;
     }
-    if (DoLogging)
-	bozo_Log("%s is executing ShutdownAll\n", caller);
+	SrvLog(0,"%s is executing ShutdownAll\n", caller);
 
     code = bnode_ApplyInstance(sdproc, NULL);
 
@@ -988,8 +971,7 @@
 	code = BZACCESS;
 	goto fail;
     }
-    if (DoLogging)
-	bozo_Log("%s is executing RestartAll\n", caller);
+	SrvLog(0,"%s is executing RestartAll\n", caller);
 
     /* start shutdown of all processes */
     code = bnode_ApplyInstance(sdproc, NULL);
@@ -1021,8 +1003,7 @@
 	code = BZACCESS;
 	goto fail;
     }
-    if (DoLogging)
-	bozo_Log("%s is executing ReBozo\n", caller);
+	SrvLog(0,"%s is executing ReBozo\n", caller);
 
     /* start shutdown of all processes */
     code = bnode_ApplyInstance(sdproc, NULL);
@@ -1065,8 +1046,7 @@
 	code = BZACCESS;
 	goto fail;
     }
-    if (DoLogging)
-	bozo_Log("%s is executing StartupAll\n", caller);
+	SrvLog(0,"%s is executing StartupAll\n", caller);
     code = bnode_ApplyInstance(stproc, NULL);
 
   fail:
@@ -1087,8 +1067,7 @@
 	code = BZACCESS;
 	goto fail;
     }
-    if (DoLogging)
-	bozo_Log("%s is executing Restart '%s'\n", caller, ainstance);
+	SrvLog(0,"%s is executing Restart '%s'\n", caller, ainstance);
 
     tb = bnode_FindInstance(ainstance);
     if (!tb) {
@@ -1125,8 +1104,7 @@
 	code = BZACCESS;
 	goto fail;
     }
-    if (DoLogging)
-	bozo_Log("%s is executing SetTempStatus '%s'\n", caller, ainstance);
+	SrvLog(0,"%s is executing SetTempStatus '%s'\n", caller, ainstance);
 
     tb = bnode_FindInstance(ainstance);
     if (!tb) {
@@ -1157,8 +1135,7 @@
 	code = BZACCESS;
 	goto fail;
     }
-    if (DoLogging)
-	bozo_Log("%s is executing SetStatus '%s' (status = %d)\n", caller,
+	SrvLog(0,"%s is executing SetStatus '%s' (status = %d)\n", caller,
 		 ainstance, astatus);
 
     tb = bnode_FindInstance(ainstance);
@@ -1265,8 +1242,7 @@
 	goto fail;
     }
 #endif
-    if (DoLogging)
-	bozo_Log("%s is executing Prune (flags=%d)\n", caller, aflags);
+	SrvLog(0,"%s is executing Prune (flags=%d)\n", caller, aflags);
 
     /* first scan AFS binary directory */
     dirp = opendir(AFSDIR_SERVER_BIN_DIRPATH);
@@ -1412,7 +1388,7 @@
     for (i = 0; i < bozo_nbosEntryStats; i++) {
 	struct bozo_bosEntryStats *e = &bozo_bosEntryStats[i];
 	if (!StatEachEntry(e)) {
-	    bozo_Log("unhappy with %s which is a %s that should "
+	    SrvLog(0,"unhappy with %s which is a %s that should "
 		     "have at least rights %o, at most rights %o %s\n",
 		     e->path, e->dir ? "dir" : "file", e->reqPerm, 
 		     (~e->proPerm & 0777), 
@@ -1423,7 +1399,7 @@
     }
 
     if (result != lastResult) {	/* log changes */
-	bozo_Log("Server directory access is %sokay\n",
+	SrvLog(0,"Server directory access is %sokay\n",
 		 (result ? "" : "not "));
     }
     lastResult = result;
@@ -1541,8 +1517,7 @@
     if (ConstructLocalLogPath(aname, &logpath)) {
 	return BZNOENT;
     }
-    if (DoLogging)
-	bozo_Log("%s is executing GetLog '%s'\n", caller, logpath);
+	SrvLog(0,"%s is executing GetLog '%s'\n", caller, logpath);
     tfile = fopen(logpath, "r");
     free(logpath);
 
@@ -1667,8 +1642,8 @@
 {
     int code;
 
-    bozo_Log
-	("Shutdown of BOS server and processes in response to signal %d\n",
+    SrvLog
+	(0,"Shutdown of BOS server and processes in response to signal %d\n",
 	 asignal);
 
     /* start shutdown of all processes */
@@ -1678,7 +1653,7 @@
     }
 
     if (code) {
-	bozo_Log("Shutdown incomplete (code = %d); manual cleanup required\n",
+	SrvLog(0,"Shutdown incomplete (code = %d); manual cleanup required\n",
 		 code);
     }
 
Index: src/bozo/bosserver.c
===================================================================
--- src/bozo/bosserver.c	(revision 2071)
+++ src/bozo/bosserver.c	(working copy)
@@ -53,19 +53,12 @@
 extern int RXSTATS_ExecuteRequest();
 extern struct bnode_ops fsbnode_ops, ezbnode_ops, cronbnode_ops;
 
-void bozo_Log();
-
 struct afsconf_dir *bozo_confdir = 0;	/* bozo configuration dir */
 static char *bozo_pid;
 struct rx_securityClass *bozo_rxsc[3];
 const char *bozo_fileName;
 FILE *bozo_logFile;
 
-int DoLogging = 0;
-int DoSyslog = 0;
-#ifndef AFS_NT40_ENV
-int DoSyslogFacility = LOG_DAEMON;
-#endif
 static afs_int32 nextRestart;
 static afs_int32 nextDay;
 
@@ -107,10 +100,6 @@
     if (afsconf_GetNoAuthFlag(bozo_confdir)) {
 	status |= BOSEXIT_NOAUTH_FLAG;
     }
-    /* if logging is on, pass "-log" to new bosserver */
-    if (DoLogging) {
-	status |= BOSEXIT_LOGGING_FLAG;
-    }
     exit(status);
 #else
     /* exec new bosserver process */
@@ -125,17 +114,12 @@
 	argv[i] = "-noauth";
 	i++;
     }
-    /* if logging is on, pass "-log" to new bosserver */
-    if (DoLogging) {
-	argv[i] = "-log";
-	i++;
-    }
 #ifndef AFS_NT40_ENV
     /* if syslog logging is on, pass "-syslog" to new bosserver */
-    if (DoSyslog) {
+    if (serverLogSyslog) {
 	char *arg = (char *)malloc(40);	/* enough for -syslog=# */
-	if (DoSyslogFacility != LOG_DAEMON) {
-	    snprintf(arg, 40, "-syslog=%d", DoSyslogFacility);
+	if (serverLogSyslogFacility != LOG_DAEMON) {
+	    snprintf(arg, 40, "-syslog=%d", serverLogSyslogFacility);
 	} else {
 	    strcpy(arg, "-syslog");
 	}
@@ -522,7 +506,7 @@
 
 #ifdef BOS_RESTRICTED_MODE
 	if (bozo_restdisable) {
-	    bozo_Log("Restricted mode disabled by signal\n");
+	    SrvLog("Restricted mode disabled by signal\n");
 	    bozo_restdisable = 0;
 	}
 #endif
@@ -717,10 +701,8 @@
     int noAuth = 0;
     struct ktc_encryptionKey tkey;
     int i;
-    char namebuf[AFSDIR_PATH_MAX];
 #ifndef AFS_NT40_ENV
     int nofork = 0;
-    struct stat sb;
 #endif
 #ifdef	AFS_AIX32_ENV
     struct sigaction nsa;
@@ -787,16 +769,16 @@
 	    /* set noauth flag */
 	    noAuth = 1;
 	} else if (strcmp(argv[code], "-log") == 0) {
-	    /* set extra logging flag */
-	    DoLogging = 1;
+        /* commandline flag for compatibility */
+        ;
 	}
 #ifndef AFS_NT40_ENV
 	else if (strcmp(argv[code], "-syslog") == 0) {
 	    /* set syslog logging flag */
-	    DoSyslog = 1;
+	    serverLogSyslog = 1;
 	} else if (strncmp(argv[code], "-syslog=", 8) == 0) {
-	    DoSyslog = 1;
-	    DoSyslogFacility = atoi(argv[code] + 8);
+		serverLogSyslog = 1;
+	    serverLogSyslogFacility = atoi(argv[code] + 8);
 	} else if (strcmp(argv[code], "-nofork") == 0) {
 	    nofork = 1;
 	}
@@ -883,8 +865,6 @@
     /* create useful dirs */
     CreateDirs();
 
-    /* chdir to AFS log directory */
-    chdir(AFSDIR_SERVER_LOGS_DIRPATH);
 
 #if 0
     fputs(AFS_GOVERNMENT_MESSAGE, stdout);
@@ -900,42 +880,25 @@
 	daemon(1, 0);
 #endif /* ! AFS_NT40_ENV */
 
-    if ((!DoSyslog)
 #ifndef AFS_NT40_ENV
-	&& ((lstat(AFSDIR_BOZLOG_FILE, &sb) == 0) && 
-	!(S_ISFIFO(sb.st_mode)))
+    serverLogSyslogTag = "bosserver";
 #endif
-	) {
-	strcpy(namebuf, AFSDIR_BOZLOG_FILE);
-	strcat(namebuf, ".old");
-	renamefile(AFSDIR_BOZLOG_FILE, namebuf);	/* try rename first */
-	bozo_logFile = fopen(AFSDIR_BOZLOG_FILE, "a");
-	if (!bozo_logFile) {
-	    printf("bosserver: can't initialize log file (%s).\n",
-		   AFSDIR_SERVER_BOZLOG_FILEPATH);
-	    exit(1);
-	}
-	/* keep log closed normally, so can be removed */
-	fclose(bozo_logFile);
-    } else {
-#ifndef AFS_NT40_ENV
-	openlog("bosserver", LOG_PID, DoSyslogFacility);
-#endif
-    }
-
+    OpenLog(AFSDIR_SERVER_BOZLOG_FILEPATH);	/* set up logging */
+    SetupLogSignals();
+	
     /* Write current state of directory permissions to log file */
     DirAccessOK();
 
     for (i = 0; i < 10; i++) {
 	code = rx_Init(htons(AFSCONF_NANNYPORT));
 	if (code) {
-	    bozo_Log("can't initialize rx: code=%d\n", code);
+	    SrvLog(0,"can't initialize rx: code=%d\n", code);
 	    sleep(3);
 	} else
 	    break;
     }
     if (i >= 10) {
-	bozo_Log("Bos giving up, can't initialize rx\n");
+	SrvLog(0,"Bos giving up, can't initialize rx\n");
 	exit(code);
     }
 
@@ -952,12 +915,12 @@
 	tcell.numServers = 1;
 	code = gethostname(tcell.hostName[0], MAXHOSTCHARS);
 	if (code) {
-	    bozo_Log("failed to get hostname, code %d\n", errno);
+	   SrvLog(0,"failed to get hostname, code %d\n", errno);
 	    exit(1);
 	}
 	if (tcell.hostName[0][0] == 0) {
-	    bozo_Log("host name not set, can't start\n");
-	    bozo_Log("try the 'hostname' command\n");
+	    SrvLog(0,"host name not set, can't start\n");
+	    SrvLog(0,"try the 'hostname' command\n");
 	    exit(1);
 	}
 	memset(tcell.hostAddr, 0, sizeof(tcell.hostAddr));	/* not computed */
@@ -965,23 +928,23 @@
 	    afsconf_SetCellInfo(bozo_confdir, AFSDIR_SERVER_ETC_DIRPATH,
 				&tcell);
 	if (code) {
-	    bozo_Log
-		("could not create cell database in '%s' (code %d), quitting\n",
+	    SrvLog
+		(0,"could not create cell database in '%s' (code %d), quitting\n",
 		 AFSDIR_SERVER_ETC_DIRPATH, code);
 	    exit(1);
 	}
 	tdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
 	if (!tdir) {
-	    bozo_Log
-		("failed to open newly-created cell database, quitting\n");
+	    SrvLog
+		(0,"failed to open newly-created cell database, quitting\n");
 	    exit(1);
 	}
     }
 
     /* read init file, starting up programs */
     if (code = ReadBozoFile(0)) {
-	bozo_Log
-	    ("bosserver: Something is wrong (%d) with the bos configuration file %s; aborting\n",
+	SrvLog
+	    (0,"bosserver: Something is wrong (%d) with the bos configuration file %s; aborting\n",
 	     code, AFSDIR_SERVER_BOZCONF_FILEPATH);
 	exit(code);
     }
@@ -1022,40 +985,3 @@
     rx_StartServer(1);		/* donate this process */
 }
 
-void
-bozo_Log(char *a, char *b, char *c, char *d, char *e, char *f)
-{
-    char tdate[26];
-    time_t myTime;
-
-    if (DoSyslog) {
-#ifndef AFS_NT40_ENV
-	syslog(LOG_INFO, a, b, c, d, e, f);
-#endif
-    } else {
-	myTime = time(0);
-	strcpy(tdate, ctime(&myTime));	/* copy out of static area asap */
-	tdate[24] = ':';
-
-	/* log normally closed, so can be removed */
-
-	bozo_logFile = fopen(AFSDIR_SERVER_BOZLOG_FILEPATH, "a");
-	if (bozo_logFile == NULL) {
-	    printf("bosserver: WARNING: problem with %s",
-		   AFSDIR_SERVER_BOZLOG_FILEPATH);
-	    fflush(stdout);
-	}
-
-	if (bozo_logFile) {
-	    fprintf(bozo_logFile, "%s ", tdate);
-	    fprintf(bozo_logFile, a, b, c, d, e, f);
-	    fflush(bozo_logFile);
-	} else {
-	    printf("%s ", tdate);
-	    printf(a, b, c, d, e, f);
-	}
-
-	/* close so rm BosLog works */
-	fclose(bozo_logFile);
-    }
-}
Index: src/bozo/bnode.c
===================================================================
--- src/bozo/bnode.c	(revision 2071)
+++ src/bozo/bnode.c	(working copy)
@@ -333,13 +333,13 @@
     if (notifier && strcmp(notifier, NONOTIFIER)) {
 	/* construct local path from canonical (wire-format) path */
 	if (ConstructLocalBinPath(notifier, &notifierpath)) {
-	    bozo_Log("BNODE-Create: Notifier program path invalid '%s'\n",
+	    SrvLog(0,"BNODE-Create: Notifier program path invalid '%s'\n",
 		     notifier);
 	    return BZNOCREATE;
 	}
 
 	if (stat(notifierpath, &tstat)) {
-	    bozo_Log("BNODE-Create: Notifier program '%s' not found\n",
+	    SrvLog(0,"BNODE-Create: Notifier program '%s' not found\n",
 		     notifierpath);
 	    free(notifierpath);
 	    return BZNOCREATE;
@@ -588,10 +588,10 @@
 			    tb->errorSignal = 0;
 			}
 			if (tp->coreName)
-			    bozo_Log("%s:%s exited with code %d\n", tb->name,
+			    SrvLog(0,"%s:%s exited with code %d\n", tb->name,
 				     tp->coreName, tp->lastExit);
 			else
-			    bozo_Log("%s exited with code %d\n", tb->name,
+			    SrvLog(0,"%s exited with code %d\n", tb->name,
 				     tp->lastExit);
 		    } else {
 			/* Signal occurred, perhaps spurious due to shutdown request.
@@ -608,12 +608,12 @@
 			    RememberProcName(tp);
 			}
 			if (tp->coreName)
-			    bozo_Log("%s:%s exited on signal %d%s\n",
+			    SrvLog(0,"%s:%s exited on signal %d%s\n",
 				     tb->name, tp->coreName, tp->lastSignal,
 				     WCOREDUMP(status) ? " (core dumped)" :
 				     "");
 			else
-			    bozo_Log("%s exited on signal %d%s\n", tb->name,
+			    SrvLog(0,"%s exited on signal %d%s\n", tb->name,
 				     tp->lastSignal,
 				     WCOREDUMP(status) ? " (core dumped)" :
 				     "");
@@ -622,7 +622,7 @@
 		    tb->lastAnyExit = FT_ApproxTime();
 
 		    if (tb->notifier) {
-			bozo_Log("BNODE: Notifier %s will be called\n",
+			SrvLog(0,"BNODE: Notifier %s will be called\n",
 				 tb->notifier);
 			hdl_notifier(tp);
 		    }
@@ -633,8 +633,8 @@
 			/* 10 in 10 seconds */
 			tb->flags |= BNODE_ERRORSTOP;
 			bnode_SetGoal(tb, BSTAT_SHUTDOWN);
-			bozo_Log
-			    ("BNODE '%s' repeatedly failed to start, perhaps missing executable.\n",
+			SrvLog
+			    (0,"BNODE '%s' repeatedly failed to start, perhaps missing executable.\n",
 			     tb->name);
 		    }
 		    bnode_Release(tb);	/* bnode delete can happen here */
@@ -727,7 +727,7 @@
     struct stat tstat;
 
     if (stat(tp->bnode->notifier, &tstat)) {
-	bozo_Log("BNODE: Failed to find notifier '%s'; ignored\n",
+	SrvLog(0,"BNODE: Failed to find notifier '%s'; ignored\n",
 		 tp->bnode->notifier);
 	return (1);
     }
@@ -747,7 +747,7 @@
 #endif
 	fout = popen(tb->notifier, "w");
 	if (fout == NULL) {
-	    bozo_Log("BNODE: Failed to find notifier '%s'; ignored\n",
+	    SrvLog(0,"BNODE: Failed to find notifier '%s'; ignored\n",
 		     tb->notifier);
 	    perror(tb->notifier);
 	    exit(1);
@@ -756,7 +756,7 @@
 	pclose(fout);
 	exit(0);
     } else if (pid < 0) {
-	bozo_Log("Failed to fork creating process to handle notifier '%s'\n",
+	SrvLog(0,"Failed to fork creating process to handle notifier '%s'\n",
 		 tp->bnode->notifier);
 	return -1;
     }
@@ -930,7 +930,7 @@
     osi_audit(BOSSpawnProcEvent, 0, AUD_STR, aexecString, AUD_END);
 
     if (cpid == (pid_t) - 1) {
-	bozo_Log("Failed to spawn process for bnode '%s'\n", abnode->name);
+	SrvLog(0,"Failed to spawn process for bnode '%s'\n", abnode->name);
 	bnode_FreeTokens(tlist);
 	free(tp);
 	return errno;
Index: src/bozo/bnode.p.h
===================================================================
--- src/bozo/bnode.p.h	(revision 2071)
+++ src/bozo/bnode.p.h	(working copy)
@@ -120,7 +120,6 @@
 #define BOSEXIT_RESTART        0xA0
 #define BOSEXIT_DORESTART(code)  (((code) & ~(0xF)) == BOSEXIT_RESTART)
 #define BOSEXIT_NOAUTH_FLAG    0x01
-#define BOSEXIT_LOGGING_FLAG   0x02
 #endif
 
 /* max time to wait for fileserver shutdown */
Index: src/bozo/cronbnodeops.c
===================================================================
--- src/bozo/cronbnodeops.c	(revision 2071)
+++ src/bozo/cronbnodeops.c	(working copy)
@@ -116,7 +116,7 @@
 	    abnode->lastStart = FT_ApproxTime();
 	    code = bnode_NewProc(abnode, abnode->command, NULL, &tp);
 	    if (code) {
-		bozo_Log("cron bnode %s failed to start (code %d)\n",
+		SrvLog(0,"cron bnode %s failed to start (code %d)\n",
 			 abnode->b.name, code);
 		return code;
 	    }
@@ -163,7 +163,7 @@
 
     /* construct local path from canonical (wire-format) path */
     if (ConstructLocalBinPath(acommand, &cmdpath)) {
-	bozo_Log("BNODE: command path invalid '%s'\n", acommand);
+	SrvLog(0,"BNODE: command path invalid '%s'\n", acommand);
 	return NULL;
     }
 
@@ -199,7 +199,7 @@
 	    bnode_SetTimeout(abnode, 0);
 	    code = bnode_NewProc(abnode, abnode->command, NULL, &tp);
 	    if (code) {
-		bozo_Log("cron failed to start bnode %s (code %d)\n",
+		SrvLog(0,"cron failed to start bnode %s (code %d)\n",
 			 abnode->b.name, code);
 		return code;
 	    }
@@ -279,10 +279,10 @@
 
     /* log interesting errors for folks */
     if (aproc->lastSignal)
-	bozo_Log("cron job %s exited due to signal %d\n", abnode->b.name,
+	SrvLog(0,"cron job %s exited due to signal %d\n", abnode->b.name,
 		 aproc->lastSignal);
     else if (aproc->lastExit)
-	bozo_Log("cron job %s exited with non-zero code %d\n", abnode->b.name,
+	SrvLog(0,"cron job %s exited with non-zero code %d\n", abnode->b.name,
 		 aproc->lastExit);
 
     abnode->waitingForShutdown = 0;

--------------060405010401070002040102--