blob: 2d68f330c37e73b868438696f15d346d3662cf66 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
Subject: busybox 1.9.1 fixes
From: http://busybox.net/downloads/fixes-1.9.1
---
init/init.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
Index: busybox-1.9.1/init/init.c
===================================================================
--- busybox-1.9.1.orig/init/init.c
+++ busybox-1.9.1/init/init.c
@@ -225,8 +225,22 @@ static void console_init(void)
}
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");
|