chiark / gitweb /
main: check if we have a valid PID before getting the name of it
authorLennart Poettering <lennart@poettering.net>
Wed, 16 Mar 2011 01:55:55 +0000 (02:55 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 16 Mar 2011 01:55:55 +0000 (02:55 +0100)
src/kmsg-syslogd.c
src/manager.c

index 4edb16136b58cb6ac1a53b37b2cc159138c86f04..c78011fe226d56cf06e1a067646358d27f4a55b4 100644 (file)
@@ -354,7 +354,9 @@ static int write_message(Server *s, const char *buf, struct ucred *ucred) {
         /* Then, add process if set */
         if (read_process(&buf, &iovec[i]) > 0)
                 i++;
         /* Then, add process if set */
         if (read_process(&buf, &iovec[i]) > 0)
                 i++;
-        else if (ucred && get_process_name(ucred->pid, &process) >= 0)
+        else if (ucred &&
+                 ucred->pid > 0 &&
+                 get_process_name(ucred->pid, &process) >= 0)
                 IOVEC_SET_STRING(iovec[i++], process);
 
         /* Skip the stored PID if we have a better one */
                 IOVEC_SET_STRING(iovec[i++], process);
 
         /* Skip the stored PID if we have a better one */
index df75eca8c48d6167bcc468b33d3662c7309d93d1..9edb8f09bbc990abc41e9904b71f6291e7ea0f75 100644 (file)
@@ -2070,7 +2070,9 @@ static int manager_process_signal_fd(Manager *m) {
                         return -errno;
                 }
 
                         return -errno;
                 }
 
-                get_process_name(sfsi.ssi_pid, &p);
+                if (sfsi.ssi_pid > 0)
+                        get_process_name(sfsi.ssi_pid, &p);
+
                 log_debug("Received SIG%s from PID %lu (%s)",
                           strna(signal_to_string(sfsi.ssi_signo)),
                           (unsigned long) sfsi.ssi_pid, strna(p));
                 log_debug("Received SIG%s from PID %lu (%s)",
                           strna(signal_to_string(sfsi.ssi_signo)),
                           (unsigned long) sfsi.ssi_pid, strna(p));