diff options
author | Roger Leigh <rleigh@debian.org> | 2006-08-19 20:23:22 +0000 |
---|---|---|
committer | Roger Leigh <rleigh@debian.org> | 2006-08-19 20:23:22 +0000 |
commit | cfb0da61c2443149dddd017da5605ace1d2bd5c4 (patch) | |
tree | 7d88689abd42f10df3af40f6345709b54b1ad91f | |
parent | e5e53478a126fda7f071cbcb65bed459fb271954 (diff) | |
download | schroot-cfb0da61c2443149dddd017da5605ace1d2bd5c4.tar.gz |
* HACKING: Document additional directory fallback checks.
* schroot/schroot.1.in, dchroot/dchroot.1.in,
dchroot-dsa/dchroot-dsa.1.in: Document directory option.
* schroot/schroot-main-base.cc
(run_impl): If a directory option was specified, set the auth wd
member.
* schroot/schroot-options.cc, dchroot/dchroot-options.cc,
dchroot-dsa/dchroot-dsa-options.cc:
(add_options): Add directory option.
* schroot/schroot-options-base.h: Add directory member, used to
specify the directory inside the chroot.
-rw-r--r-- | ChangeLog | 18 | ||||
-rw-r--r-- | HACKING | 26 | ||||
-rw-r--r-- | dchroot-dsa/dchroot-dsa-options.cc | 4 | ||||
-rw-r--r-- | dchroot-dsa/dchroot-dsa.1.in | 15 | ||||
-rw-r--r-- | dchroot/dchroot-options.cc | 2 | ||||
-rw-r--r-- | dchroot/dchroot.1.in | 22 | ||||
-rw-r--r-- | schroot/schroot-main-base.cc | 2 | ||||
-rw-r--r-- | schroot/schroot-options-base.h | 2 | ||||
-rw-r--r-- | schroot/schroot-options.cc | 2 |
9 files changed, 82 insertions, 11 deletions
@@ -1,5 +1,23 @@ 2006-08-19 Roger Leigh <rleigh@debian.org> + * HACKING: Document additional directory fallback checks. + + * schroot/schroot.1.in, dchroot/dchroot.1.in, + dchroot-dsa/dchroot-dsa.1.in: Document directory option. + + * schroot/schroot-main-base.cc + (run_impl): If a directory option was specified, set the auth wd + member. + + * schroot/schroot-options.cc, dchroot/dchroot-options.cc, + dchroot-dsa/dchroot-dsa-options.cc: + (add_options): Add directory option. + + * schroot/schroot-options-base.h: Add directory member, used to + specify the directory inside the chroot. + +2006-08-19 Roger Leigh <rleigh@debian.org> + * dchroot/dchroot-session.cc, dchroot-dsa/dchroot-dsa-session.cc (get_login_directories): Use working directory in place of the normal directory fallback list if set. @@ -84,16 +84,34 @@ Chdir fallback behaviour: No fallbacks should exist under any circumstances. - dchroot - CWD → passwd_pw dir Normal behaviour (not if -d used) + schroot [--directory used] + CWD → DIR Normal behaviour + *FAIL* If CWD nonexistent + + No fallbacks should exist under any circumstances. + + dchroot [login shell or command] + CWD → passwd pw_dir Normal behaviour (not if -d used) CWD → CWD If -d used CWD → / If CWD nonexistent and -d used *FAIL* If / nonexistent - dchroot-dsa - CWD → passwd_pw dir Normal behaviour + dchroot [--directory used] + CWD → DIR Normal behaviour + *FAIL* If CWD nonexistent + + No fallbacks should exist under any circumstances. + + dchroot-dsa [login shell or command] + CWD → passwd pw_dir Normal behaviour CWD → / If no passwd_pw dir *FAIL* If / nonexistent + dchroot-dsa [--directory used] + CWD → DIR Normal behaviour + *FAIL* If CWD nonexistent + + No fallbacks should exist under any circumstances. + Note that --debug=notice will show the internal fallback list computed for the session. diff --git a/dchroot-dsa/dchroot-dsa-options.cc b/dchroot-dsa/dchroot-dsa-options.cc index 958bff72..3c7ed750 100644 --- a/dchroot-dsa/dchroot-dsa-options.cc +++ b/dchroot-dsa/dchroot-dsa-options.cc @@ -56,6 +56,10 @@ options::add_options () chroot.add_options() ("all,a", _("Select all chroots")); + + chrootenv.add_options() + ("directory,d", opt::value<std::string>(&this->directory), + _("Directory to use")); } void diff --git a/dchroot-dsa/dchroot-dsa.1.in b/dchroot-dsa/dchroot-dsa.1.in index 11ddbcea..d19a9ed2 100644 --- a/dchroot-dsa/dchroot-dsa.1.in +++ b/dchroot-dsa/dchroot-dsa.1.in @@ -22,6 +22,7 @@ dchroot\-dsa \[em] enter a chroot environment .RB [ \-h \[or] \-\-help " \[or] " \-V \[or] \-\-version .RB " \[or] " \-l \[or] \-\-list " \[or] " \-i \[or] \-\-info .RB " \[or] " \-\-config " \[or] " -p | \-\-listpaths ] +.RB [ "\-d \fIdirectory\fP" \[or] "\-\-directory=\fIdirectory\fP" ] .RB [ \-q \[or] \-\-quiet " \[or] " \-v \[or] \-\-verbose ] .RB [ "\-c \fIchroot\fP" \[or] "\-\-chroot=\fIchroot\fP" .RB " \[or] " \-\-all " \[or] " CHROOT] @@ -36,8 +37,8 @@ The user's environment will be preserved inside the chroot. The command is a single argument which must be an absolute path to the program. Additional options are not permitted. .PP -The login shell or command will run in the user's home directory inside the -chroot, or \fI/\fP if the home directory is not available. +The directory the command or login shell is run in depends upon the context. +See \fI\-\-directory\fP option below for a complete description. .PP This version of dchroot\-dsa is a compatibility wrapper around the .BR schroot (1) @@ -81,6 +82,16 @@ the configuration in use is the same as the configuration file. Any comments in the original file will be missing. Note that earlier versions of dchroot\-dsa did not include this option. .TP +.BR \-d ", " \-\-directory=\fIdirectory\fP +Change to \fIdirectory\fP inside the chroot before running the command or login +shell. If \fIdirectory\fP is not available, dchroot\-dsa will exit with an +error status. +.IP +The default behaviour (all directory paths are inside the chroot) is to run the +login shell or command in the user's home directory, or \fI/\fP if the home +directory is not available. If none of the directories are available, +dchroot\-dsa will exit with an error status. +.TP .BR \-q ", " \-\-quiet Print only essential messages. Note that earlier versions of dchroot\-dsa did not include this option. diff --git a/dchroot/dchroot-options.cc b/dchroot/dchroot-options.cc index 3ddc2f01..a1f4eb33 100644 --- a/dchroot/dchroot-options.cc +++ b/dchroot/dchroot-options.cc @@ -56,6 +56,8 @@ options::add_options () _("Select all chroots")); chrootenv.add_options() + ("directory", opt::value<std::string>(&this->directory), + _("Directory to use")) ("preserve-environment,d", _("Preserve user environment")); } diff --git a/dchroot/dchroot.1.in b/dchroot/dchroot.1.in index 6de50388..1651f39b 100644 --- a/dchroot/dchroot.1.in +++ b/dchroot/dchroot.1.in @@ -22,6 +22,7 @@ dchroot \[em] enter a chroot environment .RB [ \-h \[or] \-\-help " \[or] " \-V \[or] \-\-version .RB " \[or] " \-l \[or] \-\-list " \[or] " \-i \[or] \-\-info .RB " \[or] " \-\-config " \[or] " \-\-location ] +.RB [ "\-\-directory=\fIdirectory\fP" ] .RB [ \-d \[or] \-\-preserve\-environment ] .RB [ \-q \[or] \-\-quiet " \[or] " \-v \[or] \-\-verbose ] .RB [ "\-c \fIchroot\fP" \[or] "\-\-chroot=\fIchroot\fP" @@ -39,11 +40,8 @@ together, separated by spaces. Users should be aware of the shell quoting issues this presents, and should use \fBschroot\fP if necessary, which does not have any quoting issues. .PP -Unless the \fI-d\fP option is used to preserve the environment, the login shell -or command will run in the user's home directory inside the chroot, or \fI/\fP -if the home directory is not available. When the \fI-d\fP option is used, it -will attempt to use the current working directory inside the chroot, again -falling back to \fI/\fP if it is not accessible. +The directory the command or login shell is run in depends upon the context. +See \fI\-\-directory\fP option below for a complete description. .PP This version of dchroot is a compatibility wrapper around the .BR schroot (1) @@ -86,6 +84,20 @@ the configuration in use is the same as the configuration file. Any comments in the original file will be missing. Note that earlier versions of dchroot did not include this option. .TP +.BR \-d ", " \-\-directory=\fIdirectory\fP +Change to \fIdirectory\fP inside the chroot before running the command or login +shell. If \fIdirectory\fP is not available, dchroot will exit with an error +status. +.IP +The default behaviour is as follows (all directory paths are inside the +chroot). Unless the \fI\-\-preserve\-environment\fP option is used to preserve +the environment, the login shell or command will run in the user's home +directory, or \fI/\fP if the home directory is not available. When the +\fI\-\-preserve\-environment\fP option is used, it will attempt to use the +current working directory, again falling back to \fI/\fP if it is not +accessible. If none of the directories are available, dchroot will exit with +an error status. +.TP .BR \-d ", " \-\-preserve\-environment Preserve the user's environment inside the chroot environment. The default is to use a clean environment; this option copies the entire user environment and diff --git a/schroot/schroot-main-base.cc b/schroot/schroot-main-base.cc index 679ae857..d7814f38 100644 --- a/schroot/schroot-main-base.cc +++ b/schroot/schroot-main-base.cc @@ -247,6 +247,8 @@ main_base::run_impl () if (!this->options->command.empty()) this->session->set_command(this->options->command); + if (!this->options->directory.empty()) + this->session->set_wd(this->options->directory); if (this->options->preserve) this->session->set_environment(environ); this->session->set_force(this->options->session_force); diff --git a/schroot/schroot-options-base.h b/schroot/schroot-options-base.h index 992ddc7e..37b2d032 100644 --- a/schroot/schroot-options-base.h +++ b/schroot/schroot-options-base.h @@ -83,6 +83,8 @@ namespace schroot std::string chroot_path; /// Command to run. sbuild::string_list command; + /// Directory to use. + std::string directory; /// User to run as. std::string user; /// Preserve environment. diff --git a/schroot/schroot-options.cc b/schroot/schroot-options.cc index 6d21553d..647de738 100644 --- a/schroot/schroot-options.cc +++ b/schroot/schroot-options.cc @@ -60,6 +60,8 @@ options::add_options () _("Select all active sessions")); chrootenv.add_options() + ("directory,d", opt::value<std::string>(&this->directory), + _("Directory to use")) ("user,u", opt::value<std::string>(&this->user), _("Username (default current user)")) ("preserve-environment,p", |