← Commit list

0687a5b49

Denys Vlasenko
Denys Vlasenko
2012-03-08
FAILED Duration: 204s

Subject

libbb: make xchroot do a chdir("/") after chroot

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

coreutils/chroot.c+0 -1
@@ -31,7 +31,6 @@ int chroot_main(int argc UNUSED_PARAM, char **argv)
if (!*argv)
bb_show_usage();
xchroot(*argv);
- xchdir("/");
++argv;
if (!*argv) { /* no 2nd param (PROG), use shell */
libbb/xfuncs_printf.c+1 -0
@@ -362,6 +362,7 @@ void FAST_FUNC xchroot(const char *path)
{
if (chroot(path))
bb_perror_msg_and_die("can't change root directory to %s", path);
+ xchdir("/");
}
// Print a warning message if opendir() fails, but don't die.
networking/ftpd.c+1 -2
@@ -1179,8 +1179,7 @@ int ftpd_main(int argc UNUSED_PARAM, char **argv)
#endif
if (argv[optind]) {
- xchdir(argv[optind]);
- chroot(".");
+ xchroot(argv[optind]);
}
//umask(077); - admin can set umask before starting us
procps/sysctl.c+2 -2
@@ -224,7 +224,7 @@ static int sysctl_handle_preload_file(const char *filename)
parser = config_open(filename);
/* Must do it _after_ config_open(): */
xchdir("/proc/sys");
- /* xchroot(".") - if you are paranoid */
+ /* xchroot("/proc/sys") - if you are paranoid */
//TODO: ';' is comment char too
//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)
return sysctl_handle_preload_file(*argv ? *argv : "/etc/sysctl.conf");
}
xchdir("/proc/sys");
- /* xchroot(".") - if you are paranoid */
+ /* xchroot("/proc/sys") - if you are paranoid */
if (opt & (FLAG_TABLE_FORMAT | FLAG_SHOW_ALL)) {
return sysctl_act_recursive(".");
}
runit/chpst.c+1 -2
@@ -417,8 +417,7 @@ int chpst_main(int argc UNUSED_PARAM, char **argv)
}
if (opt & OPT_root) {
- xchdir(root);
- xchroot(".");
+ xchroot(root);
}
if (opt & OPT_u) {
util-linux/switch_root.c+1 -1
@@ -114,7 +114,7 @@ int switch_root_main(int argc UNUSED_PARAM, char **argv)
}
xchroot(".");
// The chdir is needed to recalculate "." and ".." links
- xchdir("/");
+ /*xchdir("/"); - done in xchroot */
// If a new console specified, redirect stdin/stdout/stderr to it
if (console) {