]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Added radmin command "hup main.log". Closes issue #121
authorAlan T. DeKok <aland@freeradius.org>
Tue, 12 Feb 2013 14:56:29 +0000 (09:56 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 12 Feb 2013 14:56:48 +0000 (09:56 -0500)
src/include/radiusd.h
src/main/command.c
src/main/mainconfig.c

index 0c77a01016671790ac8c0a383696f4697cbdd031..5db484e24462a3b3db5e3737e9721552318c4167 100644 (file)
@@ -616,6 +616,7 @@ extern struct main_config_t mainconfig;
 int read_mainconfig(int reload);
 int free_mainconfig(void);
 void hup_mainconfig(void);
+void hup_logfile(void);
 void fr_suid_down(void);
 void fr_suid_up(void);
 void fr_suid_down_permanent(void);
index 3f70fc010eaafe3bc3e4f32237c80751878da5c0..5aae86b438d820f6a3177aebeca0bec56dcebf97 100644 (file)
@@ -305,6 +305,14 @@ static int command_hup(rad_listen_t *listener, int argc, char *argv[])
                return 1;
        }
 
+       /*
+        *      Hack a "main" HUP thingy
+        */
+       if (strcmp(argv[0], "main.log") == 0) {
+               hup_logfile();
+               return 1;
+       }
+
        cs = cf_section_find("modules");
        if (!cs) return 0;
 
index 675118b937edc726fbe5e6d2c5d1a43e29904c8e..843101b8640b72dec6ac538667105f322e5e456b 100644 (file)
@@ -1016,6 +1016,29 @@ int free_mainconfig(void)
        return 0;
 }
 
+void hup_logfile(void)
+{
+               int fd, old_fd;
+               
+               if (mainconfig.radlog_dest != RADLOG_FILES) return;
+
+               fd = open(mainconfig.log_file,
+                         O_WRONLY | O_APPEND | O_CREAT, 0640);
+               if (fd >= 0) {
+                       /*
+                        *      Atomic swap. We'd like to keep the old
+                        *      FD around so that callers don't
+                        *      suddenly find the FD closed, and the
+                        *      writes go nowhere.  But that's hard to
+                        *      do.  So... we have the case where a
+                        *      log message *might* be lost on HUP.
+                        */
+                       old_fd = mainconfig.radlog_fd;
+                       mainconfig.radlog_fd = fd;
+                       close(old_fd);
+               }
+}
+
 void hup_mainconfig(void)
 {
        cached_config_t *cc;
@@ -1056,25 +1079,7 @@ void hup_mainconfig(void)
         *      The "open log file" code is here rather than in log.c,
         *      because it makes that function MUCH simpler.
         */
-       if (mainconfig.radlog_dest == RADLOG_FILES) {
-               int fd, old_fd;
-               
-               fd = open(mainconfig.log_file,
-                         O_WRONLY | O_APPEND | O_CREAT, 0640);
-               if (fd >= 0) {
-                       /*
-                        *      Atomic swap. We'd like to keep the old
-                        *      FD around so that callers don't
-                        *      suddenly find the FD closed, and the
-                        *      writes go nowhere.  But that's hard to
-                        *      do.  So... we have the case where a
-                        *      log message *might* be lost on HUP.
-                        */
-                       old_fd = mainconfig.radlog_fd;
-                       mainconfig.radlog_fd = fd;
-                       close(old_fd);
-               }
-       }
+       hup_logfile();
 
        radlog(L_INFO, "HUP - loading modules");