added "log file" option for those systems with broken syslog (like
authorAndrew Tridgell <tridge@samba.org>
Wed, 9 Sep 1998 05:51:42 +0000 (05:51 +0000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 9 Sep 1998 05:51:42 +0000 (05:51 +0000)
AIX)

loadparm.c
log.c

index 42762c3..24ef7c6 100644 (file)
@@ -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 0497521..b727a53 100644 (file)
--- a/log.c
+++ b/log.c
   */
 #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--;