diff options
author | Jim Meyering <jim@meyering.net> | 1999-01-31 17:50:53 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1999-01-31 17:50:53 +0000 |
commit | 2f07328f17a278e8997ac5f61b1426ac18403e8a (patch) | |
tree | 5a16c0b886017766148e44e91a52c076e833e3ca /src | |
parent | 09619556e678d3c490ec973086f809ffff14e0f3 (diff) | |
download | coreutils-2f07328f17a278e8997ac5f61b1426ac18403e8a.tar.xz |
(main): Call chdir ("/") after chroot.
Suggestion from James Youngman.
Diffstat (limited to 'src')
-rw-r--r-- | src/chroot.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/chroot.c b/src/chroot.c index 76cab5345..59514e929 100644 --- a/src/chroot.c +++ b/src/chroot.c @@ -1,5 +1,5 @@ /* chroot -- run command or shell with special root directory - Copyright (C) 95, 96, 1997 Free Software Foundation, Inc. + Copyright (C) 95, 96, 1997, 1999 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -72,6 +72,9 @@ main (int argc, char **argv) if (chroot (argv[1])) error (1, errno, _("cannot change root directory to %s"), argv[1]); + if (chdir ("/")) + error (1, errno, _("cannot chdir to root directory")); + if (argc == 2) { /* No command. Run an interactive shell. */ @@ -82,8 +85,10 @@ main (int argc, char **argv) argv[1] = "-i"; } else - /* The following arguments give the command. */ - argv += 2; + { + /* The following arguments give the command. */ + argv += 2; + } /* Execute the given command. */ execvp (argv[0], argv); |