Module Name:    src
Committed By:   christos
Date:           Wed Aug 18 08:32:02 UTC 2010

Modified Files:
        src/lib/libutil: passwd.c

Log Message:
Log why pwd_mkdb failed. Currently on aslr systems, pwd_mkdb either aborts
or when s/vfork/fork/ dies with SEGV accessing the the stack. The same abort
effect can be achieved when we remove all resource limits.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/lib/libutil/passwd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libutil/passwd.c
diff -u src/lib/libutil/passwd.c:1.49 src/lib/libutil/passwd.c:1.50
--- src/lib/libutil/passwd.c:1.49	Wed Aug 18 04:09:17 2010
+++ src/lib/libutil/passwd.c	Wed Aug 18 04:32:02 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: passwd.c,v 1.49 2010/08/18 08:09:17 christos Exp $	*/
+/*	$NetBSD: passwd.c,v 1.50 2010/08/18 08:32:02 christos Exp $	*/
 
 /*
  * Copyright (c) 1987, 1993, 1994, 1995
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: passwd.c,v 1.49 2010/08/18 08:09:17 christos Exp $");
+__RCSID("$NetBSD: passwd.c,v 1.50 2010/08/18 08:32:02 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/types.h>
@@ -144,7 +144,7 @@
 
 	pid = vfork();
 	if (pid == -1)
-		return (-1);
+		return -1;
 
 	if (pid == 0) {
 		args[0] = "pwd_mkdb";
@@ -166,9 +166,21 @@
 		_exit(1);
 	}
 	pid = waitpid(pid, &pstat, 0);
-	if (pid == -1 || !WIFEXITED(pstat) || WEXITSTATUS(pstat) != 0)
-		return(-1);
-	return(0);
+	if (pid == -1) {
+		warn("error waiting for pid %lu", (unsigned long)pid);
+		return -1;
+	}
+	if (WIFEXITED(pstat)) {
+		if (WEXITSTATUS(pstat) != 0) {
+			warnx("pwd_mkdb exited with static %d",
+			    WEXITSTATUS(pstat));
+			return -1;
+		}
+	} else if (WIFSIGNALED(pstat)) {
+		warnx("pwd_mkdb exited with signal %d", WTERMSIG(pstat));
+		return -1;
+	}
+	return 0;
 }
 
 int

Reply via email to