diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-03-17 13:26:51 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-03-17 13:26:51 +0000 |
commit | fb274df0797f58cda0b3b6809769707fe21e40e7 (patch) | |
tree | a2137605d1e760bfcf025af1911c96a2f6db6e65 /init/init.c | |
parent | 9c8c03898166dd0ae32094325090d902b8828e8e (diff) | |
download | busybox-w32-fb274df0797f58cda0b3b6809769707fe21e40e7.tar.gz busybox-w32-fb274df0797f58cda0b3b6809769707fe21e40e7.tar.bz2 busybox-w32-fb274df0797f58cda0b3b6809769707fe21e40e7.zip |
init: do not use bb_sanitize_stdio(), "/dev/null" may be missing (yet)
Diffstat (limited to 'init/init.c')
-rw-r--r-- | init/init.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/init/init.c b/init/init.c index 6d4969c4b..eefb9df55 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -219,8 +219,22 @@ static void console_init(void) | |||
219 | } | 219 | } |
220 | messageD(L_LOG, "console='%s'", s); | 220 | messageD(L_LOG, "console='%s'", s); |
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 | bb_sanitize_stdio(); | 223 | * (so that they won't be used by future opens) */ |
224 | |||
225 | /* bb_sanitize_stdio(); - WRONG. | ||
226 | * Fail 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); | ||
224 | } | 238 | } |
225 | 239 | ||
226 | s = getenv("TERM"); | 240 | s = getenv("TERM"); |