tags 363475 + patch fixed-upstream pending thanks Martin Michlmayr <[EMAIL PROTECTED]> writes:
> I'd rather end up in $HOME than in / whene the current working dir > doesn't exist in the chroot: I committed the following patch to implement this behaviour. This only occurs when running a login shell (no command specified). If running a command and the CWD does not exist, it now aborts with an error, to be extra safe. Regards, Roger -- Roger Leigh Printing on GNU/Linux? http://gutenprint.sourceforge.net/ Debian GNU/Linux http://www.debian.org/ GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
Index: schroot/sbuild-session.cc =================================================================== --- schroot/sbuild-session.cc (revision 564) +++ schroot/sbuild-session.cc (working copy) @@ -698,12 +698,38 @@ exit (EXIT_FAILURE); } + std::string file; + + string_list command(get_command()); + /* chdir to current directory */ if (chdir (cwd.c_str())) { - log_warning() << format(_("Could not chdir to '%1%': %2%")) - % cwd % strerror(errno) - << endl; + /* Fall back to home directory, but only for a login shell, + since for a command we require deterministic behaviour. */ + if (command.empty() || + command[0].empty()) // No command + { + log_warning() << format(_("Could not chdir to '%1%': %2%")) + % cwd % strerror(errno) + << endl; + + if (chdir (get_home().c_str())) + log_warning() << format(_("Falling back to '%1%'")) + % "/" + << endl; + else + log_warning() << format(_("Falling back to home directory '%1%'")) + % get_home() + << endl; + } + else + { + log_error() << format(_("Could not chdir to '%1%': %2%")) + % cwd % strerror(errno) + << endl; + exit (EXIT_FAILURE); + } } /* Set up environment */ @@ -712,10 +738,6 @@ << "Set environment:\n" << env; /* Run login shell */ - std::string file; - - string_list command(get_command()); - if (command.empty() || command[0].empty()) // No command { Index: ChangeLog =================================================================== --- ChangeLog (revision 565) +++ ChangeLog (working copy) @@ -1,5 +1,14 @@ 2006-04-30 Roger Leigh <[EMAIL PROTECTED]> + * NEWS: Document directory behaviour. + + * schroot/sbuild-session.cc (run_child): If the current working + directory does not exist inside the chroot, change to the home + directory (for login shells), or fail with an error (for commands) + where the behaviour must be deterministic. + +2006-04-30 Roger Leigh <[EMAIL PROTECTED]> + * test/sbuild-parse-value.cc: Update tests. * schroot/sbuild-keyfile.h (get_value): Catch exceptions thrown by Index: NEWS =================================================================== --- NEWS (revision 564) +++ NEWS (working copy) @@ -12,6 +12,12 @@ 1) The package now compiles with older compilers, such as GCC 3.3 and 3.4. + 2) If the current working directory does not exist inside the + chroot, the user's home directory ($HOME, home directory in + passwd, or /) will be used when running a login shell. If + running a command and the directory does not exist, schroot will + exit with an error. + * Major changes in 0.2.8: Bugfixes only.
pgpr09rH10G3G.pgp
Description: PGP signature