diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-06 07:00:11 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-06 07:00:11 +0000 |
commit | d48e81f0cda73aca49cd852212a62e879cf35b86 (patch) | |
tree | bc7f639f139f1fe5d65dd20b5819d41a5acf2cea /init/init.c | |
parent | ff182a3d68462cb7ec38affa1afb04a06031862f (diff) | |
download | busybox-w32-d48e81f0cda73aca49cd852212a62e879cf35b86.tar.gz busybox-w32-d48e81f0cda73aca49cd852212a62e879cf35b86.tar.bz2 busybox-w32-d48e81f0cda73aca49cd852212a62e879cf35b86.zip |
mdev: do not follow symlinks in /sys (as was intended prior to rev 18811).
If this breaks things, please document why!
mdev,init: use shared code for fd sanitization
function old new delta
bb_daemonize_or_rexec 155 172 +17
mdev_main 500 505 +5
init_main 907 856 -51
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/1 up/down: 22/-51) Total: -29 bytes
Diffstat (limited to 'init/init.c')
-rw-r--r-- | init/init.c | 15 |
1 files changed, 1 insertions, 14 deletions
diff --git a/init/init.c b/init/init.c index 232896709..4b2bd9c77 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -221,20 +221,7 @@ static void console_init(void) | |||
221 | } else { | 221 | } else { |
222 | /* Make sure fd 0,1,2 are not closed | 222 | /* Make sure fd 0,1,2 are not closed |
223 | * (so that they won't be used by future opens) */ | 223 | * (so that they won't be used by future opens) */ |
224 | 224 | bb_sanitize_stdio(); | |
225 | /* bb_sanitize_stdio(); - WRONG. | ||
226 | * It fails if "/dev/null" doesnt exist, and for init | ||
227 | * this is a real possibility! Open code it instead. */ | ||
228 | |||
229 | int fd = open(bb_dev_null, O_RDWR); | ||
230 | if (fd < 0) { | ||
231 | /* Give me _ANY_ open descriptor! */ | ||
232 | fd = xopen("/", O_RDONLY); /* we don't believe this can fail */ | ||
233 | } | ||
234 | while ((unsigned)fd < 2) | ||
235 | fd = dup(fd); | ||
236 | if (fd > 2) | ||
237 | close(fd); | ||
238 | } | 225 | } |
239 | 226 | ||
240 | s = getenv("TERM"); | 227 | s = getenv("TERM"); |