SCHROOT(1)

NAME
schroot — securely enter a chroot environment

SYNOPSIS
schroot [-h|--help | -V|--version | -l|--list | -i|--info | --config | --location | -b|--begin-session | --recover-session | -r|--run-session | -e|--end-session] [-d directory|--directory=directory] [-u user|--user=user] [-p|--preserve-environment] [-q|--quiet | -v|--verbose] [-c chroot|--chroot=chroot | --all | --all-chroots | --all-sessions] [COMMAND [ ARG1 [ ARG2 [ ARGn]]]]

DESCRIPTION
schroot 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.

The command is a program, plus as many optional arguments as required. Each argument may be separately quoted.

The directory the command or login shell is run in depends upon the context. See --directory option below for a complete description.

If the user is not a and allowed user, or amember 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.

If no chroot is specified, the chroot name or alias ‘default’ will be used as a fallback. This is equivalent to “--chroot=default”.

OPTIONS
schroot accepts the following options:

  Basic options

-h, --help
    Show help summary.

-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 --info 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 “--all-chroots --all-sessions”.

--all-chroots
    Select all chroots. Identical to --all, except that active sessions are not considered.

--all-sessions
    Select all active sessions. Identical to --all, except that chroots are not considered.

-c, --chroot=chroot
    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 --all.

-u, --user=user
    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.

-l, --list
    List all available chroots.

-i, --info
    Print detailed information about the specified chroots.

--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.

--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.

-d, --directory=directory
    Change to directory inside the chroot before running the command or login shell. If directory is not available, schroot will exit with an error status.

    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 \--preserve-environment is used), then the user's home directory, and / 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.

-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 “Environment”, below.

-q, --quiet
    Print only essential messages.

-v, --verbose
    Print all messages.

-V, --version
    Print version information.

  Session options

-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.

--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.

-r, --run-session
    Run an existing session. The session ID is specified with the --chroot option.

-e, --end-session
    End an existing session. The session ID is specified with the --chroot option.

-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.

EXAMPLES
$ schroot -l
default
etch
sid
testing
unstable

$ schroot -i -c sid
Name: sid
Description: Debian unstable
Location: /srv/chroot/sid
Priority: 3
Groups: sbuild
Root Groups: root
Aliases: unstable default

Use --all or -c multiple times to use all or multiple chroots, respectively.

$ schroot -c sid /bin/ls
[sid chroot] Running command: “/bin/ls”
CVS sbuild-chroot.c sbuild-session.h schroot.conf.5
Makefile sbuild-chroot.h schroot.1 schroot.conf.5.in
Makefile.am sbuild-config.c schroot.1.in
Makefile.in sbuild-config.h schroot.c
pam sbuild-session.c schroot.conf

$ schroot -c sid -- ls -1 | head -n 5
[sid chroot] Running command: “ls -1”
ABOUT-NLS
AUTHORS
COPYING
ChangeLog
INSTALL

Use -- to allow options beginning with ‘-’ or ‘--’ 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.

$ schroot -c sid -u root
Password:
[sid chroot] (rleigh→root) Running login shell: “/bin/bash”
#

If the user ‘rleigh’ was in root-users in @SCHROOT_CONF@, or one of the groups he belonged to was in root-groups, they would be granted root access without authentication, but the PAM authorisation step is still applied.

TROUBLESHOOTING
If something is not working, and it's not clear from the error messages what is wrong, try using the --debug=level option to turn on debugging messages. This gives a great deal more information. Valid debug levels are ‘none’, and ‘notice’, ‘info’, ‘warning’ and ‘critical’ in order of increasing severity. The lower the severity level, the more output.

If you are still having trouble, the developers may be contacted on the mailing list:
Debian buildd-tools Developers
<buildd-tools-devel@lists.alioth.debian.org>

BUGS
On the mips and mipsel architectures, Linux kernels up to and including at least version 2.6.17 have broken personality(2) support, which results in a failure to set the personality. This will be seen as an “Operation not permitted” (EPERM) error. To work around this problem, set personality to ‘undefined’, or upgrade to a more recent kernel.

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 following, potentially dangerous, environment variables are always removed for safety: BASH_ENV, CDPATH, ENV, HOSTALIASES, IFS, KRB5_CONFIG, KRBCONFDIR, KRBTKFILE, KRB_CONF, LD_.*, LOCALDOMAIN, NLSPATH, PATH_LOCALE, RES_OPTIONS, TERMINFO, TERMINFO_DIRS, and TERMPATH.

FILES

@SCHROOT_CONF@
    The system-wide chroot definition file. This file must be owned by the root user, and not be writable by other.

@SCHROOT_CONF_SETUP_D@

@SCHROOT_CONF_EXEC_D@
    The system-wide chroot setup and execution directories. See schroot-setup(5).

/etc/pam.d/schroot
    PAM configuration.

AUTHORS
Roger Leigh.

COPYRIGHT
Copyright © 2005-2006 Roger Leigh <rleigh@debian.org>

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.

SEE ALSO
dchroot(1), sbuild(1), chroot(2), schroot-setup(5), schroot.conf(5).