X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/58b1999e086721ff77d8f3d5e0d29e1e58c70a94..4875d6b64dd0ed8d451746cc0cc609cff36192bd:/log.c diff --git a/log.c b/log.c index 0b55457f..256e70e8 100644 --- a/log.c +++ b/log.c @@ -61,7 +61,7 @@ struct { { RERR_WAITCHILD , "some error returned by waitpid()" }, { RERR_MALLOC , "error allocating core memory buffers" }, { RERR_PARTIAL , "some files could not be transferred" }, - { RERR_VANISHED , "some files vanished before they could be transfered" }, + { RERR_VANISHED , "some files vanished before they could be transferred" }, { RERR_TIMEOUT , "timeout in data send/receive" }, { RERR_CMD_FAILED , "remote shell failed" }, { RERR_CMD_KILLED , "remote shell killed" }, @@ -85,6 +85,20 @@ static char const *rerr_name(int code) return NULL; } +static void log_open(void) +{ + if (logfname && !logfile) { + extern int orig_umask; + int old_umask = umask(022 | orig_umask); + logfile = fopen(logfname, "a"); + umask(old_umask); + if (!logfile) { + am_daemon = 0; /* avoid trying to log again */ + rsyserr(FERROR, errno, "fopen() of log-file failed"); + exit_cleanup(RERR_FILESELECT); + } + } +} static void logit(int priority, char *buf) { @@ -139,16 +153,6 @@ void log_init(void) #endif } -void log_open(void) -{ - if (logfname && !logfile) { - extern int orig_umask; - int old_umask = umask(022 | orig_umask); - logfile = fopen(logfname, "a"); - umask(old_umask); - } -} - void log_close(void) { if (logfile) { @@ -371,8 +375,8 @@ static void log_formatted(enum logcode code, case 'o': n = op; break; case 'f': pathjoin(buf2, sizeof buf2, - file->basedir ? file->basedir : "", - f_name(file)); + am_sender && file->dir.root ? file->dir.root : "", + safe_fname(f_name(file))); clean_fname(buf2, 0); n = buf2; if (*n == '/') n++; @@ -414,7 +418,7 @@ static void log_formatted(enum logcode code, l = strlen(n); if (l + ((int)(s - &buf[0])) >= sizeof(buf)) { - rprintf(FERROR,"buffer overflow expanding %%%c - exiting\n", + rprintf(FERROR,"buffer overflow expanding %%%c -- exiting\n", p[0]); exit_cleanup(RERR_MESSAGEIO); }