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 /libbb/vfork_daemon_rexec.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 'libbb/vfork_daemon_rexec.c')
-rw-r--r-- | libbb/vfork_daemon_rexec.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libbb/vfork_daemon_rexec.c b/libbb/vfork_daemon_rexec.c index 37d4c274e..da0dc03e5 100644 --- a/libbb/vfork_daemon_rexec.c +++ b/libbb/vfork_daemon_rexec.c | |||
@@ -265,7 +265,14 @@ void FAST_FUNC bb_daemonize_or_rexec(int flags, char **argv) | |||
265 | close(2); | 265 | close(2); |
266 | } | 266 | } |
267 | 267 | ||
268 | fd = xopen(bb_dev_null, O_RDWR); | 268 | fd = open(bb_dev_null, O_RDWR); |
269 | if (fd < 0) { | ||
270 | /* NB: we can be called as bb_sanitize_stdio() from init | ||
271 | * or mdev, and there /dev/null may legitimately not (yet) exist! | ||
272 | * Do not use xopen above, but obtain _ANY_ open descriptor, | ||
273 | * even bogus one as below. */ | ||
274 | fd = xopen("/", O_RDONLY); /* don't believe this can fail */ | ||
275 | } | ||
269 | 276 | ||
270 | while ((unsigned)fd < 2) | 277 | while ((unsigned)fd < 2) |
271 | fd = dup(fd); /* have 0,1,2 open at least to /dev/null */ | 278 | fd = dup(fd); /* have 0,1,2 open at least to /dev/null */ |