{
char *motd_file;
char *lock_file;
+ char *log_file;
int syslog_facility;
int max_connections;
char *socket_options;
{"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},
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)
*/
#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)
{
if (initialised) return;
initialised = 1;
+ if (lp_log_file()) {
+ logfile = fopen(lp_log_file(), "a");
+ return;
+ }
+
#ifdef LOG_NDELAY
options |= LOG_NDELAY;
#endif
#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
log_open();
if (!io_multiplex_write(fd, buf, strlen(buf))) {
- syslog(priority, "%s", buf);
+ logit(priority, buf);
}
depth--;