From: Michael Meffie Date: Wed, 21 Jan 2015 19:31:51 +0000 (-0500) Subject: bozo: use the full path when renaming BosLog to BosLog.old X-Git-Tag: upstream/1.8.0_pre1^2~262 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=05e7c2f2fb60805e21f6235d7666b9c6f943a685;p=packages%2Fo%2Fopenafs.git bozo: use the full path when renaming BosLog to BosLog.old Use the full path when renaming the BosLog file to BosLog.old and when checking whether the BosLog file can be opened, otherwise the rename will fail (and go unnoticed), and the initial BosLog check opens a handle to a file in the wrong directory. Create the server directories, including the logs directory, before forking and log file initialization. Change-Id: I3733d64335f348190572f6278086b634641f2754 Reviewed-on: http://gerrit.openafs.org/11685 Tested-by: BuildBot Reviewed-by: Chas Williams <3chas3@gmail.com> Reviewed-by: Perry Ruiter Reviewed-by: Benjamin Kaduk --- diff --git a/src/bozo/bosserver.c b/src/bozo/bosserver.c index 9f5b74e04..19db559ed 100644 --- a/src/bozo/bosserver.c +++ b/src/bozo/bosserver.c @@ -976,19 +976,26 @@ main(int argc, char **argv, char **envp) } #endif + /* create useful dirs */ + i = CreateDirs(DoCore); + if (i) { + printf("bosserver: could not set up directories, code %d\n", i); + exit(1); + } + if ((!DoSyslog) #ifndef AFS_NT40_ENV - && ((lstat(AFSDIR_BOZLOG_FILE, &sb) == 0) && + && ((lstat(AFSDIR_SERVER_BOZLOG_FILEPATH, &sb) == 0) && !(S_ISFIFO(sb.st_mode))) #endif ) { - if (asprintf(&oldlog, "%s.old", AFSDIR_BOZLOG_FILE) < 0) { + if (asprintf(&oldlog, "%s.old", AFSDIR_SERVER_BOZLOG_FILEPATH) < 0) { printf("bosserver: out of memory\n"); exit(1); } - rk_rename(AFSDIR_BOZLOG_FILE, oldlog); /* try rename first */ + rk_rename(AFSDIR_SERVER_BOZLOG_FILEPATH, oldlog); /* try rename first */ free(oldlog); - bozo_logFile = fopen(AFSDIR_BOZLOG_FILE, "a"); + bozo_logFile = fopen(AFSDIR_SERVER_BOZLOG_FILEPATH, "a"); if (!bozo_logFile) { printf("bosserver: can't initialize log file (%s).\n", AFSDIR_SERVER_BOZLOG_FILEPATH); @@ -1014,13 +1021,6 @@ main(int argc, char **argv, char **envp) } #endif /* ! AFS_NT40_ENV */ - /* create useful dirs */ - i = CreateDirs(DoCore); - if (i) { - printf("bosserver: could not set up directories, code %d\n", i); - exit(1); - } - /* Write current state of directory permissions to log file */ DirAccessOK();