Module: ngircd.git
Branch: master
Commit: 9d3800fd15a273f23f51c1f1ab3bc75dacf6c589
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=9d3800fd…
Author: Alexander Barton <alex(a)barton.de>
Date: Thu May 30 08:55:48 2013 -0700
Merge pull request #3 from Cofyc/master
irc-info.c: some commands use LINE_LEN as command buffer len
---
Module: ngircd.git
Branch: master
Commit: 7ea3864a9369086024a2d541b053963958b19899
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=7ea3864a…
Author: Alexander Barton <alex(a)barton.de>
Date: Sat May 25 00:25:38 2013 +0200
IncludeDir: default to "$SYSCONFDIR/ngircd.conf.d"
Now "IncludeDir" defaults to "$SYSCONFDIR/ngircd.conf.d" instead
of no directory, but a missing directory is only reported as an
error if it has explicitely configured in the main configuration
file and simply ignored otherwise.
Therefore it is now possible not to touch the default (sample)
configuration file at all, and set all distribution and/or system
specific configuration options in "*.conf" files stored in
"$SYSCONFDIF/ngircd.conf.d/".
Thanks to "Elmasloco" for the idea!
---
src/ngircd/conf.c | 52 ++++++++++++++++++++++-----------------
src/ngircd/defines.h | 5 +++-
src/testsuite/ngircd-test1.conf | 1 +
src/testsuite/ngircd-test2.conf | 1 +
4 files changed, 35 insertions(+), 24 deletions(-)
diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c
index c08183d..aad64b3 100644
--- a/src/ngircd/conf.c
+++ b/src/ngircd/conf.c
@@ -947,33 +947,39 @@ Read_Config(bool TestOnly, bool IsStarting)
fclose(fd);
if (Conf_IncludeDir[0]) {
- /* Include further configuration files, if any */
dh = opendir(Conf_IncludeDir);
- if (dh) {
- while ((entry = readdir(dh)) != NULL) {
- ptr = strrchr(entry->d_name, '.');
- if (!ptr || strcasecmp(ptr, ".conf") != 0)
- continue;
- snprintf(file, sizeof(file), "%s/%s",
- Conf_IncludeDir, entry->d_name);
- if (TestOnly)
- Config_Error(LOG_INFO,
- "Reading configuration from \"%s\" ...",
- file);
- fd = fopen(file, "r");
- if (fd) {
- Read_Config_File(file, fd);
- fclose(fd);
- } else
- Config_Error(LOG_ALERT,
- "Can't read configuration \"%s\": %s",
- file, strerror(errno));
- }
- closedir(dh);
- } else
+ if (!dh)
Config_Error(LOG_ALERT,
"Can't open include directory \"%s\": %s",
Conf_IncludeDir, strerror(errno));
+ } else {
+ strlcpy(Conf_IncludeDir, SYSCONFDIR, sizeof(Conf_IncludeDir));
+ strlcat(Conf_IncludeDir, CONFIG_DIR, sizeof(Conf_IncludeDir));
+ dh = opendir(Conf_IncludeDir);
+ }
+
+ /* Include further configuration files, if IncludeDir is available */
+ if (dh) {
+ while ((entry = readdir(dh)) != NULL) {
+ ptr = strrchr(entry->d_name, '.');
+ if (!ptr || strcasecmp(ptr, ".conf") != 0)
+ continue;
+ snprintf(file, sizeof(file), "%s/%s",
+ Conf_IncludeDir, entry->d_name);
+ if (TestOnly)
+ Config_Error(LOG_INFO,
+ "Reading configuration from \"%s\" ...",
+ file);
+ fd = fopen(file, "r");
+ if (fd) {
+ Read_Config_File(file, fd);
+ fclose(fd);
+ } else
+ Config_Error(LOG_ALERT,
+ "Can't read configuration \"%s\": %s",
+ file, strerror(errno));
+ }
+ closedir(dh);
}
/* Check if there is still a server to add */
diff --git a/src/ngircd/defines.h b/src/ngircd/defines.h
index cffbfad..7784c17 100644
--- a/src/ngircd/defines.h
+++ b/src/ngircd/defines.h
@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2012 Alexander Barton (alex(a)barton.de) and Contributors.
+ * Copyright (c)2001-2013 Alexander Barton (alex(a)barton.de) and Contributors.
*
* 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
@@ -73,6 +73,9 @@
/** Configuration file name. */
#define CONFIG_FILE "/ngircd.conf"
+/** Directory containing optional configuration snippets. */
+#define CONFIG_DIR "/ngircd.conf.d"
+
/** Name of the MOTD file. */
#define MOTD_FILE "/ngircd.motd"
diff --git a/src/testsuite/ngircd-test1.conf b/src/testsuite/ngircd-test1.conf
index 1e40fd3..0d0cccc 100644
--- a/src/testsuite/ngircd-test1.conf
+++ b/src/testsuite/ngircd-test1.conf
@@ -16,6 +16,7 @@
[Options]
OperCanUseMode = yes
Ident = no
+ IncludeDir = /var/empty
PAM = no
[Operator]
diff --git a/src/testsuite/ngircd-test2.conf b/src/testsuite/ngircd-test2.conf
index e3f8867..c9d7f6c 100644
--- a/src/testsuite/ngircd-test2.conf
+++ b/src/testsuite/ngircd-test2.conf
@@ -16,6 +16,7 @@
[Options]
OperCanUseMode = yes
Ident = no
+ IncludeDir = /var/empty
PAM = no
[Operator]
Module: ngircd.git
Branch: master
Commit: 6beb0fad3ff09ae92a7aea0e4b8ad7b00fe2e26d
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=6beb0fad…
Author: Alexander Barton <alex(a)barton.de>
Date: Fri May 24 21:57:42 2013 +0200
conf.c: New function Read_Config_File()
This function reads in and parses a single configuration file.
Adjust all other functions to display the correct name of the
file being read in currently.
---
src/ngircd/conf.c | 388 +++++++++++++++++++++++++++++------------------------
1 file changed, 212 insertions(+), 176 deletions(-)
Diff: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commitdiff;h=6beb…