aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2012-03-08 00:28:24 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2012-03-08 00:28:24 +0100
commit0687a5b496a05cbc06f3bcdc517a2e6cabc535df (patch)
tree55aedfacfddad2faafb75c4bee0d98122325df5c
parent39c2cb2e93e2acc75a5eb6dd91d81f79c787acd5 (diff)
downloadbusybox-w32-0687a5b496a05cbc06f3bcdc517a2e6cabc535df.tar.gz
busybox-w32-0687a5b496a05cbc06f3bcdc517a2e6cabc535df.tar.bz2
busybox-w32-0687a5b496a05cbc06f3bcdc517a2e6cabc535df.zip
libbb: make xchroot do a chdir("/") after chroot
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--coreutils/chroot.c1
-rw-r--r--libbb/xfuncs_printf.c1
-rw-r--r--networking/ftpd.c3
-rw-r--r--procps/sysctl.c4
-rw-r--r--runit/chpst.c3
-rw-r--r--util-linux/switch_root.c2
6 files changed, 6 insertions, 8 deletions
diff --git a/coreutils/chroot.c b/coreutils/chroot.c
index ab8beb023..633e66b38 100644
--- a/coreutils/chroot.c
+++ b/coreutils/chroot.c
@@ -31,7 +31,6 @@ int chroot_main(int argc UNUSED_PARAM, char **argv)
31 if (!*argv) 31 if (!*argv)
32 bb_show_usage(); 32 bb_show_usage();
33 xchroot(*argv); 33 xchroot(*argv);
34 xchdir("/");
35 34
36 ++argv; 35 ++argv;
37 if (!*argv) { /* no 2nd param (PROG), use shell */ 36 if (!*argv) { /* no 2nd param (PROG), use shell */
diff --git a/libbb/xfuncs_printf.c b/libbb/xfuncs_printf.c
index 56ee459e4..d8a42ba0b 100644
--- a/libbb/xfuncs_printf.c
+++ b/libbb/xfuncs_printf.c
@@ -362,6 +362,7 @@ void FAST_FUNC xchroot(const char *path)
362{ 362{
363 if (chroot(path)) 363 if (chroot(path))
364 bb_perror_msg_and_die("can't change root directory to %s", path); 364 bb_perror_msg_and_die("can't change root directory to %s", path);
365 xchdir("/");
365} 366}
366 367
367// Print a warning message if opendir() fails, but don't die. 368// Print a warning message if opendir() fails, but don't die.
diff --git a/networking/ftpd.c b/networking/ftpd.c
index e38138c0a..1c97df564 100644
--- a/networking/ftpd.c
+++ b/networking/ftpd.c
@@ -1179,8 +1179,7 @@ int ftpd_main(int argc UNUSED_PARAM, char **argv)
1179#endif 1179#endif
1180 1180
1181 if (argv[optind]) { 1181 if (argv[optind]) {
1182 xchdir(argv[optind]); 1182 xchroot(argv[optind]);
1183 chroot(".");
1184 } 1183 }
1185 1184
1186 //umask(077); - admin can set umask before starting us 1185 //umask(077); - admin can set umask before starting us
diff --git a/procps/sysctl.c b/procps/sysctl.c
index cb3b6a25a..5296d0f58 100644
--- a/procps/sysctl.c
+++ b/procps/sysctl.c
@@ -224,7 +224,7 @@ static int sysctl_handle_preload_file(const char *filename)
224 parser = config_open(filename); 224 parser = config_open(filename);
225 /* Must do it _after_ config_open(): */ 225 /* Must do it _after_ config_open(): */
226 xchdir("/proc/sys"); 226 xchdir("/proc/sys");
227 /* xchroot(".") - if you are paranoid */ 227 /* xchroot("/proc/sys") - if you are paranoid */
228 228
229//TODO: ';' is comment char too 229//TODO: ';' is comment char too
230//TODO: comment may be only at line start. "var=1 #abc" - "1 #abc" is the value 230//TODO: comment may be only at line start. "var=1 #abc" - "1 #abc" is the value
@@ -260,7 +260,7 @@ int sysctl_main(int argc UNUSED_PARAM, char **argv)
260 return sysctl_handle_preload_file(*argv ? *argv : "/etc/sysctl.conf"); 260 return sysctl_handle_preload_file(*argv ? *argv : "/etc/sysctl.conf");
261 } 261 }
262 xchdir("/proc/sys"); 262 xchdir("/proc/sys");
263 /* xchroot(".") - if you are paranoid */ 263 /* xchroot("/proc/sys") - if you are paranoid */
264 if (opt & (FLAG_TABLE_FORMAT | FLAG_SHOW_ALL)) { 264 if (opt & (FLAG_TABLE_FORMAT | FLAG_SHOW_ALL)) {
265 return sysctl_act_recursive("."); 265 return sysctl_act_recursive(".");
266 } 266 }
diff --git a/runit/chpst.c b/runit/chpst.c
index 9b8c99bdd..ac296babf 100644
--- a/runit/chpst.c
+++ b/runit/chpst.c
@@ -417,8 +417,7 @@ int chpst_main(int argc UNUSED_PARAM, char **argv)
417 } 417 }
418 418
419 if (opt & OPT_root) { 419 if (opt & OPT_root) {
420 xchdir(root); 420 xchroot(root);
421 xchroot(".");
422 } 421 }
423 422
424 if (opt & OPT_u) { 423 if (opt & OPT_u) {
diff --git a/util-linux/switch_root.c b/util-linux/switch_root.c
index db6ae3542..a301b365b 100644
--- a/util-linux/switch_root.c
+++ b/util-linux/switch_root.c
@@ -114,7 +114,7 @@ int switch_root_main(int argc UNUSED_PARAM, char **argv)
114 } 114 }
115 xchroot("."); 115 xchroot(".");
116 // The chdir is needed to recalculate "." and ".." links 116 // The chdir is needed to recalculate "." and ".." links
117 xchdir("/"); 117 /*xchdir("/"); - done in xchroot */
118 118
119 // If a new console specified, redirect stdin/stdout/stderr to it 119 // If a new console specified, redirect stdin/stdout/stderr to it
120 if (console) { 120 if (console) {