Write the core file of a non-suid process into the current directory
authorbluhm <bluhm@openbsd.org>
Sun, 10 Aug 2014 23:44:20 +0000 (23:44 +0000)
committerbluhm <bluhm@openbsd.org>
Sun, 10 Aug 2014 23:44:20 +0000 (23:44 +0000)
even if sysctl kern.nosuidcoredump has been set to 2 or 3.  This
allows a regular user to debug his programs again.
OK guenther@ deraadt@

sys/kern/kern_sig.c

index 88a8865..3be6083 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: kern_sig.c,v 1.173 2014/07/13 16:41:21 claudio Exp $  */
+/*     $OpenBSD: kern_sig.c,v 1.174 2014/08/10 23:44:20 bluhm Exp $    */
 /*     $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $   */
 
 /*
@@ -1481,14 +1481,14 @@ coredump(struct proc *p)
            p->p_rlimit[RLIMIT_CORE].rlim_cur)
                return (EFBIG);
 
-       if (nosuidcoredump == 3) {
+       if (incrash && nosuidcoredump == 3) {
                /*
                 * If the program directory does not exist, dumps of
                 * that core will silently fail.
                 */
                len = snprintf(name, sizeof(name), "%s/%s/%u.core",
                    dir, p->p_comm, p->p_pid);
-       } else if (nosuidcoredump == 2)
+       } else if (incrash && nosuidcoredump == 2)
                len = snprintf(name, sizeof(name), "%s/%s.core",
                    dir, p->p_comm);
        else