[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ipcop-svn
Subject:    [Ipcop-svn] SF.net SVN: ipcop:[3519]
From:       owes () users ! sourceforge ! net
Date:       2009-08-29 19:57:21
Message-ID: E1MhU37-0008Ci-82 () bj8yhf1 ! ch3 ! sourceforge ! com
[Download RAW message or body]

Revision: 3519
          http://ipcop.svn.sourceforge.net/ipcop/?rev=3519&view=rev
Author:   owes
Date:     2009-08-29 19:57:21 +0000 (Sat, 29 Aug 2009)

Log Message:
-----------
Stop syslogd (not SIGHUP) in case remote logging is used.

Modified Paths:
--------------
    ipcop/trunk/src/misc-progs/restartsyslogd.c

Modified: ipcop/trunk/src/misc-progs/restartsyslogd.c
===================================================================
--- ipcop/trunk/src/misc-progs/restartsyslogd.c	2009-08-29 19:54:38 UTC (rev 3518)
+++ ipcop/trunk/src/misc-progs/restartsyslogd.c	2009-08-29 19:57:21 UTC (rev 3519)
@@ -55,7 +55,9 @@
 int main(int argc, char **argv)
 {
     char buffer[STRING_SIZE], hostname[STRING_SIZE];
-    int config_fd, rc, fd, pid;
+    int config_fd;
+    int rc;
+    int remote_log;
     struct stat st;
     NODEKV *log_kv = NULL;
 
@@ -109,6 +111,8 @@
         exit(ERR_SETTINGS);
     }
 
+    remote_log = test_kv(log_kv, "ENABLE_REMOTELOG", "on");
+
     free_kv(&log_kv);
 
 
@@ -161,44 +165,29 @@
     }
 
 
+    /* If remote syslog is used, stop syslogd first as syslogd will not be able to \
open udp/514 as non-root */ +    if ((access("/var/run/syslogd.pid", 0) != -1) && \
(remote_log == SUCCESS)) { +        verbose_printf(1, "Stopping syslogd ... \n");
+
+        mysignalpidfile("/var/run/syslogd.pid", SIGTERM);
+        unlink("/var/run/syslogd.pid");
+    }
+    
     /* Get syslogd to read the new config file */
-    if ((fd = open("/var/run/syslogd.pid", O_RDONLY)) == -1) {
-        verbose_printf(1, "Starting syslogd ... \n");
-        if (errno == ENOENT) {
-            /* pid file doesn't exists.. restart syslog */
-            if ((rc = safe_system("/usr/sbin/syslogd -u syslogd")) == 0)
-                return 0;
-            else {
-                fprintf(stderr, "Unable to restart syslogd - returned exit code \
                %d\n", rc);
-                exit(ERR_SYSLOG);
-            }
+    if (access("/var/run/syslogd.pid", 0) != -1) {
+        verbose_printf(1, "Restarting syslogd ... \n");
+    
+        if (mysignalpidfile("/var/run/syslogd.pid", SIGHUP) == SUCCESS) {
+            return 0;
         }
-        else {
-            /* Something odd is going on, failsafe */
-            perror("Unable to open pid file");
-            exit(ERR_SYSLOG);
-        }
     }
 
-    memset(buffer, 0, STRING_SIZE);
-    if (read(fd, buffer, STRING_SIZE - 1) == -1) {
-        close(fd);
-        perror("Couldn't read from pid file");
+        
+    verbose_printf(1, "Starting syslogd ... \n");
+    if ((rc = safe_system("/usr/sbin/syslogd -u syslogd -m 0")) != 0) {
+        fprintf(stderr, "Unable to start syslogd - returned exit code %d\n", rc);
         exit(ERR_SYSLOG);
     }
-    close(fd);
-    /* strtol does sanity checks that atoi doesn't do */
-    errno = 0;
-    pid = (int) strtol(buffer, (char **) NULL, 10);
-    if (errno || pid <= 1) {
-        fprintf(stderr, "Bad pid value\n");
-        exit(ERR_SYSLOG);
-    }
-    verbose_printf(1, "Restarting syslogd ... \n");
-    if (kill(pid, SIGHUP) == -1) {
-        fprintf(stderr, "Unable to send SIGHUP\n");
-        exit(ERR_SYSLOG);
-    }
-
+    
     return 0;
 }


This was sent by the SourceForge.net collaborative development platform, the world's \
largest Open Source development site.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Ipcop-svn mailing list
Ipcop-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ipcop-svn


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic