#include <sbuild-session.h>
Inheritance diagram for sbuild::session:
Public Types | |
typedef runtime_error_custom< session > | error |
Exception type. | |
typedef std::tr1::shared_ptr< chroot_config > | config_ptr |
A shared_ptr to a chroot_config object. | |
typedef std::tr1::shared_ptr< session > | ptr |
A shared_ptr to a session object. | |
enum | operation { OPERATION_AUTOMATIC, OPERATION_BEGIN, OPERATION_RECOVER, OPERATION_END, OPERATION_RUN } |
Session operations. More... | |
Public Member Functions | |
session (std::string const &service, config_ptr &config, operation operation, string_list const &chroots) | |
The constructor. | |
virtual | ~session () |
The destructor. | |
config_ptr & | get_config () |
Get the configuration associated with this session. | |
void | set_config (config_ptr &config) |
Set the configuration associated with this session. | |
string_list const & | get_chroots () const |
Get the chroots to use in this session. | |
void | set_chroots (string_list const &chroots) |
Set the chroots to use in this session. | |
operation | get_operation () const |
Get the operation this session will perform. | |
void | set_operation (operation operation) |
Set the operation this session will perform. | |
std::string const & | get_session_id () const |
Get the session identifier. | |
void | set_session_id (std::string const &session_id) |
Set the session identifier. | |
bool | get_force () const |
Get the force status of this session. | |
void | set_force (bool force) |
Set the force status of this session. | |
int | get_child_status () const |
Get the exit (wait) status of the last child process to run in this session. | |
virtual sbuild::auth::status | get_auth_status () const |
Check if authentication is required, taking groups and root-groups membership or all chroots specified into account. | |
virtual void | run_impl () |
Run a session. | |
Private Member Functions | |
int | exec (std::string const &file, string_list const &command, environment const &env) |
execve wrapper. | |
void | setup_chroot (chroot::ptr &session_chroot, chroot::setup_type setup_type) |
Setup a chroot. | |
void | run_chroot (chroot::ptr &session_chroot) |
Run command or login shell in the specified chroot. | |
void | run_child (chroot::ptr &session_chroot) |
Run a command or login shell as a child process in the specified chroot. | |
void | wait_for_child (int pid, int &child_status) |
Wait for a child process to complete, and check its exit status. | |
void | set_sighup_handler () |
Set the SIGHUP handler. | |
void | clear_sighup_handler () |
Restore the state of SIGHUP prior to setting the handler. | |
Private Attributes | |
config_ptr | config |
The chroot configuration. | |
string_list | chroots |
The chroots to run the session operation in. | |
int | chroot_status |
The current chroot status. | |
int | child_status |
The child exit status. | |
operation | session_operation |
The session operation to perform. | |
std::string | session_id |
The session identifier. | |
bool | force |
The session force status. | |
sigaction | saved_signals |
Signals saved while sighup handler is set. |
This class provides the session handling for schroot. It derives from auth, which performs all the necessary PAM actions, specialising it by overriding its virtual functions. This allows more sophisticated handling of user authorisation (groups and root-groups membership in the configuration file) and session management (setting up the session, entering the chroot and running the requested command or shell).
|
A shared_ptr to a chroot_config object.
|
|
Exception type.
Reimplemented from sbuild::auth. |
|
A shared_ptr to a session object.
|
|
Session operations.
|
|
The constructor.
|
|
The destructor.
Reimplemented in dchroot::session. |
|
Restore the state of SIGHUP prior to setting the handler.
|
|
execve wrapper. Run the command specified by file (an absolute pathname), using command and env as the argv and environment, respectively.
|
|
Check if authentication is required, taking groups and root-groups membership or all chroots specified into account.
Reimplemented from sbuild::auth. Reimplemented in dchroot::session. |
|
Get the exit (wait) status of the last child process to run in this session.
|
|
Get the chroots to use in this session.
|
|
Get the configuration associated with this session.
|
|
Get the force status of this session.
|
|
Get the operation this session will perform.
|
|
Get the session identifier. The session identifier is a unique string to identify a session.
|
|
Run a command or login shell as a child process in the specified chroot. This method is only ever to be run in a child process, and will never return.
|
|
Run command or login shell in the specified chroot. An error will be thrown on failure.
|
|
Run a session. If a command has been specified, this will be run in each of the specified chroots. If no command has been specified, a login shell will run in the specified chroot. An error will be thrown on failure. Implements sbuild::auth. Reimplemented in dchroot::session. |
|
Set the chroots to use in this session.
|
|
Set the configuration associated with this session.
|
|
Set the force status of this session.
|
|
Set the operation this session will perform.
|
|
Set the session identifier. The session identifier is a unique string to identify a session.
|
|
Set the SIGHUP handler. An error will be thrown on failure. |
|
Setup a chroot. This runs all of the commands in setup.d or run.d. The environment variables CHROOT_NAME, CHROOT_DESCRIPTION, CHROOT_LOCATION, AUTH_USER and AUTH_VERBOSITY are set for use in setup scripts. See schroot-setup(5) for a complete list. An error will be thrown on failure.
|
|
Wait for a child process to complete, and check its exit status. An error will be thrown on failure.
|
|
The child exit status.
|
|
The current chroot status.
|
|
The chroots to run the session operation in.
|
|
The chroot configuration.
|
|
The session force status.
|
|
Signals saved while sighup handler is set.
|
|
The session identifier.
|
|
The session operation to perform.
|