about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--misc/daemon.c8
2 files changed, 7 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index d717f84220..30772a98bd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2004-09-24  Ulrich Drepper  <drepper@redhat.com>
 
+	* misc/daemon.c (daemon): Don't succeed if /dev/null cannot be
+	opened.
+
 	* nis/ypclnt.c (do_ypcall): Add one missing unlock.  Simplify the
 	code a bit.
 
diff --git a/misc/daemon.c b/misc/daemon.c
index 775ef1aacf..7597ce9996 100644
--- a/misc/daemon.c
+++ b/misc/daemon.c
@@ -61,12 +61,12 @@ daemon(nochdir, noclose)
 	if (!nochdir)
 		(void)__chdir("/");
 
-	if (!noclose
-	    && (fd = open_not_cancel(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
+	if (!noclose) {
 		struct stat64 st;
 
-		if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0) == 0)
-		{
+		if ((fd = open_not_cancel(_PATH_DEVNULL, O_RDWR, 0)) != -1
+		    && (__builtin_expect (__fxstat64 (_STAT_VER, fd, &st), 0)
+			== 0)) {
 			if (__builtin_expect (S_ISCHR (st.st_mode), 1) != 0
 #if defined DEV_NULL_MAJOR && defined DEV_NULL_MINOR
 			    && (st.st_rdev