Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

kernel/2901: Signal logging (revised patch)

From: Frank Denis <j(at)pureftpd.org>
Date: Sat Aug 24 2002 - 04:39:33 EDT


>Number: 2901
>Category: kernel
>Synopsis: Signal logging (revised patch)
>Confidential: no

	System      : OpenBSD 3.1
	Architecture: OpenBSD.i386
	Machine     : i386

>Description:

Revised patch :

  • Remove killproc() : orphan function.
  • Log important signals at the right place.
  • Use log(), not printf().
  • Log core dumps, including failures.
  • sprintf() -> snprintf() in coredump().

>How-To-Repeat:

-

>Fix:

  • sys/kern/kern_sig.c.orig Sun Jul 14 04:44:08 2002 +++ sys/kern/kern_sig.c Sat Aug 24 10:29:53 2002 @@ -83,7 +83,6 @@ { 0, filt_sigattach, filt_sigdetach, filt_signal };

 void proc_stop(struct proc *p);
-void killproc(struct proc *, char *);
 int cansignal(struct proc *, struct pcred *, struct proc *, int);  

 struct pool sigacts_pool; /* memory pool for sigacts structures */ @@ -1228,20 +1227,6 @@
 }  

 /*
- * Kill the current process for stated reason.
- */
-void
-killproc(p, why)
-	struct proc *p;
-	char *why;
-{
-
-	log(LOG_ERR, "pid %d was killed: %s\n", p->p_pid, why);
-	uprintf("sorry, pid %d was killed: %s\n", p->p_pid, why);
-	psignal(p, SIGKILL);
-}

-
-/*
  * Force the current process to exit with the specified signal, dumping core
  * if appropriate.  We bypass the normal tests for masked and caught signals,
  * allowing unrecoverable failures to terminate the process without changing
@@ -1254,7 +1239,37 @@
 	register struct proc *p;
 	int signum;

 {
-
+    switch (signum) {
+    case 0:
+    case SIGKILL:
+    case SIGINT:
+    case SIGTERM:
+    case SIGALRM:
+    case SIGSTOP:
+    case SIGTTIN:
+    case SIGTTOU:
+    case SIGTSTP:
+    case SIGHUP:
+    case SIGUSR1:
+    case SIGUSR2:
+        break;
+    default:
+        if (p->p_pptr != NULL)
+            log(LOG_INFO, "signal %d received by (%.32s:%d) UID(%lu) "
+                "EUID(%lu), parent (%.32s:%d) UID(%lu) EUID(%lu)\n",
+                signum, p->p_comm, p->p_pid, 
+                (unsigned long) p->p_cred->p_ruid,
+                (unsigned long) p->p_ucred->cr_uid,
+                p->p_pptr->p_comm, p->p_pptr->p_pid,
+                (unsigned long) p->p_pptr->p_cred->p_ruid,
+                (unsigned long) p->p_pptr->p_ucred->cr_uid);
+        else
+            log(LOG_INFO, "signal %d received by (%.32s:%d) UID(%lu) "
+                "EUID(%lu), zombie\n", signum, p->p_comm, p->p_pid, 
+                (unsigned long) p->p_cred->p_ruid,
+                (unsigned long) p->p_ucred->cr_uid);                
+    }
+    
 	/* Mark process as going away */
 	p->p_flag |= P_WEXIT;
 
@@ -1309,7 +1324,7 @@
Do you need help?X
cred->cr_uid = p->p_cred->p_ruid; cred->cr_gid = p->p_cred->p_rgid; - sprintf(name, "%s.core", p->p_comm); + snprintf(name, sizeof name, "%s.core", p->p_comm); NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, p); error = vn_open(&nd, O_CREAT | FWRITE | O_NOFOLLOW, S_IRUSR | S_IWUSR); @@ -1394,6 +1409,13 @@ crfree(cred); if (error == 0) error = error1; + if (error == 0) + log(LOG_WARNING, "core dumped for pid %d (%s)\n", + p->p_pid, p->p_comm); + else + log(LOG_WARNING, "error %d while dumping core for pid %d (%s)\n", + error, p->p_pid, p->p_comm); + return (error);

 }

>Release-Note:
Received on Thu Nov 7 16:15:07 2002

Do you need more help?X

This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 13:29:36 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library