mirror of
https://git.busybox.net/busybox.git
synced 2024-12-24 22:13:25 +08:00
init: do not use bb_sanitize_stdio(), "/dev/null" may be missing (yet)
This commit is contained in:
parent
9c8c038981
commit
fb274df079
18
init/init.c
18
init/init.c
@ -219,8 +219,22 @@ static void console_init(void)
|
|||||||
}
|
}
|
||||||
messageD(L_LOG, "console='%s'", s);
|
messageD(L_LOG, "console='%s'", s);
|
||||||
} else {
|
} else {
|
||||||
/* Make sure fd 0,1,2 are not closed */
|
/* Make sure fd 0,1,2 are not closed
|
||||||
bb_sanitize_stdio();
|
* (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");
|
s = getenv("TERM");
|
||||||
|
Loading…
Reference in New Issue
Block a user