From: Michael Meffie Date: Wed, 21 Jan 2015 19:42:47 +0000 (-0500) Subject: bozo: create a syslog connection only if the -syslog option is given X-Git-Tag: upstream/1.8.0_pre1^2~208 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=11468ae0e12a627a8802711e8562948828834f06;p=packages%2Fo%2Fopenafs.git bozo: create a syslog connection only if the -syslog option is given Fix a minor bug in which an unnecessary syslog connection is opened when the BosLog is not present (typically, the first time the bosserver is started) or when the BosLog is a named pipe, even if the -syslog option was not given. This bug was introduced in commit bdc7e43117706d0aa46d3b6435489e9d4c2b0888, which added checks to avoid renaming logs when they are named pipes. lstat() and S_ISFIFO are provided by libroken, so do not need to be hidden behind conditional compilation. Change-Id: I828534be69949fe017cc7dbed1b6798aa4c0ba17 Reviewed-on: http://gerrit.openafs.org/11686 Reviewed-by: Perry Ruiter Tested-by: BuildBot Reviewed-by: Benjamin Kaduk --- diff --git a/src/bozo/bosserver.c b/src/bozo/bosserver.c index 76f866a90..f3be7aa6d 100644 --- a/src/bozo/bosserver.c +++ b/src/bozo/bosserver.c @@ -857,9 +857,9 @@ main(int argc, char **argv, char **envp) afs_int32 numClasses; int DoPeerRPCStats = 0; int DoProcessRPCStats = 0; + struct stat sb; #ifndef AFS_NT40_ENV int nofork = 0; - struct stat sb; #endif #ifdef AFS_AIX32_ENV struct sigaction nsa; @@ -1045,18 +1045,17 @@ main(int argc, char **argv, char **envp) exit(1); } - if ((!DoSyslog) -#ifndef AFS_NT40_ENV - && ((lstat(AFSDIR_SERVER_BOZLOG_FILEPATH, &sb) == 0) && - !(S_ISFIFO(sb.st_mode))) -#endif - ) { - if (asprintf(&oldlog, "%s.old", AFSDIR_SERVER_BOZLOG_FILEPATH) < 0) { - printf("bosserver: out of memory\n"); - exit(1); + if (!DoSyslog) { + /* Support logging to named pipes by not renaming. */ + if ((lstat(AFSDIR_SERVER_BOZLOG_FILEPATH, &sb) == 0) + && !(S_ISFIFO(sb.st_mode))) { + if (asprintf(&oldlog, "%s.old", AFSDIR_SERVER_BOZLOG_FILEPATH) < 0) { + printf("bosserver: out of memory\n"); + exit(1); + } + rk_rename(AFSDIR_SERVER_BOZLOG_FILEPATH, oldlog); + free(oldlog); } - rk_rename(AFSDIR_SERVER_BOZLOG_FILEPATH, oldlog); /* try rename first */ - free(oldlog); bozo_logFile = fopen(AFSDIR_SERVER_BOZLOG_FILEPATH, "a"); if (!bozo_logFile) { printf("bosserver: can't initialize log file (%s).\n",