X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Fconf.c;h=bae5fa7ad7b8f96467eb200092d0a85440102d7a;hp=c08183de9c1c94861b6f646bdbf341615391a652;hb=5021977bb1bf6c13323b7ef2a73f64e9533a379a;hpb=891dbd2acc59a6d9ff6dd8a5b12e91f5a8fa20ed diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c index c08183de..bae5fa7a 100644 --- a/src/ngircd/conf.c +++ b/src/ngircd/conf.c @@ -827,7 +827,7 @@ no_listenports(void) /** * Read contents of a text file into an array. * - * This function is used to read the MOTD and help text file, for exampe. + * This function is used to read the MOTD and help text file, for example. * * @param filename Name of the file to read. * @return true, when the file has been read in. @@ -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 */