2 * mainconf.c Handle the server's configuration.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 * Copyright 2002,2006-2007 The FreeRADIUS server project
21 * Copyright 2002 Alan DeKok <aland@ox.org>
24 #include <freeradius-devel/ident.h>
27 #include <freeradius-devel/radiusd.h>
28 #include <freeradius-devel/modules.h>
29 #include <freeradius-devel/rad_assert.h>
33 #ifdef HAVE_SYS_RESOURCE_H
34 #include <sys/resource.h>
45 #ifdef HAVE_SYS_PRCTL_H
46 #include <sys/prctl.h>
53 #ifdef HAVE_SYS_STAT_H
61 struct main_config_t mainconfig;
62 char *request_log_file = NULL;
63 char *debug_condition = NULL;
65 typedef struct cached_config_t {
66 struct cached_config_t *next;
71 static cached_config_t *cs_cache = NULL;
74 * Temporary local variables for parsing the configuration
79 * Systems that have set/getresuid also have setuid.
81 static uid_t server_uid = 0;
82 static gid_t server_gid = 0;
83 static const char *uid_name = NULL;
84 static const char *gid_name = NULL;
86 static const char *chroot_dir = NULL;
87 static int allow_core_dumps = 0;
88 static const char *radlog_dest = NULL;
91 * These are not used anywhere else..
93 static const char *localstatedir = NULL;
94 static const char *prefix = NULL;
95 static char *syslog_facility = NULL;
96 static const FR_NAME_NUMBER str2fac[] = {
101 { "user", LOG_USER },
104 { "mail", LOG_MAIL },
107 { "daemon", LOG_DAEMON },
110 { "auth", LOG_AUTH },
116 { "news", LOG_NEWS },
119 { "uucp", LOG_UUCP },
122 { "cron", LOG_CRON },
125 { "authpriv", LOG_AUTHPRIV },
131 { "local0", LOG_LOCAL0 },
134 { "local1", LOG_LOCAL1 },
137 { "local2", LOG_LOCAL2 },
140 { "local3", LOG_LOCAL3 },
143 { "local4", LOG_LOCAL4 },
146 { "local5", LOG_LOCAL5 },
149 { "local6", LOG_LOCAL6 },
152 { "local7", LOG_LOCAL7 },
158 * Security configuration for the server.
160 static const CONF_PARSER security_config[] = {
161 { "max_attributes", PW_TYPE_INTEGER, 0, &fr_max_attributes, Stringify(0) },
162 { "reject_delay", PW_TYPE_INTEGER, 0, &mainconfig.reject_delay, Stringify(0) },
163 { "status_server", PW_TYPE_BOOLEAN, 0, &mainconfig.status_server, "no"},
164 { NULL, -1, 0, NULL, NULL }
169 * Logging configuration for the server.
171 static const CONF_PARSER logdest_config[] = {
172 { "destination", PW_TYPE_STRING_PTR, 0, &radlog_dest, "files" },
173 { "syslog_facility", PW_TYPE_STRING_PTR, 0, &syslog_facility, Stringify(0) },
175 { "file", PW_TYPE_STRING_PTR, 0, &mainconfig.log_file, "${logdir}/radius.log" },
176 { "requests", PW_TYPE_STRING_PTR, 0, &request_log_file, NULL },
177 { NULL, -1, 0, NULL, NULL }
181 static const CONF_PARSER serverdest_config[] = {
182 { "log", PW_TYPE_SUBSECTION, 0, NULL, (const void *) logdest_config },
183 { "log_file", PW_TYPE_STRING_PTR, 0, &mainconfig.log_file, NULL },
184 { "log_destination", PW_TYPE_STRING_PTR, 0, &radlog_dest, NULL },
185 { NULL, -1, 0, NULL, NULL }
189 static const CONF_PARSER log_config_nodest[] = {
190 { "stripped_names", PW_TYPE_BOOLEAN, 0, &log_stripped_names,"no" },
192 { "auth", PW_TYPE_BOOLEAN, 0, &mainconfig.log_auth, "no" },
193 { "auth_badpass", PW_TYPE_BOOLEAN, 0, &mainconfig.log_auth_badpass, "no" },
194 { "auth_goodpass", PW_TYPE_BOOLEAN, 0, &mainconfig.log_auth_goodpass, "no" },
195 { "msg_badpass", PW_TYPE_STRING_PTR, 0, &mainconfig.auth_badpass_msg, NULL},
196 { "msg_goodpass", PW_TYPE_STRING_PTR, 0, &mainconfig.auth_goodpass_msg, NULL},
198 { NULL, -1, 0, NULL, NULL }
203 * A mapping of configuration file names to internal variables
205 static const CONF_PARSER server_config[] = {
207 * FIXME: 'prefix' is the ONLY one which should be
208 * configured at compile time. Hard-coding it here is
209 * bad. It will be cleaned up once we clean up the
210 * hard-coded defines for the locations of the various
213 { "prefix", PW_TYPE_STRING_PTR, 0, &prefix, "/usr/local"},
214 { "localstatedir", PW_TYPE_STRING_PTR, 0, &localstatedir, "${prefix}/var"},
215 { "logdir", PW_TYPE_STRING_PTR, 0, &radlog_dir, "${localstatedir}/log"},
216 { "libdir", PW_TYPE_STRING_PTR, 0, &radlib_dir, "${prefix}/lib"},
217 { "radacctdir", PW_TYPE_STRING_PTR, 0, &radacct_dir, "${logdir}/radacct" },
218 { "hostname_lookups", PW_TYPE_BOOLEAN, 0, &fr_dns_lookups, "no" },
219 { "max_request_time", PW_TYPE_INTEGER, 0, &mainconfig.max_request_time, Stringify(MAX_REQUEST_TIME) },
220 { "cleanup_delay", PW_TYPE_INTEGER, 0, &mainconfig.cleanup_delay, Stringify(CLEANUP_DELAY) },
221 { "max_requests", PW_TYPE_INTEGER, 0, &mainconfig.max_requests, Stringify(MAX_REQUESTS) },
222 #ifdef DELETE_BLOCKED_REQUESTS
223 { "delete_blocked_requests", PW_TYPE_INTEGER, 0, &mainconfig.kill_unresponsive_children, Stringify(FALSE) },
225 { "pidfile", PW_TYPE_STRING_PTR, 0, &mainconfig.pid_file, "${run_dir}/radiusd.pid"},
226 { "checkrad", PW_TYPE_STRING_PTR, 0, &mainconfig.checkrad, "${sbindir}/checkrad" },
228 { "debug_level", PW_TYPE_INTEGER, 0, &mainconfig.debug_level, "0"},
231 { "proxy_requests", PW_TYPE_BOOLEAN, 0, &mainconfig.proxy_requests, "yes" },
233 { "log", PW_TYPE_SUBSECTION, 0, NULL, (const void *) log_config_nodest },
236 * People with old configs will have these. They are listed
237 * AFTER the "log" section, so if they exist in radiusd.conf,
238 * it will prefer "log_foo = bar" to "log { foo = bar }".
239 * They're listed with default values of NULL, so that if they
240 * DON'T exist in radiusd.conf, then the previously parsed
241 * values for "log { foo = bar}" will be used.
243 { "log_auth", PW_TYPE_BOOLEAN, 0, &mainconfig.log_auth, NULL },
244 { "log_auth_badpass", PW_TYPE_BOOLEAN, 0, &mainconfig.log_auth_badpass, NULL },
245 { "log_auth_goodpass", PW_TYPE_BOOLEAN, 0, &mainconfig.log_auth_goodpass, NULL },
246 { "log_stripped_names", PW_TYPE_BOOLEAN, 0, &log_stripped_names, NULL },
248 { "security", PW_TYPE_SUBSECTION, 0, NULL, (const void *) security_config },
250 { NULL, -1, 0, NULL, NULL }
253 static const CONF_PARSER bootstrap_config[] = {
255 { "user", PW_TYPE_STRING_PTR, 0, &uid_name, NULL },
256 { "group", PW_TYPE_STRING_PTR, 0, &gid_name, NULL },
258 { "chroot", PW_TYPE_STRING_PTR, 0, &chroot_dir, NULL },
259 { "allow_core_dumps", PW_TYPE_BOOLEAN, 0, &allow_core_dumps, "no" },
261 { NULL, -1, 0, NULL, NULL }
266 #define MAX_ARGV (256)
269 static size_t config_escape_func(char *out, size_t outlen, const char *in)
272 static const char *disallowed = "%{}\\'\"`";
276 * Non-printable characters get replaced with their
277 * mime-encoded equivalents.
280 if (outlen <= 3) break;
282 snprintf(out, outlen, "=%02X", (unsigned char) in[0]);
289 } else if (strchr(disallowed, *in) != NULL) {
290 if (outlen <= 2) break;
302 * Only one byte left.
322 * Xlat for %{config:section.subsection.attribute}
324 static size_t xlat_config(void *instance, REQUEST *request,
325 char *fmt, char *out,
327 RADIUS_ESCAPE_STRING func)
334 request = request; /* -Wunused */
335 instance = instance; /* -Wunused */
340 if (!radius_xlat(buffer, sizeof(buffer), fmt, request, config_escape_func)) {
344 ci = cf_reference_item(request->root->config,
345 request->root->config, buffer);
346 if (!ci || !cf_item_is_pair(ci)) {
351 cp = cf_itemtopair(ci);
354 * Ensure that we only copy what's necessary.
356 * If 'outlen' is too small, then the output is chopped to fit.
358 value = cf_pair_value(cp);
360 if (outlen > strlen(value)) {
361 outlen = strlen(value) + 1;
365 return func(out, outlen, value);
370 * Xlat for %{client:foo}
372 static size_t xlat_client(UNUSED void *instance, REQUEST *request,
373 char *fmt, char *out,
375 UNUSED RADIUS_ESCAPE_STRING func)
377 const char *value = NULL;
380 if (!fmt || !out || (outlen < 1)) return 0;
382 if (!request || !request->client) {
387 cp = cf_pair_find(request->client->cs, fmt);
388 if (!cp || !(value = cf_pair_value(cp))) {
393 strlcpy(out, value, outlen);
399 * Recursively make directories.
401 static int r_mkdir(const char *part)
403 char *ptr, parentdir[500];
406 if (stat(part, &st) == 0)
409 ptr = strrchr(part, FR_DIR_SEP);
414 snprintf(parentdir, (ptr - part)+1, "%s", part);
416 if (r_mkdir(parentdir) != 0)
419 if (mkdir(part, 0770) != 0) {
420 radlog(L_ERR, "mkdir(%s) error: %s\n", part, strerror(errno));
427 #ifdef HAVE_SYS_RESOURCE_H
428 static struct rlimit core_limits;
431 static void fr_set_dumpable(void)
434 * If configured, turn core dumps off.
436 if (!allow_core_dumps) {
437 #ifdef HAVE_SYS_RESOURCE_H
438 struct rlimit no_core;
441 no_core.rlim_cur = 0;
442 no_core.rlim_max = 0;
444 if (setrlimit(RLIMIT_CORE, &no_core) < 0) {
445 radlog(L_ERR, "Failed disabling core dumps: %s",
453 * Set or re-set the dumpable flag.
455 #ifdef HAVE_SYS_PRCTL_H
456 #ifdef PR_SET_DUMPABLE
457 if (prctl(PR_SET_DUMPABLE, 1) < 0) {
458 radlog(L_ERR,"Cannot re-enable core dumps: prctl(PR_SET_DUMPABLE) failed: '%s'",
465 * Reset the core dump limits to their original value.
467 #ifdef HAVE_SYS_RESOURCE_H
468 if (setrlimit(RLIMIT_CORE, &core_limits) < 0) {
469 radlog(L_ERR, "Cannot update core dump limit: %s",
476 static int doing_setuid = FALSE;
478 #if defined(HAVE_SETRESUID) && defined (HAVE_GETRESUID)
479 void fr_suid_up(void)
481 uid_t ruid, euid, suid;
483 if (getresuid(&ruid, &euid, &suid) < 0) {
484 radlog(L_ERR, "Failed getting saved UID's");
488 if (setresuid(-1, suid, -1) < 0) {
489 radlog(L_ERR, "Failed switching to privileged user");
493 if (geteuid() != suid) {
494 radlog(L_ERR, "Switched to unknown UID");
499 void fr_suid_down(void)
501 if (!doing_setuid) return;
503 if (setresuid(-1, server_uid, geteuid()) < 0) {
504 fprintf(stderr, "%s: Failed switching to uid %s: %s\n",
505 progname, uid_name, strerror(errno));
509 if (geteuid() != server_uid) {
510 fprintf(stderr, "%s: Failed switching uid: UID is incorrect\n",
518 void fr_suid_down_permanent(void)
520 if (!doing_setuid) return;
522 if (setresuid(server_uid, server_uid, server_uid) < 0) {
523 radlog(L_ERR, "Failed in permanent switch to uid %s: %s",
524 uid_name, strerror(errno));
528 if (geteuid() != server_uid) {
529 radlog(L_ERR, "Switched to unknown uid");
537 * Much less secure...
539 void fr_suid_up(void)
542 void fr_suid_down(void)
544 if (!uid_name) return;
546 if (setuid(server_uid) < 0) {
547 fprintf(stderr, "%s: Failed switching to uid %s: %s\n",
548 progname, uid_name, strerror(errno));
554 void fr_suid_down_permanent(void)
558 #endif /* HAVE_SETRESUID && HAVE_GETRESUID */
559 #else /* HAVE_SETUID */
560 void fr_suid_up(void)
563 void fr_suid_down(void)
567 void fr_suid_down_permanent(void)
571 #endif /* HAVE_SETUID */
576 * Do chroot, if requested.
578 * Switch UID and GID to what is specified in the config file
580 static int switch_users(CONF_SECTION *cs)
582 #ifdef HAVE_SYS_RESOURCE_H
584 * Get the current maximum for core files. Do this
585 * before anything else so as to ensure it's properly
588 if (getrlimit(RLIMIT_CORE, &core_limits) < 0) {
589 radlog(L_ERR, "Failed to get current core limit: %s", strerror(errno));
595 * Don't do chroot/setuid/setgid if we're in debugging
598 if (debug_flag && (getuid() != 0)) return 1;
600 if (cf_section_parse(cs, NULL, bootstrap_config) < 0) {
601 fprintf(stderr, "radiusd: Error: Failed to parse user/group information.\n");
611 gr = getgrnam(gid_name);
613 fprintf(stderr, "%s: Cannot get ID for group %s: %s\n",
614 progname, gid_name, strerror(errno));
617 server_gid = gr->gr_gid;
619 server_gid = getgid();
628 pw = getpwnam(uid_name);
630 fprintf(stderr, "%s: Cannot get passwd entry for user %s: %s\n",
631 progname, uid_name, strerror(errno));
635 if (getuid() == pw->pw_uid) {
639 server_uid = pw->pw_uid;
640 #ifdef HAVE_INITGROUPS
641 if (initgroups(uid_name, server_gid) < 0) {
642 fprintf(stderr, "%s: Cannot initialize supplementary group list for user %s: %s\n",
643 progname, uid_name, strerror(errno));
649 server_uid = getuid();
654 if (chroot(chroot_dir) < 0) {
655 fprintf(stderr, "%s: Failed to perform chroot %s: %s",
656 progname, chroot_dir, strerror(errno));
661 * Note that we leave chdir alone. It may be
662 * OUTSIDE of the root. This allows us to read
663 * the configuration from "-d ./etc/raddb", with
664 * the chroot as "./chroot/" for example. After
665 * the server has been loaded, it does a "cd
666 * ${logdir}" below, so that core files (if any)
667 * go to a logging directory.
669 * This also allows the configuration of the
670 * server to be outside of the chroot. If the
671 * server is statically linked, then the only
672 * things needed inside of the chroot are the
673 * logging directories.
679 if (gid_name && (setgid(server_gid) < 0)) {
680 fprintf(stderr, "%s: Failed setting group to %s: %s",
681 progname, gid_name, strerror(errno));
688 * Just before losing root permissions, ensure that the
689 * log files have the correct owner && group.
691 * We have to do this because the log file MAY have been
692 * specified on the command-line.
694 if (uid_name || gid_name) {
695 if ((mainconfig.radlog_dest == RADLOG_FILES) &&
696 (mainconfig.radlog_fd < 0)) {
697 mainconfig.radlog_fd = open(mainconfig.log_file,
698 O_WRONLY | O_APPEND | O_CREAT, 0640);
699 if (mainconfig.radlog_fd < 0) {
700 fprintf(stderr, "radiusd: Failed to open log file %s: %s\n", mainconfig.log_file, strerror(errno));
704 if (chown(mainconfig.log_file, server_uid, server_gid) < 0) {
705 fprintf(stderr, "%s: Cannot change ownership of log file %s: %s\n",
706 progname, mainconfig.log_file, strerror(errno));
720 * This also clears the dumpable flag if core dumps
725 if (allow_core_dumps) {
726 radlog(L_INFO, "Core dumps are enabled.");
731 #endif /* HAVE_SETUID */
734 static const FR_NAME_NUMBER str2dest[] = {
735 { "null", RADLOG_NULL },
736 { "files", RADLOG_FILES },
737 { "syslog", RADLOG_SYSLOG },
738 { "stdout", RADLOG_STDOUT },
739 { "stderr", RADLOG_STDERR },
740 { NULL, RADLOG_NUM_DEST }
747 * This function can ONLY be called from the main server process.
749 int read_mainconfig(int reload)
751 const char *p = NULL;
759 radlog(L_ERR, "Reload is not implemented");
763 if (stat(radius_dir, &statbuf) < 0) {
764 radlog(L_ERR, "Errors reading %s: %s",
765 radius_dir, strerror(errno));
770 if ((statbuf.st_mode & S_IWOTH) != 0) {
771 radlog(L_ERR, "Configuration directory %s is globally writable. Refusing to start due to insecure configuration.",
778 if (0 && (statbuf.st_mode & S_IROTH) != 0) {
779 radlog(L_ERR, "Configuration directory %s is globally readable. Refusing to start due to insecure configuration.",
785 radlog(L_INFO, "Starting - reading configuration files ...");
787 /* Read the configuration file */
788 snprintf(buffer, sizeof(buffer), "%.200s/%.50s.conf",
789 radius_dir, mainconfig.name);
790 if ((cs = cf_file_read(buffer)) == NULL) {
791 radlog(L_ERR, "Errors reading %s", buffer);
796 * If there was no log destination set on the command line,
799 if (mainconfig.radlog_dest == RADLOG_NULL) {
800 if (cf_section_parse(cs, NULL, serverdest_config) < 0) {
801 fprintf(stderr, "radiusd: Error: Failed to parse log{} section.\n");
802 cf_section_free(&cs);
807 fprintf(stderr, "radiusd: Error: No log destination specified.\n");
808 cf_section_free(&cs);
812 mainconfig.radlog_dest = fr_str2int(str2dest, radlog_dest,
814 if (mainconfig.radlog_dest == RADLOG_NUM_DEST) {
815 fprintf(stderr, "radiusd: Error: Unknown log_destination %s\n",
817 cf_section_free(&cs);
821 if (mainconfig.radlog_dest == RADLOG_SYSLOG) {
823 * Make sure syslog_facility isn't NULL
826 if (!syslog_facility) {
827 fprintf(stderr, "radiusd: Error: Syslog chosen but no facility was specified\n");
828 cf_section_free(&cs);
831 mainconfig.syslog_facility = fr_str2int(str2fac, syslog_facility, -1);
832 if (mainconfig.syslog_facility < 0) {
833 fprintf(stderr, "radiusd: Error: Unknown syslog_facility %s\n",
835 cf_section_free(&cs);
841 * Call openlog only once, when the
844 openlog(progname, LOG_PID, mainconfig.syslog_facility);
847 } else if (mainconfig.radlog_dest == RADLOG_FILES) {
848 if (!mainconfig.log_file) {
849 fprintf(stderr, "radiusd: Error: Specified \"files\" as a log destination, but no log filename was given!\n");
850 cf_section_free(&cs);
858 * Switch users as early as possible.
860 if (!switch_users(cs)) exit(1);
864 * Open the log file AFTER switching uid / gid. If we
865 * did switch uid/gid, then the code in switch_users()
866 * took care of setting the file permissions correctly.
868 if ((mainconfig.radlog_dest == RADLOG_FILES) &&
869 (mainconfig.radlog_fd < 0)) {
870 mainconfig.radlog_fd = open(mainconfig.log_file,
871 O_WRONLY | O_APPEND | O_CREAT, 0640);
872 if (mainconfig.radlog_fd < 0) {
873 fprintf(stderr, "radiusd: Failed to open log file %s: %s\n", mainconfig.log_file, strerror(errno));
874 cf_section_free(&cs);
879 /* Initialize the dictionary */
880 cp = cf_pair_find(cs, "dictionary");
881 if (cp) p = cf_pair_value(cp);
882 if (!p) p = radius_dir;
883 DEBUG2("including dictionary file %s/%s", p, RADIUS_DICTIONARY);
884 if (dict_init(p, RADIUS_DICTIONARY) != 0) {
885 radlog(L_ERR, "Errors reading dictionary: %s",
891 * This allows us to figure out where, relative to
892 * radiusd.conf, the other configuration files exist.
894 cf_section_parse(cs, NULL, server_config);
897 * Free the old configuration items, and replace them
900 * Note that where possible, we do atomic switch-overs,
901 * to ensure that the pointers are always valid.
903 cf_section_free(&mainconfig.config);
904 mainconfig.config = cs;
906 DEBUG2("%s: #### Loading Realms and Home Servers ####", mainconfig.name);
907 if (!realms_init(cs)) {
911 DEBUG2("%s: #### Loading Clients ####", mainconfig.name);
912 if (!clients_parse_section(cs)) {
917 * Register the %{config:section.subsection} xlat function.
919 xlat_register("config", xlat_config, NULL);
920 xlat_register("client", xlat_client, NULL);
923 * Starting the server, WITHOUT "-x" on the
924 * command-line: use whatever is in the config
927 if (debug_flag == 0) {
928 debug_flag = mainconfig.debug_level;
930 fr_debug_flag = debug_flag;
933 * Go update our behaviour, based on the configuration
938 * Sanity check the configuration for internal
941 if (mainconfig.reject_delay > mainconfig.cleanup_delay) {
942 mainconfig.reject_delay = mainconfig.cleanup_delay;
944 if (mainconfig.reject_delay < 0) mainconfig.reject_delay = 0;
946 /* Reload the modules. */
947 if (setup_modules(reload, mainconfig.config) < 0) {
952 if (chdir(radlog_dir) < 0) {
953 radlog(L_ERR, "Failed to 'chdir %s' after chroot: %s",
954 radlog_dir, strerror(errno));
959 cc = rad_malloc(sizeof(*cc));
960 memset(cc, 0, sizeof(*cc));
963 rad_assert(cs_cache == NULL);
970 * Free the configuration. Called only when the server is exiting.
972 int free_mainconfig(void)
974 cached_config_t *cc, *next;
976 virtual_servers_free(0);
979 * Free all of the cached configurations.
981 for (cc = cs_cache; cc != NULL; cc = next) {
983 cf_section_free(&cc->cs);
988 * Clean up the configuration data
992 listen_free(&mainconfig.listen);
998 void hup_mainconfig(void)
1000 cached_config_t *cc;
1004 radlog(L_INFO, "HUP - Re-reading configuration files");
1006 /* Read the configuration file */
1007 snprintf(buffer, sizeof(buffer), "%.200s/%.50s.conf",
1008 radius_dir, mainconfig.name);
1009 if ((cs = cf_file_read(buffer)) == NULL) {
1010 radlog(L_ERR, "Failed to re-read %s", buffer);
1014 cc = rad_malloc(sizeof(*cc));
1015 memset(cc, 0, sizeof(*cc));
1018 * Save the current configuration. Note that we do NOT
1019 * free older ones. We should probably do so at some
1020 * point. Doing so will require us to mark which modules
1021 * are still in use, and which aren't. Modules that
1022 * can't be HUPed always use the original configuration.
1023 * Modules that can be HUPed use one of the newer
1026 cc->created = time(NULL);
1028 cc->next = cs_cache;
1032 * Re-open the log file. If we can't, then keep logging
1033 * to the old log file.
1035 * The "open log file" code is here rather than in log.c,
1036 * because it makes that function MUCH simpler.
1038 if (mainconfig.radlog_dest == RADLOG_FILES) {
1041 fd = open(mainconfig.log_file,
1042 O_WRONLY | O_APPEND | O_CREAT, 0640);
1045 * Atomic swap. We'd like to keep the old
1046 * FD around so that callers don't
1047 * suddenly find the FD closed, and the
1048 * writes go nowhere. But that's hard to
1049 * do. So... we have the case where a
1050 * log message *might* be lost on HUP.
1052 old_fd = mainconfig.radlog_fd;
1053 mainconfig.radlog_fd = fd;
1058 radlog(L_INFO, "HUP - loading modules");
1061 * Prefer the new module configuration.
1063 module_hup(cf_section_sub_find(cs, "modules"));
1066 * Load new servers BEFORE freeing old ones.
1068 virtual_servers_load(cs);
1070 virtual_servers_free(cc->created - mainconfig.max_request_time * 4);