about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2012-02-14 11:01:13 +0100
committerAlexander Barton <alex@barton.de>2012-02-14 11:01:13 +0100
commit3641e511095203818df7ca05439cf42eb7c7c954 (patch)
treed99699f90b233d44998a37fed6eece07d032ea9a /src
parent3f46e93ccc429722ed4298127d664673d9e8f37d (diff)
downloadngircd-3641e511095203818df7ca05439cf42eb7c7c954.tar.gz
ngircd-3641e511095203818df7ca05439cf42eb7c7c954.zip
Correctly re-open syslog logging after reading of configuration
Syslog logging has been initialized before reading the configuraton
file, so ngIRCd always used the default facility and ignored the
"SyslogFacility" configuration option.

Thanks to Patrik Schindler for reporting this issue!
Diffstat (limited to 'src')
-rw-r--r--src/ngircd/log.c23
-rw-r--r--src/ngircd/log.h3
-rw-r--r--src/ngircd/ngircd.c4
3 files changed, 27 insertions, 3 deletions
diff --git a/src/ngircd/log.c b/src/ngircd/log.c
index 80b2c056..d81bec24 100644
--- a/src/ngircd/log.c
+++ b/src/ngircd/log.c
@@ -64,6 +64,12 @@ Log_Message(int Level, const char *msg)
 }
 
 
+/**
+ * Initialitze logging.
+ * This function is called before the configuration file is read in.
+ *
+ * @param Daemon_Mode Set to true if ngIRCd is running as daemon.
+ */
 GLOBAL void
 Log_Init(bool Daemon_Mode)
 {
@@ -80,6 +86,23 @@ Log_Init(bool Daemon_Mode)
 } /* Log_Init */
 
 
+/**
+ * Re-init logging after reading the configuration file.
+ */
+GLOBAL void
+Log_ReInit(void)
+{
+#ifdef SYSLOG
+#ifndef LOG_CONS     /* Kludge: mips-dec-ultrix4.5 has no LOG_CONS */
+#define LOG_CONS 0
+#endif
+	closelog();
+	openlog(PACKAGE_NAME, LOG_CONS|LOG_PID, Conf_SyslogFacility);
+#endif
+	Log(LOG_NOTICE, "%s started.", NGIRCd_Version);
+}
+
+
 GLOBAL void
 Log_Exit( void )
 {
diff --git a/src/ngircd/log.h b/src/ngircd/log.h
index 5222b5d2..f582e6c8 100644
--- a/src/ngircd/log.h
+++ b/src/ngircd/log.h
@@ -1,6 +1,6 @@
 /*
  * ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2010 Alexander Barton (alex@barton.de)
+ * Copyright (c)2001-2012 Alexander Barton (alex@barton.de)
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -36,6 +36,7 @@ GLOBAL void Log_Init PARAMS(( bool Daemon_Mode ));
 GLOBAL void Log_Exit PARAMS(( void ));
 
 GLOBAL void Log PARAMS(( int Level, const char *Format, ... ));
+GLOBAL void Log_ReInit PARAMS((void));
 
 GLOBAL void Log_ServerNotice PARAMS((char UserMode, const char *Format, ...));
 
diff --git a/src/ngircd/ngircd.c b/src/ngircd/ngircd.c
index 874dfa3f..60d15a1f 100644
--- a/src/ngircd/ngircd.c
+++ b/src/ngircd/ngircd.c
@@ -255,11 +255,11 @@ main(int argc, const char *argv[])
 		NGIRCd_SignalRestart = false;
 		NGIRCd_SignalQuit = false;
 
-		Random_Init();
-
 		/* Initialize modules, part I */
 		Log_Init(!NGIRCd_NoDaemon);
+		Random_Init();
 		Conf_Init();
+		Log_ReInit();
 
 		/* Initialize the "main program": chroot environment, user and
 		 * group ID, ... */