svn commit: trunk/busybox/init

vda at busybox.net vda at busybox.net
Mon Mar 17 13:26:52 UTC 2008


Author: vda
Date: 2008-03-17 06:26:51 -0700 (Mon, 17 Mar 2008)
New Revision: 21367

Log:
init: do not use bb_sanitize_stdio(), "/dev/null" may be missing (yet)



Modified:
   trunk/busybox/init/init.c


Changeset:
Modified: trunk/busybox/init/init.c
===================================================================
--- trunk/busybox/init/init.c	2008-03-17 12:58:19 UTC (rev 21366)
+++ trunk/busybox/init/init.c	2008-03-17 13:26:51 UTC (rev 21367)
@@ -219,8 +219,22 @@
 		}
 		messageD(L_LOG, "console='%s'", s);
 	} else {
-		/* Make sure fd 0,1,2 are not closed */
-		bb_sanitize_stdio();
+		/* Make sure fd 0,1,2 are not closed
+		 * (so that they won't be used by future opens) */
+
+		/* bb_sanitize_stdio(); - WRONG.
+		 * Fail if "/dev/null" doesnt exist, and for init
+		 * this is a real possibility! Open code it instead. */
+
+		int fd = open(bb_dev_null, O_RDWR);
+		if (fd < 0) {
+			/* Give me _ANY_ open descriptor! */
+			fd = xopen("/", O_RDONLY); /* we don't believe this can fail */
+		}
+    		while ((unsigned)fd < 2)
+            		fd = dup(fd);
+		if (fd > 2)
+			close (fd);
 	}
 
 	s = getenv("TERM");




More information about the busybox-cvs mailing list