From 2f07328f17a278e8997ac5f61b1426ac18403e8a Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 31 Jan 1999 17:50:53 +0000 Subject: (main): Call chdir ("/") after chroot. Suggestion from James Youngman. --- src/chroot.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') 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); -- cgit v1.2.3-54-g00ecf