.\"
.\" ngircd.conf(5) manual page template
.\"
-.TH ngircd.conf 5 "Feb 2013" ngIRCd "ngIRCd Manual"
+.TH ngircd.conf 5 "May 2013" ngIRCd "ngIRCd Manual"
.SH NAME
ngircd.conf \- configuration file of ngIRCd
.SH SYNOPSIS
prepended to their user name.
Default: yes.
.TP
+.TP
+\fBIncludeDir\fR (string)
+Directory containing configuration snippets (*.conf), that should be read in
+after parsing the current configuration file.
+Default: none.
\fBMorePrivacy\fR (boolean)
This will cause ngIRCd to censor user idle time, logon time as well as the
part/quit messages (that are sometimes used to inform everyone about which
#include <grp.h>
#include <sys/types.h>
#include <unistd.h>
-
+#include <dirent.h>
#include "array.h"
#include "ngircd.h"
static char Conf_MotdFile[FNAME_LEN];
static char Conf_HelpFile[FNAME_LEN];
+static char Conf_IncludeDir[FNAME_LEN];
static void Set_Defaults PARAMS(( bool InitServers ));
static bool Read_Config PARAMS(( bool TestOnly, bool IsStarting ));
#ifdef IDENT
printf(" Ident = %s\n", yesno_to_str(Conf_Ident));
#endif
+ printf(" IncludeDir = %s\n", Conf_IncludeDir);
printf(" MorePrivacy = %s\n", yesno_to_str(Conf_MorePrivacy));
printf(" NoticeAuth = %s\n", yesno_to_str(Conf_NoticeAuth));
printf(" OperCanUseMode = %s\n", yesno_to_str(Conf_OperCanMode));
#else
Conf_Ident = false;
#endif
+ strcpy(Conf_IncludeDir, "");
Conf_MorePrivacy = false;
Conf_NoticeAuth = false;
Conf_OperCanMode = false;
Read_Config(bool TestOnly, bool IsStarting)
{
const UINT16 defaultport = 6667;
+ char *ptr, file[FNAME_LEN];
+ struct dirent *entry;
int i, n;
FILE *fd;
+ DIR *dh;
/* Open configuration file */
fd = fopen( NGIRCd_ConfFile, "r" );
#endif
Read_Config_File(NGIRCd_ConfFile, fd);
-
- /* Close configuration file */
- fclose( fd );
+ 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
+ Config_Error(LOG_ALERT,
+ "Can't open include directory \"%s\": %s",
+ Conf_IncludeDir, strerror(errno));
+ }
/* Check if there is still a server to add */
if( New_Server.name[0] ) {
size_t count;
/* Read configuration file */
+ section[0] = '\0';
while (true) {
if (!fgets(str, LINE_LEN, fd))
break;
WarnIdent(Line);
return;
}
+ if (strcasecmp(Var, "IncludeDir") == 0) {
+ len = strlcpy(Conf_IncludeDir, Arg, sizeof(Conf_IncludeDir));
+ if (len >= sizeof(Conf_IncludeDir))
+ Config_Error_TooLong(File, Line, Var);
+ return;
+ }
if (strcasecmp(Var, "MorePrivacy") == 0) {
Conf_MorePrivacy = Check_ArgIsTrue(Arg);
return;