From 5e82a91d1337b78510bc62fe3c7e43f9c0b7d3d1 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Fri, 24 Sep 2010 17:39:11 +0200 Subject: New configuration option "SyslogFacility" The new option "SyslogFacility" deines the syslog "facility" to which ngIRCd should send log messages. Possible values are system dependant, but most probably "auth", "daemon", "user" and "local1" through "local7" are possible values; see syslog(3). Default is "local5" for historical reasons. --- src/ngircd/conf.c | 19 +++++++++++++++++++ src/ngircd/conf.h | 7 +++++++ src/ngircd/log.c | 10 ++++------ 3 files changed, 30 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c index 5619a6c7..acb40103 100644 --- a/src/ngircd/conf.c +++ b/src/ngircd/conf.c @@ -324,6 +324,10 @@ Conf_Test( void ) printf(" ServerGID = %s\n", grp->gr_name); else printf(" ServerGID = %ld\n", (long)Conf_GID); +#ifdef SYSLOG + printf(" SyslogFacility = %s\n", + ngt_SyslogFacilityName(Conf_SyslogFacility)); +#endif printf(" PingTimeout = %d\n", Conf_PingTimeout); printf(" PongTimeout = %d\n", Conf_PongTimeout); printf(" ConnectRetry = %d\n", Conf_ConnectRetry); @@ -600,6 +604,14 @@ Set_Defaults(bool InitServers) Conf_MaxJoins = 10; Conf_MaxNickLength = CLIENT_NICK_LEN_DEFAULT; +#ifdef SYSLOG +#ifdef LOG_LOCAL5 + Conf_SyslogFacility = LOG_LOCAL5; +#else + Conf_SyslogFacility = 0; +#endif +#endif + /* Initialize server configuration structures */ if (InitServers) { for (i = 0; i < MAX_SERVERS; @@ -1147,6 +1159,13 @@ Handle_GLOBAL( int Line, char *Var, char *Arg ) Conf_SSLOptions.DHFile = strdup_warn( Arg ); return; } +#endif +#ifdef SYSLOG + if (strcasecmp(Var, "SyslogFacility") == 0) { + Conf_SyslogFacility = ngt_SyslogFacilityID(Arg, + Conf_SyslogFacility); + return; + } #endif Config_Error(LOG_ERR, "%s, line %d (section \"Global\"): Unknown variable \"%s\"!", NGIRCd_ConfFile, Line, Var); diff --git a/src/ngircd/conf.h b/src/ngircd/conf.h index 5cf5f6b1..ff67dc79 100644 --- a/src/ngircd/conf.h +++ b/src/ngircd/conf.h @@ -173,6 +173,13 @@ GLOBAL int Conf_MaxConnectionsIP; /* Maximum length of a nick name */ GLOBAL unsigned int Conf_MaxNickLength; +#ifdef SYSLOG + +/* Syslog "facility" */ +GLOBAL int Conf_SyslogFacility; + +#endif + GLOBAL void Conf_Init PARAMS((void)); GLOBAL bool Conf_Rehash PARAMS((void)); GLOBAL int Conf_Test PARAMS((void)); diff --git a/src/ngircd/log.c b/src/ngircd/log.c index 0cfe3b71..3710142d 100644 --- a/src/ngircd/log.c +++ b/src/ngircd/log.c @@ -36,6 +36,7 @@ #include "conn.h" #include "channel.h" #include "irc-write.h" +#include "conf.h" #include "exp.h" #include "log.h" @@ -72,13 +73,10 @@ Log_Init( bool Daemon_Mode ) Is_Daemon = Daemon_Mode; #ifdef SYSLOG -#ifndef LOG_CONS /* Kludge: mips-dec-ultrix4.5 has no LOG_CONS/LOG_LOCAL5 */ +#ifndef LOG_CONS /* Kludge: mips-dec-ultrix4.5 has no LOG_CONS */ #define LOG_CONS 0 #endif -#ifndef LOG_LOCAL5 -#define LOG_LOCAL5 0 -#endif - openlog( PACKAGE_NAME, LOG_CONS|LOG_PID, LOG_LOCAL5 ); + openlog(PACKAGE_NAME, LOG_CONS|LOG_PID, Conf_SyslogFacility); #endif Log( LOG_NOTICE, "%s started.", NGIRCd_Version ); @@ -267,7 +265,7 @@ GLOBAL void Log_Init_Subprocess(char UNUSED *Name) { #ifdef SYSLOG - openlog( PACKAGE_NAME, LOG_CONS|LOG_PID, LOG_LOCAL5 ); + openlog(PACKAGE_NAME, LOG_CONS|LOG_PID, Conf_SyslogFacility); #endif #ifdef DEBUG Log_Subprocess(LOG_DEBUG, "%s sub-process starting, PID %ld.", -- cgit 1.4.1