Commit b839898f authored by rswindell's avatar rswindell
Browse files

Enancement for ragnarok:

If "syslog" is passed as a command-line option, always send log output to
syslog, even when not daemonized.
parent 80e48c05
......@@ -8,7 +8,7 @@
* @format.tab-size 4 (Plain Text/Source Code File Header) *
* @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) *
* *
* Copyright 2014 Rob Swindell - http://www.synchro.net/copyright.html *
* CopyrightRob Swindell - http://www.synchro.net/copyright.html *
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License *
......@@ -129,6 +129,7 @@ BOOL std_facilities=FALSE;
FILE * pidf;
char pid_fname[MAX_PATH+1];
BOOL capabilities_set=FALSE;
BOOL syslog_always=FALSE;
#ifdef USE_LINUX_CAPS
/*
......@@ -166,6 +167,7 @@ static const char* usage = "\nusage: %s [[setting] [...]] [path/ini_file]\n"
"\t x is the optional LOCALx facility to use\n"
"\t if none is specified, uses USER\n"
"\t if 'S' is specified, uses standard facilities\n"
"\tsyslog log to syslog (even when not daemonized)\n"
#endif
"\tgi get user identity (using IDENT protocol)\n"
"\tnh disable hostname lookups\n"
......@@ -227,14 +229,15 @@ static int lputs(int level, char *str)
#ifdef __unix__
if (is_daemon) {
if (is_daemon || syslog_always) {
if(str!=NULL) {
if (std_facilities)
syslog(level|LOG_AUTH,"%s",str);
else
syslog(level,"%s",str);
}
return(0);
if(is_daemon)
return(0);
}
#endif
if(!mutex_initialized) {
......@@ -614,14 +617,15 @@ static int bbs_lputs(void* p, int level, const char *str)
return(0);
#ifdef __unix__
if (is_daemon) {
if (is_daemon || syslog_always) {
if(str==NULL)
return(0);
if (std_facilities)
syslog(level|LOG_AUTH,"%s",str);
else
syslog(level,"term %s",str);
return(strlen(str));
if(is_daemon)
return(strlen(str));
}
#endif
......@@ -672,7 +676,7 @@ static int ftp_lputs(void* p, int level, const char *str)
return(0);
#ifdef __unix__
if (is_daemon) {
if (is_daemon || syslog_always) {
if(str==NULL)
return(0);
if (std_facilities)
......@@ -683,7 +687,8 @@ static int ftp_lputs(void* p, int level, const char *str)
#endif
else
syslog(level,"ftp %s",str);
return(strlen(str));
if(is_daemon)
return(strlen(str));
}
#endif
......@@ -734,14 +739,15 @@ static int mail_lputs(void* p, int level, const char *str)
return(0);
#ifdef __unix__
if (is_daemon) {
if (is_daemon || syslog_always) {
if(str==NULL)
return(0);
if (std_facilities)
syslog(level|LOG_MAIL,"%s",str);
else
syslog(level,"mail %s",str);
return(strlen(str));
if(is_daemon)
return(strlen(str));
}
#endif
......@@ -792,14 +798,15 @@ static int services_lputs(void* p, int level, const char *str)
return(0);
#ifdef __unix__
if (is_daemon) {
if (is_daemon || syslog_always) {
if(str==NULL)
return(0);
if (std_facilities)
syslog(level|LOG_DAEMON,"%s",str);
else
syslog(level,"srvc %s",str);
return(strlen(str));
if(is_daemon)
return(strlen(str));
}
#endif
......@@ -850,14 +857,15 @@ static int event_lputs(void* p, int level, const char *str)
return(0);
#ifdef __unix__
if (is_daemon) {
if (is_daemon || syslog_always) {
if(str==NULL)
return(0);
if (std_facilities)
syslog(level|LOG_CRON,"%s",str);
else
syslog(level,"evnt %s",str);
return(strlen(str));
if(is_daemon)
return(strlen(str));
}
#endif
......@@ -890,14 +898,15 @@ static int web_lputs(void* p, int level, const char *str)
return(0);
#ifdef __unix__
if (is_daemon) {
if (is_daemon || syslog_always) {
if(str==NULL)
return(0);
if (std_facilities)
syslog(level|LOG_DAEMON,"%s",str);
else
syslog(level,"web %s",str);
return(strlen(str));
if(is_daemon)
return(strlen(str));
}
#endif
......@@ -1371,6 +1380,12 @@ int main(int argc, char** argv)
printf("Web server options:\t0x%08"PRIX32"\n",web_startup.options);
return(0);
}
#ifdef __unix__
if(!stricmp(arg,"syslog")) {
syslog_always=TRUE;
continue;
}
#endif
switch(toupper(*(arg++))) {
#ifdef __unix__
case 'D': /* Run as daemon */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment