.\" Copyright © 2005-2007 Roger Leigh .\" Copyright © 2006 Andreas Bombe .\" .\" schroot is free software; you can redistribute it and/or modify it .\" under the terms of the GNU General Public License as published by .\" the Free Software Foundation; either version 2 of the License, or .\" (at your option) any later version. .\" .\" schroot is distributed in the hope that it will be useful, but .\" WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU .\" General Public License for more details. .\" .\" You should have received a copy of the GNU General Public License .\" along with this program; if not, write to the Free Software .\" Foundation, Inc., 59 Temple Place, Suite 330, Boston, .\" MA 02111-1307 USA .TH SCHROOT 1 "08 Jul 2007" "Version 1.1.5" "Debian sbuild" .SH NAME schroot \[em] securely enter a chroot environment .SH SYNOPSIS .B schroot .RB [ \-h \[or] \-\-help " \[or] " \-V \[or] \-\-version .RB " \[or] " \-l \[or] \-\-list " \[or] " \-i \[or] \-\-info .RB " \[or] " \-\-config " \[or] " \-\-location .RB " \[or] " \-\-automatic\-session .RB " \[or] " \-b \[or] \-\-begin\-session " \[or] " \-\-recover\-session .RB " \[or] " \-r \[or] \-\-run\-session " \[or] " \-e \[or] \-\-end\-session ] .RB [ \-f \[or] "\-\-force" ] .RB [ "\-n \fIsession-name\fP" \[or] "\-\-session\-name=\fIsession-name\fP" ] .RB [ "\-d \fIdirectory\fP" \[or] "\-\-directory=\fIdirectory\fP" ] .RB [ "\-u \fIuser\fP" \[or] "\-\-user=\fIuser\fP" ] .RB [ \-p \[or] \-\-preserve\-environment ] .RB [ \-q \[or] \-\-quiet " \[or] " \-v \[or] \-\-verbose ] .RB [ "\-c \fIchroot\fP" \[or] "\-\-chroot=\fIchroot\fP" .RB " \[or] " \-\-all " \[or] " \-\-all\-chroots " \[or] " \-\-all\-sessions ] .RB [ COMMAND " [ " ARG1 " [ " ARG2 " [ " ARGn ]]]] .SH DESCRIPTION \fBschroot\fP allows the user to run a command or a login shell in a chroot environment. If no command is specified, a login shell will be started in the user's current working directory inside the chroot. .PP The command is a program, plus as many optional arguments as required. Each argument may be separately quoted. .PP 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 If the user is not an allowed user, or a member of the allowed groups (or if changing to root, the allowed root users or allowed root groups) for the specified chroot(s), the user will be required to authenticate themselves (typically with a password, but this depends upon the PAM configuration). All chroot usage will be logged in the system logs. .PP If no chroot is specified, the chroot name or alias \[oq]default\[cq] will be used as a fallback. This is equivalent to \[lq]\-\-chroot=default\[rq]. .SH OPTIONS \fBschroot\fP accepts the following options: .SS Actions .TP .BR \-h ", " \-\-help Show help summary. .TP .BR \-V ", " \-\-version Print version information. .TP .BR \-l ", " \-\-list List all available chroots. .TP .BR \-i ", " \-\-info Print detailed information about the specified chroots. .TP .BR \-\-config Print configuration of the specified chroots. This is useful for testing that the configuration in use is the same as the configuration file. Any comments in the original file will be missing. .TP .BR \-\-location Print location (path) of the specified chroots. Note that chroot types which can only be used within a session will not have a location until they are active. .SS General options .TP .BR \-q ", " \-\-quiet Print only essential messages. .TP .BR \-v ", " \-\-verbose Print all messages. .SS Chroot selection .TP .BR \-c ", " \-\-chroot=\fIchroot\fP Specify a chroot or active session to use. This option may be used multiple times to specify more than one chroot, in which case its effect is similar to \fI\-\-all\fP. .TP .BR \-a ", " \-\-all Select all chroots and active sessions. When a command has been specified, the command will be run in all chroots and active sessions. If \fI\-\-info\fP has been used, display information about all chroots. This option does not make sense to use with a login shell (when no command has been specified). This option is equivalent to \[lq]\-\-all\-chroots \-\-all\-sessions\[rq]. .TP .BR \-\-all\-chroots Select all chroots. Identical to \fI\-\-all\fP, except that active sessions are not considered. .TP .BR \-\-all\-sessions Select all active sessions. Identical to \fI\-\-all\fP, except that chroots are not considered. .SS Chroot environment .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, schroot will exit with an error status. .IP The default behaviour is as follows (all directory paths are inside the chroot). A login shell is run in the current working directory. If this is not available, it will try $HOME (when \fI\\-\-preserve\-environment\fP is used), then the user's home directory, and \fI/\fP inside the chroot in turn. A command is always run in the current working directory inside the chroot. If none of the directories are available, schroot will exit with an error status. .TP .BR \-u ", " \-\-user=\fIuser\fP Run as a different user. The default is to run as the current user. If required, the user may be required to authenticate themselves with a password. .TP .BR \-p ", " \-\-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 sets it in the session. The environment variables allowed are subject to certain restrictions; see the section \[lq]\fIEnvironment\fP\[rq], below. .SS Session actions .TP .BR \-\-automatic\-session Begin, run and end a session automatically. This is the default action, so does not require specifying in normal operation. .TP .BR \-b ", " \-\-begin\-session Begin a session. A unique session identifier (session ID) is returned on standard output. The session ID is required to use the other session options. Note that the session identifier may be specified with the \fI\-\-session\-name\fP option. .TP .BR \-\-recover\-session Recover an existing session. If an existing session has become unavailable, for example becoming unmounted due to a reboot, this option will make the session available for use again, for example by remounting it. .TP .BR \-r ", " \-\-run\-session Run an existing session. The session ID is specified with the \fI\-\-chroot\fP option. .TP .BR \-e ", " \-\-end\-session End an existing session. The session ID is specified with the \fI\-\-chroot\fP option. .SS Session options .TP .BR \-n ", " \-\-session\-name=\fIsession-name\fP Name a session. The specified \fIsession-name\fP replaces the default session name containing an automatically-generated session ID. .TP .BR \-f ", " \-\-force Force a session operation, even if it would otherwise fail. This may be used to forcibly end a session, even if it has active users. This does not guarantee that the session will be ended cleanly; filesystems may not be unmounted, for example. .SH EXAMPLES .SS List available chroots \f[CR]$ \f[CB]schroot \-l\fP\fP .br \f[CR]default\fP .br \f[CR]etch\fP .br \f[CR]sid\fP .br \f[CR]testing\fP .br \f[CR]unstable\fP .SS Get information about a chroot \f[CR]$\ \f[CB]schroot\ \-i\ \-c\ sid\fP\fP .br \f[CR]\ \ \[em]\[em]\[em]\ Chroot\ \[em]\[em]\[em]\fP .br \f[CR]\ \ Name\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ sid\fP .br \f[CR]\ \ Description\ \ \ \ \ \ \ \ \ \ \ \ Debian sid (unstable)\fP .br \f[CR]\ \ Type\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ plain\fP .br \f[CR]\ \ Priority\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 3\fP .br \f[CR]\ \ Users\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ rleigh\fP .br \f[CR]\ \ Groups\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ sbuild\fP .br \f[CR]\ \ Root\ Users\fP .br \f[CR]\ \ Root\ Groups\ \ \ \ \ \ \ \ \ \ \ \ sbuild\fP .br \f[CR]\ \ Aliases\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ unstable\ unstable\-sbuild\ unstable\-p\fP .br \f[CR]owerpc\-sbuild\fP .br \f[CR]\ \ Environment\ Filter\ \ \ \ \ \^(BASH_ENV|CDPATH|ENV|HOSTALIASES|IF\fP .br \f[CR]S|KRB5_CONFIG|KRBCONFDIR|KRBTKFILE|KRB_CONF|LD_.*|LOCALDOMAI\fP .br \f[CR]N|NLSPATH|PATH_LOCALE|RES_OPTIONS|TERMINFO|TERMINFO_DIRS|TER\fP .br \f[CR]MPATH)$\fP .br \f[CR]\ \ Run\ Setup\ Scripts\ \ \ \ \ \ true\fP .br \f[CR]\ \ Run\ Execution\ Scripts\ \ false\fP .br \f[CR]\ \ Script\ Configuration\ \ \ script\-defaults\fP .br \f[CR]\ \ Session\ Managed\ \ \ \ \ \ \ \ true\fP .br \f[CR]\ \ Personality\ \ \ \ \ \ \ \ \ \ \ \ linux32\fP .br \f[CR]\ \ Location\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ /srv/chroot/sid\fP .LP Use \fI\-\-all\fP or \fI\-c\fP multiple times to use all or multiple chroots, respectively. .SS Running commands in a chroot \f[CR]$ \f[CB]schroot \-c sid /bin/ls\fP\fP .br \f[CR][sid chroot] Running command: \[lq]/bin/ls\[rq]\fP .br \f[CR]CVS sbuild\-chroot.c sbuild\-session.h schroot.conf.5\fP .br \f[CR]Makefile sbuild\-chroot.h schroot.1 schroot.conf.5.in\fP .br \f[CR]Makefile.am sbuild\-config.c schroot.1.in\fP .br \f[CR]Makefile.in sbuild\-config.h schroot.c\fP .br \f[CR]pam sbuild\-session.c schroot.conf\fP .PP \f[CR]$ \f[CB]schroot \-c sid \-\- ls \-1 | head \-n 5\fP\fP .br \f[CR][sid chroot] Running command: \[lq]ls \-1\[rq]\fP .br \f[CR]ABOUT\-NLS\fP .br \f[CR]AUTHORS\fP .br \f[CR]COPYING\fP .br \f[CR]ChangeLog\fP .br \f[CR]INSTALL\fP .LP Use \fI\-\-\fP to allow options beginning with \[oq]\-\[cq] or \[oq]\-\-\[cq] in the command to run in the chroot. This prevents them being interpreted as options for schroot itself. Note that the top line was echoed to standard error, and the remaining lines to standard output. This is intentional, so that program output from commands run in the chroot may be piped and redirected as required; the data will be the same as if the command was run directly on the host system. .SS Switching users \f[CR]$ \f[CB]schroot \-c sid \-u root\fP\fP .br \f[CR]Password:\fP .br \f[CR][sid chroot] (rleigh\[->]root) Running login shell: \[lq]/bin/bash\[rq]\fP .br \f[CR]# \fP .LP If the user \[oq]rleigh\[cq] was in \f[CI]root\-users\fP in \fI/usr/local/etc/schroot/schroot.conf\fP, or one of the groups he belonged to was in \f[CI]root\-groups\fP, they would be granted root access without authentication, but the PAM authorisation step is still applied. .SS Sessions A chroot may be needed to run more than one command. In particular, where the chroot is created on the fly from an LVM LV or a file on disc, there is a need to make the chroot persistent while a given task (or set of tasks) is performed. Sessions exist for this purpose. For simple chroot types such as \[oq]plain\[cq] and \[oq]directory\[cq], sessions may be created but are not strictly necessary. .PP Let's start by looking at a session-capable chroot: .PP \f[CR]%\ \f[CB]schroot\ \-i\ \-c\ sid\-snap\fP\fP .br \f[CR]\ \ \[em]\[em]\[em]\ Chroot\ \[em]\[em]\[em]\fP .br \f[CR]\ \ Name\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ sid\-snap\fP .br \f[CR]\ \ Description\ \ \ \ \ \ \ \ \ \ \ \ Debian sid snapshot\fP .br \f[CR]\ \ Type\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ lvm\-snapshot\fP .br \f[CR]\ \ Priority\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 3\fP .br \f[CR]\ \ Users\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ maks rleigh\fP .br \f[CR]\ \ Groups\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ sbuild\fP .br \f[CR]\ \ Root\ Users\fP .br \f[CR]\ \ Root\ Groups\ \ \ \ \ \ \ \ \ \ \ \ root sbuild\fP .br \f[CR]\ \ Aliases\fP .br \f[CR]\ \ Environment\ Filter\ \ \ \ \ \^(BASH_ENV|CDPATH|ENV|HOSTALIASES|IF\fP .br \f[CR]S|KRB5_CONFIG|KRBCONFDIR|KRBTKFILE|KRB_CONF|LD_.*|LOCALDOMAI\fP .br \f[CR]N|NLSPATH|PATH_LOCALE|RES_OPTIONS|TERMINFO|TERMINFO_DIRS|TER\fP .br \f[CR]MPATH)$\fP .br \f[CR]\ \ Run\ Setup\ Scripts\ \ \ \ \ \ true\fP .br \f[CR]\ \ Run\ Execution\ Scripts\ \ true\fP .br \f[CR]\ \ Script\ Configuration\ \ \ script\-defaults\fP .br \f[CR]\ \ Session\ Managed\ \ \ \ \ \ \ \ true\fP .br \f[CR]\ \ Personality\ \ \ \ \ \ \ \ \ \ \ \ linux\fP .br \f[CR]\ \ Device\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ /dev/hda_vg/sid_chroot\fP .br \f[CR]\ \ Mount\ Options\ \ \ \ \ \ \ \ \ \ \-o atime,async,user_xattr\fP .br \f[CR]\ \ Source\ Users\fP .br \f[CR]\ \ Source\ Groups\ \ \ \ \ \ \ \ \ \ root rleigh\fP .br \f[CR]\ \ Source\ Root\ Users\fP .br \f[CR]\ \ Source\ Root\ Groups\ \ \ \ \ root rleigh\fP .br \f[CR]\ \ LVM\ Snapshot\ Options\ \ \ \-\-size 2G \-c 128\fP .PP Note that the \fISession Managed\fP option is set to \[oq]true\[cq]. This is a requirement in order to use session management, and is supported by most chroot types. Next, we will create a new session: .PP \f[CR]% \f[CB]schroot \-b \-c sid\-snap\fP\fP .br \f[CR]sid\-snap\-46195b04\-0893\-49bf\-beb8\-0d4ccc899f0f\fP .PP The session ID of the newly-created session is returned on standard output. It is common to store it like this: .PP \f[CR]% \f[CB]SESSION=$(schroot \-b \-c sid\-snap)\fP\fP .br \f[CR]% \f[CB]echo $SESSION\fP\fP .br \f[CR]sid\-snap\-46195b04\-0893\-49bf\-beb8\-0d4ccc899f0f\fP .PP The session may be used just like any normal chroot. This is what the session looks like: .PP \f[CR]%\ \f[CB]schroot\ \-i\ \-c\ sid\-snap\-46195b04\-0893\-49bf\-beb8\-0d4ccc899f0f\fP\fP .br \f[CR]\ \ \[em]\[em]\[em]\ Session\ \[em]\[em]\[em]\fP .br \f[CR]\ \ Name\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ sid\-snap\-46195b04\-0893\-49bf\-beb8\-0d\fP .br \f[CR]4ccc899f0f\fP .br \f[CR]\ \ Description\ \ \ \ \ \ \ \ \ \ \ \ Debian sid snapshot\fP .br \f[CR]\ \ Type\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ lvm\-snapshot\fP .br \f[CR]\ \ Priority\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ 3\fP .br \f[CR]\ \ Users\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ maks rleigh\fP .br \f[CR]\ \ Groups\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ sbuild\fP .br \f[CR]\ \ Root\ Users\fP .br \f[CR]\ \ Root\ Groups\ \ \ \ \ \ \ \ \ \ \ \ root sbuild\fP .br \f[CR]\ \ Aliases\fP .br \f[CR]\ \ Environment\ Filter\ \ \ \ \ \^(BASH_ENV|CDPATH|ENV|HOSTALIASES|IF\fP .br \f[CR]S|KRB5_CONFIG|KRBCONFDIR|KRBTKFILE|KRB_CONF|LD_.*|LOCALDOMAI\fP .br \f[CR]N|NLSPATH|PATH_LOCALE|RES_OPTIONS|TERMINFO|TERMINFO_DIRS|TER\fP .br \f[CR]MPATH)$\fP .br \f[CR]\ \ Run\ Setup\ Scripts\ \ \ \ \ \ true\fP .br \f[CR]\ \ Run\ Execution\ Scripts\ \ true\fP .br \f[CR]\ \ Script\ Configuration\ \ \ script\-defaults\fP .br \f[CR]\ \ Session\ Managed\ \ \ \ \ \ \ \ true\fP .br \f[CR]\ \ Personality\ \ \ \ \ \ \ \ \ \ \ \ linux\fP .br \f[CR]\ \ Mount\ Location\ \ \ \ \ \ \ \ \ /var/lib/schroot/mount/sid\-snap\-461\fP .br \f[CR]95b04\-0893\-49bf\-beb8\-0d4ccc899f0f\fP .br \f[CR]\ \ Path\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ /var/lib/schroot/mount/sid\-snap\-461\fP .br \f[CR]95b04\-0893\-49bf\-beb8\-0d4ccc899f0f\fP .br \f[CR]\ \ Mount\ Device\ \ \ \ \ \ \ \ \ \ \ /dev/hda_vg/sid\-snap\-46195b04\-0893\-\fP .br \f[CR]49bf\-beb8\-0d4ccc899f0f\fP .br \f[CR]\ \ Device\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ /dev/hda_vg/sid_chroot\fP .br \f[CR]\ \ Mount\ Options\ \ \ \ \ \ \ \ \ \ \-o\ atime,async,user_xattr\fP .br \f[CR]\ \ Source\ Users\fP .br \f[CR]\ \ Source\ Groups\ \ \ \ \ \ \ \ \ \ root\ rleigh\fP .br \f[CR]\ \ Source\ Root\ Users\fP .br \f[CR]\ \ Source\ Root\ Groups\ \ \ \ \ root\ rleigh\fP .br \f[CR]\ \ LVM\ Snapshot\ Device\ \ \ \ /dev/hda_vg/sid\-snap\-46195b04\-0893\-\fP .br \f[CR]49bf\-beb8\-0d4ccc899f0f\fP .br \f[CR]\ \ LVM\ Snapshot\ Options\ \ \ \-\-size\ 2G\ \-c\ 128\fP .PP Now the session has been created, commands may be run in it: .PP \f[CR]% \f[CB]schroot \-r \-c sid\-snap\-46195b04\-0893\-49bf\-beb8\-0d4ccc899f0f \-\- uname \-sr\fP\fP .br \f[CR]I: [sid\-snap\-46195b04\-0893\-49bf\-beb8\-0d4ccc899f0f chroot] Running command: \[lq]uname \-sr\[rq]\fP .br \f[CR]Linux 2.6.18\-3\-powerpc\fP .br \f[CR]% \f[CB]schroot \-r \-c $SESSION \-\- uname \-sr\fP\fP .br \f[CR]I: [sid\-snap\-fe170af9\-d9be\-4800\-b1bd\-de275858b938 chroot] Running command: \[lq]uname \-sr\[rq]\fP .br \f[CR]Linux 2.6.18\-3\-powerpc\fP .PP When all the commands to run in the session have been performed, the session may be ended: .PP \f[CR]% \f[CB]schroot \-e \-c sid\-snap\-46195b04\-0893\-49bf\-beb8\-0d4ccc899f0f\fP\fP .br \f[CR]% \f[CB]schroot \-e \-c $SESSION\fP\fP .PP Finally, the session names can be long and unwieldy. A name may be specified instead of using the automatically generated session ID: .PP \f[CR]% \f[CB]schroot \-b \-c sid\-snap \-n my\-session\-name\fP\fP .br \f[CR]my\-session\-name\fP .SH TROUBLESHOOTING If something is not working, and it's not clear from the error messages what is wrong, try using the \fB\-\-debug=\fP\fIlevel\fP option to turn on debugging messages. This gives a great deal more information. Valid debug levels are \[oq]none\[cq], and \[oq]notice\[cq], \[oq]info\[cq], \[oq]warning\[cq] and \[oq]critical\[cq] in order of increasing severity. The lower the severity level, the more output. .PP If you are still having trouble, the developers may be contacted on the mailing list: .br \f[CR]Debian\ buildd-tools\ Developers .br \fP .SH BUGS On the \fBmips\fP and \fBmipsel\fP architectures, Linux kernels up to and including at least version 2.6.17 have broken .BR personality (2) support, which results in a failure to set the personality. This will be seen as an \[lq]Operation not permitted\[rq] (EPERM) error. To work around this problem, set \f[CI]personality\fP to \[oq]undefined\[cq], or upgrade to a more recent kernel. .SH ENVIRONMENT By default, the environment is not preserved, and the following environment variables are defined: HOME, LOGNAME, PATH, SHELL, TERM (preserved if already defined), and USER. The environment variables SCHROOT_COMMAND, SCHROOT_USER, SCHROOT_GROUP, SCHROOT_UID and SCHROOT_GID are set inside the chroot specifying the command being run, the user name, group name, user ID and group ID, respectively. .PP The following, potentially dangerous, environment variables are removed for safety by default: BASH_ENV, CDPATH, ENV, HOSTALIASES, IFS, KRB5_CONFIG, KRBCONFDIR, KRBTKFILE, KRB_CONF, LD_.*, LOCALDOMAIN, NLSPATH, PATH_LOCALE, RES_OPTIONS, TERMINFO, TERMINFO_DIRS, and TERMPATH. If desired, the \f[CI]environment\-filter\fP configuration key will allow the exclusion list to the modified; see .BR schroot.conf (5) for further details. .SH FILES .TP \f[BI]/usr/local/etc/schroot/schroot.conf\fP The system-wide chroot definition file. This file must be owned by the root user, and not be writable by other. .TP \f[BI]/usr/local/etc/schroot/setup.d\fP .TP \f[BI]/usr/local/etc/schroot/exec.d\fP The system-wide chroot setup and execution directories. See .BR schroot-setup (5). .TP \f[BI]/etc/pam.d/schroot\fP PAM configuration. .SH AUTHORS Roger Leigh. .SH COPYRIGHT Copyright \(co 2005\-2007 Roger Leigh \f[CR]\fP .PP 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 the Free Software Foundation; either version 2 of the License, or (at your option) any later version. .SH SEE ALSO .BR dchroot (1), .BR sbuild (1), .BR chroot (2), .BR schroot-setup (5), .BR schroot.conf (5). .\"# .\"# The following sets edit modes for GNU EMACS .\"# Local Variables: .\"# mode:nroff .\"# fill-column:79 .\"# End: