From 4f6325c362b7b7e35e6728bb5c101e9ab5215092 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 9 Sep 1998 05:51:42 +0000 Subject: [PATCH] added "log file" option for those systems with broken syslog (like AIX) --- loadparm.c | 3 +++ log.c | 20 ++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/loadparm.c b/loadparm.c index 42762c36..24ef7c67 100644 --- a/loadparm.c +++ b/loadparm.c @@ -98,6 +98,7 @@ typedef struct { char *motd_file; char *lock_file; + char *log_file; int syslog_facility; int max_connections; char *socket_options; @@ -231,6 +232,7 @@ static struct parm_struct parm_table[] = {"lock file", P_STRING, P_GLOBAL, &Globals.lock_file, NULL, 0}, {"syslog facility", P_ENUM, P_GLOBAL, &Globals.syslog_facility, enum_facilities,0}, {"socket options", P_STRING, P_GLOBAL, &Globals.socket_options,NULL, 0}, + {"log file", P_STRING, P_GLOBAL, &Globals.log_file, NULL, 0}, {"name", P_STRING, P_LOCAL, &sDefault.name, NULL, 0}, {"comment", P_STRING, P_LOCAL, &sDefault.comment, NULL, 0}, @@ -295,6 +297,7 @@ static void init_locals(void) FN_GLOBAL_STRING(lp_motd_file, &Globals.motd_file) FN_GLOBAL_STRING(lp_lock_file, &Globals.lock_file) +FN_GLOBAL_STRING(lp_log_file, &Globals.log_file) FN_GLOBAL_STRING(lp_socket_options, &Globals.socket_options) FN_GLOBAL_INTEGER(lp_max_connections, &Globals.max_connections) FN_GLOBAL_INTEGER(lp_syslog_facility, &Globals.syslog_facility) diff --git a/log.c b/log.c index 04975218..b727a53d 100644 --- a/log.c +++ b/log.c @@ -23,6 +23,17 @@ */ #include "rsync.h" +static FILE *logfile; + +static void logit(int priority, char *buf) +{ + if (logfile) { + fprintf(logfile,"%s", buf); + fflush(logfile); + } else { + syslog(priority, "%s", buf); + } +} void log_open(void) { @@ -33,6 +44,11 @@ void log_open(void) if (initialised) return; initialised = 1; + if (lp_log_file()) { + logfile = fopen(lp_log_file(), "a"); + return; + } + #ifdef LOG_NDELAY options |= LOG_NDELAY; #endif @@ -44,7 +60,7 @@ void log_open(void) #endif #ifndef LOG_NDELAY - syslog(LOG_INFO,"rsyncd started\n"); + logit(LOG_INFO,"rsyncd started\n"); #endif /* this looks pointless, but it is needed in order for the @@ -86,7 +102,7 @@ void rprintf(int fd, const char *format, ...) log_open(); if (!io_multiplex_write(fd, buf, strlen(buf))) { - syslog(priority, "%s", buf); + logit(priority, buf); } depth--; -- 2.34.1