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