sbuild  1.7.1
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
sbuild::chroot::chroot Class Reference

Common chroot data. More...

#include <chroot.h>

+ Collaboration diagram for sbuild::chroot::chroot:

Public Types

enum  setup_type {
  SETUP_START, SETUP_RECOVER, SETUP_STOP, EXEC_START,
  EXEC_STOP
}
 Type of setup to perform. More...
 
enum  verbosity { VERBOSITY_QUIET, VERBOSITY_NORMAL, VERBOSITY_VERBOSE }
 Message verbosity. More...
 
enum  error_code {
  CHROOT_CREATE, CHROOT_DEVICE, CHROOT_TYPE, DEVICE_ABS,
  DEVICE_LOCK, DEVICE_NOTBLOCK, DEVICE_UNLOCK, DIRECTORY_ABS,
  FACET_ABSENT, FACET_INVALID, FACET_PRESENT, FILE_ABS,
  FILE_LOCK, FILE_NOTREG, FILE_OWNER, FILE_PERMS,
  FILE_UNLOCK, LOCATION_ABS, NAME_INVALID, SCRIPT_CONFIG_CV,
  SESSION_UNLINK, SESSION_WRITE, VERBOSITY_INVALID
}
 Error codes. More...
 
typedef custom_error< error_codeerror
 Exception type.
 
typedef std::shared_ptr< chrootptr
 A shared_ptr to a chroot object.
 
typedef std::shared_ptr< const
chroot
const_ptr
 A shared_ptr to a const chroot object.
 
typedef std::shared_ptr
< facet::facet
facet_ptr
 A shared pointer to a chroot facet.
 
typedef std::list< facet_ptrfacet_list
 A list of chroot facets.
 

Public Member Functions

 chroot ()
 The constructor.
 
 chroot (const chroot &rhs)
 The copy constructor. More...
 
virtual ~chroot ()
 The destructor.
 
chroot::ptr clone () const
 Copy the chroot. More...
 
chroot::ptr clone_session (const std::string &session_id, const std::string &alias, const std::string &user, bool root) const
 Create a session chroot. More...
 
chroot::ptr clone_source () const
 Create a source chroot. More...
 
std::string const & get_name () const
 Get the name of the chroot. More...
 
void set_name (const std::string &name)
 Set the name of the chroot. More...
 
std::string const & get_description () const
 Get the description of the chroot. More...
 
void set_description (const std::string &description)
 Set the description of the chroot. More...
 
std::string const & get_mount_location () const
 Get the mount location of the chroot. More...
 
void set_mount_location (const std::string &location)
 Set the mount location of the chroot. More...
 
std::string get_path () const
 Get the path to the chroot. More...
 
string_list const & get_users () const
 Get the users allowed to access the chroot. More...
 
void set_users (const string_list &users)
 Set the users allowed to access the chroot. More...
 
string_list const & get_groups () const
 Get the groups allowed to access the chroot. More...
 
void set_groups (const string_list &groups)
 Set the users allowed to access the chroot. More...
 
string_list const & get_root_users () const
 Get the users allowed to access the chroot as root. More...
 
void set_root_users (const string_list &users)
 Set the users allowed to access the chroot as root. More...
 
string_list const & get_root_groups () const
 Get the groups allowed to access the chroot as root. More...
 
void set_root_groups (const string_list &groups)
 Set the groups allowed to access the chroot as root. More...
 
string_list const & get_aliases () const
 Get the aliases of the chroot. More...
 
void set_aliases (const string_list &aliases)
 Set the aliases of the chroot. More...
 
bool get_preserve_environment () const
 Check if the environment should be preserved in the chroot. More...
 
void set_preserve_environment (bool preserve_environment)
 Set if the environment should be preserved in the chroot. More...
 
std::string const & get_default_shell () const
 Get default shell. More...
 
void set_default_shell (const std::string &default_shell)
 Set the default shell. More...
 
regex const & get_environment_filter () const
 Get the environment filter of the chroot. More...
 
void set_environment_filter (const regex &environment_filter)
 Set the environment filter of the chroot. More...
 
bool get_active () const
 Get the activity status of the chroot. More...
 
bool get_original () const
 Get the originality of the chroot. More...
 
void set_original (bool original)
 Set the originality of the chroot. More...
 
bool get_run_setup_scripts () const
 Check if chroot setup scripts will be run. More...
 
std::string const & get_script_config () const
 Get the script configuration file for the chroot. More...
 
void set_script_config (const std::string &script_config)
 Set the script configuration file for the chroot. More...
 
std::string const & get_profile () const
 Get the configuration profile for the chroot. More...
 
void set_profile (const std::string &profile)
 Set configuration profile for the chroot. More...
 
string_list const & get_command_prefix () const
 Get the command_prefix for the chroot. More...
 
void set_command_prefix (const string_list &command_prefix)
 Set the command_prefix for the chroot. More...
 
verbosity get_verbosity () const
 Get the message verbosity. More...
 
const char * get_verbosity_string () const
 Get the message verbosity as a readable string. More...
 
void set_verbosity (verbosity verbosity)
 Set the message verbosity. More...
 
void set_verbosity (const std::string &verbosity)
 Set the message verbosity. More...
 
std::string const & get_chroot_type () const
 Get the type of the chroot. More...
 
void setup_env (environment &env) const
 Set environment. More...
 
void lock (setup_type type)
 Lock a chroot during setup. More...
 
void unlock (setup_type type, int status)
 Unlock a chroot during setup. More...
 
template<typename T >
std::shared_ptr< T > get_facet ()
 Get a chroot facet. More...
 
template<typename T >
const std::shared_ptr< const T > get_facet () const
 Get a chroot facet. More...
 
template<typename T >
std::shared_ptr< T > get_facet_strict ()
 Get a chroot facet. More...
 
template<typename T >
const std::shared_ptr< const T > get_facet_strict () const
 Get a chroot facet. More...
 
facet_listget_facets ()
 Get the list of all chroot facets. More...
 
const facet_listget_facets () const
 Get the list of all chroot facets. More...
 
template<typename T >
void add_facet (std::shared_ptr< T > facet, bool copy=false)
 Add a chroot facet. More...
 
void add_facet_by_name (facet::facet::ptr facet, bool copy=false)
 Add a chroot facet by name (rather than type). More...
 
template<typename T >
void remove_facet ()
 Remove a chroot facet. More...
 
template<typename T >
void remove_facet (std::shared_ptr< T > facet)
 Remove a chroot facet. More...
 
template<typename T >
void replace_facet (std::shared_ptr< T > facet)
 Replace an existing chroot facet with a new facet. More...
 
string_list list_facets () const
 List all registered chroot facets. More...
 
facet::facet::session_flags get_session_flags () const
 Get the session flags of the chroot. More...
 
void get_details (format_detail &detail) const
 Get detailed information about the chroot for output. More...
 
void print_details (std::ostream &stream) const
 Print detailed information about the chroot to a stream. More...
 
void get_keyfile (keyfile &keyfile) const
 Copy the chroot properties into a keyfile. More...
 
void set_keyfile (const keyfile &keyfile)
 Set the chroot properties from a keyfile. More...
 
string_list get_used_keys () const
 Get a list of the keys used during keyfile parsing. More...
 

Static Public Member Functions

static chroot::ptr create (const std::string &type)
 Create a chroot. More...
 

Protected Member Functions

void setup_lock (setup_type type, bool lock, int status)
 Unlock a chroot during setup. More...
 

Private Attributes

std::string name
 Chroot name.
 
std::string description
 Chroot description.
 
string_list users
 Users allowed to access the chroot.
 
string_list groups
 Groups allowed to access the chroot.
 
string_list root_users
 Users allowed to access the chroot as root.
 
string_list root_groups
 Groups allowed to access the chroot as root.
 
string_list aliases
 Alternative names for the chroot.
 
bool preserve_environment
 Preserve environment?
 
std::string default_shell
 Default shell.
 
regex environment_filter
 Environment filter regex.
 
std::string mount_location
 Location to mount chroot in the filesystem (if any).
 
bool original
 Was the chroot automatically generated?
 
std::string script_config
 Configuration of the setup and exec scripts.
 
std::string profile
 Configuration profile for setup scripts (replaces script_config).
 
string_list command_prefix
 Command prefix.
 
verbosity message_verbosity
 The message verbosity.
 
facet_list facets
 Contained chroot facets.
 

Friends

std::ostream & operator<< (std::ostream &stream, const ptr &rhs)
 Print detailed information about the chroot to a stream. More...
 
keyfile const & operator>> (const keyfile &keyfile, ptr &rhs)
 Chroot initialisation from a keyfile. More...
 
keyfileoperator<< (keyfile &keyfile, const ptr &rhs)
 Chroot serialisation to a keyfile. More...
 

Detailed Description

Common chroot data.

This class contains all of the metadata associated with a single chroot, for all chroot types. This is the in-core representation of a chroot definition in the configuration file, and may be initialised directly from an open keyfile.

Member Enumeration Documentation

Error codes.

Enumerator
CHROOT_CREATE 

Chroot creation failed.

CHROOT_DEVICE 

Chroot device name not set.

CHROOT_TYPE 

Unknown chroot type.

DEVICE_ABS 

Device must have an absolute path.

DEVICE_LOCK 

Failed to lock device.

DEVICE_NOTBLOCK 

File is not a block device.

DEVICE_UNLOCK 

Failed to unlock device.

DIRECTORY_ABS 

Directory must have an absolute path.

FACET_ABSENT 

Attempt to use facet which is not present.

FACET_INVALID 

Attempt to add object which is not a facet.

FACET_PRESENT 

Attempt to add facet which is already in use.

FILE_ABS 

File must have an absolute path.

FILE_LOCK 

Failed to acquire lock.

FILE_NOTREG 

File is not a regular file.

FILE_OWNER 

File is not owned by user root.

FILE_PERMS 

File has write permissions for others.

FILE_UNLOCK 

Failed to discard lock.

LOCATION_ABS 

Location must have an absolute path.

NAME_INVALID 

Invalid name.

SCRIPT_CONFIG_CV 

Could not set profile from script configuration path.

SESSION_UNLINK 

Failed to unlink session file.

SESSION_WRITE 

Failed to write session file.

VERBOSITY_INVALID 

Message verbosity is invalid.

Type of setup to perform.

Enumerator
SETUP_START 

Activate a chroot.

SETUP_RECOVER 

Reactivate a chroot.

SETUP_STOP 

Deactivate a chroot.

EXEC_START 

Prepare for executing a command.

EXEC_STOP 

Clean up after executing a command.

Message verbosity.

Enumerator
VERBOSITY_QUIET 

Only print essential messages.

VERBOSITY_NORMAL 

Print messages (the default).

VERBOSITY_VERBOSE 

Print all messages.

Constructor & Destructor Documentation

sbuild::chroot::chroot::chroot ( const chroot rhs)

The copy constructor.

Todo:
Use internal version of add_facet to add chroot pointer.

References facets.

Member Function Documentation

template<typename T >
void sbuild::chroot::chroot::add_facet ( std::shared_ptr< T >  facet,
bool  copy = false 
)
void sbuild::chroot::chroot::add_facet_by_name ( facet::facet::ptr  facet,
bool  copy = false 
)
inline

Add a chroot facet by name (rather than type).

Any facet with the same name will be removed, prior to this facet being added.

Parameters
facetthe facet to add.
copytrue if the facet has been copied, or false if this is a new instance.

References facets.

Referenced by chroot().

+ Here is the caller graph for this function:

chroot::ptr sbuild::chroot::chroot::clone ( ) const

Copy the chroot.

This is a virtual copy constructor.

Returns
a shared_ptr to the new copy of the chroot.

References chroot().

Referenced by sbuild::chroot::facet::session_clonable::clone_session(), and sbuild::chroot::facet::source_clonable::clone_source().

+ Here is the caller graph for this function:

chroot::ptr sbuild::chroot::chroot::clone_session ( const std::string &  session_id,
const std::string &  alias,
const std::string &  user,
bool  root 
) const

Create a session chroot.

Parameters
session_idthe identifier (session_id) for the new session.
aliasthe alias used to initially identify the chroot.
userthe user creating the session.
roottrue if the user has root access, otherwise false.
Returns
a session chroot.
chroot::ptr sbuild::chroot::chroot::clone_source ( ) const

Create a source chroot.

Returns
a source chroot.
chroot::ptr sbuild::chroot::chroot::create ( const std::string &  type)
static

Create a chroot.

This is a factory function.

Parameters
typethe type of chroot to create.
Returns
a shared_ptr to the new chroot.

References chroot(), and CHROOT_TYPE.

bool sbuild::chroot::chroot::get_active ( ) const

Get the activity status of the chroot.

The chroot is active if it has been cloned as a session.

Returns
true if active, false if inactive
string_list const & sbuild::chroot::chroot::get_aliases ( ) const

Get the aliases of the chroot.

These are alternative names for the chroot.

Returns
a list of names.

References aliases.

Referenced by get_details(), and get_keyfile().

+ Here is the caller graph for this function:

std::string const & sbuild::chroot::chroot::get_chroot_type ( ) const

Get the type of the chroot.

Returns
the chroot type.
Todo:
Delegate to storage facet name.

References sbuild::chroot::facet::facet::get_name().

Referenced by get_details(), get_keyfile(), and setup_env().

+ Here is the caller graph for this function:

string_list const & sbuild::chroot::chroot::get_command_prefix ( ) const

Get the command_prefix for the chroot.

This is a command to prefix to any command run in the chroot.

Returns
the command prefix.

References command_prefix.

Referenced by get_details(), and get_keyfile().

+ Here is the caller graph for this function:

std::string const & sbuild::chroot::chroot::get_default_shell ( ) const

Get default shell.

Returns
default shell, or empty string if unset

References default_shell.

Referenced by get_details(), and get_keyfile().

+ Here is the caller graph for this function:

std::string const & sbuild::chroot::chroot::get_description ( ) const

Get the description of the chroot.

Returns
the description.

References description.

Referenced by get_details(), get_keyfile(), and setup_env().

+ Here is the caller graph for this function:

void sbuild::chroot::chroot::get_details ( format_detail detail) const
regex const & sbuild::chroot::chroot::get_environment_filter ( ) const

Get the environment filter of the chroot.

This is a POSIX extended regular expression used to remove insecure environment variables from the chroot environment.

Returns
the filter

References environment_filter.

Referenced by get_details(), and get_keyfile().

+ Here is the caller graph for this function:

template<typename T >
std::shared_ptr< T > sbuild::chroot::chroot::get_facet ( )

Get a chroot facet.

This is a templated method; use the correct type for the facet required.

Returns
a shared_ptr to the facet, or to NULL if the facet does not exist.

References facets.

Referenced by sbuild::chroot::facet::block_device::chroot_session_setup(), sbuild::chroot::facet::loopback::chroot_session_setup(), sbuild::chroot::facet::mountable::get_keyfile(), sbuild::chroot::facet::lvm_snapshot::get_keyfile(), sbuild::chroot::facet::file::get_keyfile(), sbuild::chroot::facet::btrfs_snapshot::get_keyfile(), sbuild::chroot::facet::block_device_base::get_path(), sbuild::chroot::facet::loopback::get_path(), sbuild::chroot::facet::lvm_snapshot::get_session_flags(), sbuild::chroot::facet::custom::get_session_flags(), sbuild::chroot::facet::file::get_session_flags(), sbuild::chroot::facet::btrfs_snapshot::get_session_flags(), sbuild::chroot::facet::source_clonable::get_session_flags(), sbuild::chroot::facet::fsunion::get_session_flags(), sbuild::chroot::facet::lvm_snapshot::set_chroot(), sbuild::chroot::facet::loopback::set_chroot(), sbuild::chroot::facet::file::set_chroot(), sbuild::chroot::facet::btrfs_snapshot::set_chroot(), sbuild::chroot::facet::directory::set_chroot(), sbuild::chroot::facet::block_device::set_chroot(), sbuild::chroot::facet::custom::set_chroot(), sbuild::chroot::facet::block_device_base::set_chroot(), sbuild::chroot::facet::mountable::set_keyfile(), sbuild::chroot::facet::lvm_snapshot::set_keyfile(), sbuild::chroot::facet::custom::set_keyfile(), sbuild::chroot::facet::file::set_keyfile(), sbuild::chroot::facet::btrfs_snapshot::set_keyfile(), sbuild::chroot::facet::fsunion::set_keyfile(), and sbuild::chroot::facet::lvm_snapshot::set_snapshot_device().

+ Here is the caller graph for this function:

template<typename T >
const std::shared_ptr< const T > sbuild::chroot::chroot::get_facet ( ) const

Get a chroot facet.

This is a templated method; use the correct type for the facet required.

Returns
a shared_ptr to the facet, or to NULL if the facet does not exist.

References facets.

template<typename T >
std::shared_ptr< T > sbuild::chroot::chroot::get_facet_strict ( )

Get a chroot facet.

This is a templated method; use the correct type for the facet required.

Returns
a shared_ptr to the facet, or throws an error if the facet does not exist.

References FACET_ABSENT.

template<typename T >
const std::shared_ptr< const T > sbuild::chroot::chroot::get_facet_strict ( ) const

Get a chroot facet.

This is a templated method; use the correct type for the facet required.

Returns
a shared_ptr to the facet, or throws an error if the facet does not exist.

References FACET_ABSENT.

chroot::facet_list & sbuild::chroot::chroot::get_facets ( )

Get the list of all chroot facets.

Returns
the facet list.

References facets.

const chroot::facet_list & sbuild::chroot::chroot::get_facets ( ) const

Get the list of all chroot facets.

Returns
the facet list.

References facets.

string_list const & sbuild::chroot::chroot::get_groups ( ) const

Get the groups allowed to access the chroot.

Returns
a list of groups.

References groups.

Referenced by get_details(), and get_keyfile().

+ Here is the caller graph for this function:

void sbuild::chroot::chroot::get_keyfile ( keyfile keyfile) const

Copy the chroot properties into a keyfile.

The keyfile group with the name of the chroot will be set; if it already exists, it will be removed before setting it.

Parameters
keyfilethe keyfile to use.

References facets, get_aliases(), get_chroot_type(), get_command_prefix(), get_default_shell(), get_description(), get_environment_filter(), get_groups(), get_mount_location(), get_name(), get_preserve_environment(), get_profile(), get_root_groups(), get_root_users(), get_script_config(), get_users(), get_verbosity_string(), sbuild::keyfile::remove_group(), sbuild::keyfile::set_object_list_value(), and sbuild::keyfile::set_object_value().

Referenced by sbuild::chroot::facet::userdata::set_data(), and sbuild::chroot::facet::session::setup_session_info().

+ Here is the caller graph for this function:

std::string const & sbuild::chroot::chroot::get_mount_location ( ) const
std::string const & sbuild::chroot::chroot::get_name ( ) const

Get the name of the chroot.

Returns
the name.

References name.

Referenced by sbuild::chroot::facet::lvm_snapshot::chroot_session_setup(), sbuild::chroot::facet::btrfs_snapshot::chroot_session_setup(), sbuild::chroot::facet::fsunion::chroot_session_setup(), sbuild::chroot::facet::session::get_details(), get_details(), sbuild::chroot::facet::personality::get_keyfile(), sbuild::chroot::facet::directory_base::get_keyfile(), sbuild::chroot::facet::userdata::get_keyfile(), sbuild::chroot::facet::block_device_base::get_keyfile(), sbuild::chroot::facet::loopback::get_keyfile(), sbuild::chroot::facet::session::get_keyfile(), sbuild::chroot::facet::mountable::get_keyfile(), sbuild::chroot::facet::lvm_snapshot::get_keyfile(), sbuild::chroot::facet::custom::get_keyfile(), sbuild::chroot::facet::unshare::get_keyfile(), sbuild::chroot::facet::file::get_keyfile(), sbuild::chroot::facet::btrfs_snapshot::get_keyfile(), sbuild::chroot::facet::source_clonable::get_keyfile(), sbuild::chroot::facet::fsunion::get_keyfile(), get_keyfile(), sbuild::chroot::facet::personality::set_keyfile(), sbuild::chroot::facet::directory_base::set_keyfile(), sbuild::chroot::facet::userdata::set_keyfile(), sbuild::chroot::facet::block_device_base::set_keyfile(), sbuild::chroot::facet::loopback::set_keyfile(), sbuild::chroot::facet::session::set_keyfile(), sbuild::chroot::facet::mountable::set_keyfile(), sbuild::chroot::facet::lvm_snapshot::set_keyfile(), sbuild::chroot::facet::custom::set_keyfile(), sbuild::chroot::facet::unshare::set_keyfile(), sbuild::chroot::facet::file::set_keyfile(), sbuild::chroot::facet::btrfs_snapshot::set_keyfile(), sbuild::chroot::facet::source_clonable::set_keyfile(), sbuild::chroot::facet::fsunion::set_keyfile(), set_keyfile(), setup_env(), and sbuild::chroot::facet::session::setup_session_info().

+ Here is the caller graph for this function:

bool sbuild::chroot::chroot::get_original ( ) const

Get the originality of the chroot.

Returns
true if original, false if generated.

References original.

std::string sbuild::chroot::chroot::get_path ( ) const

Get the path to the chroot.

This is the absolute path to the root of the chroot, and is typically the same as the mount location and location concatenated together, but is overridden by the chroot type if required.

Returns
the path.
Todo:
Remove once migrated to storage facet, or delegate.

Referenced by get_details(), and setup_env().

+ Here is the caller graph for this function:

bool sbuild::chroot::chroot::get_preserve_environment ( ) const

Check if the environment should be preserved in the chroot.

Returns
true to preserve or false to clean.

References preserve_environment.

Referenced by get_details(), and get_keyfile().

+ Here is the caller graph for this function:

std::string const & sbuild::chroot::chroot::get_profile ( ) const

Get the configuration profile for the chroot.

This is a directory, either relative to the configured pkgsysconfdir or an absolute path.

Returns
the configuration file name.

References profile.

Referenced by chroot(), get_details(), get_keyfile(), and setup_env().

+ Here is the caller graph for this function:

string_list const & sbuild::chroot::chroot::get_root_groups ( ) const

Get the groups allowed to access the chroot as root.

Members of these groups can switch to root without authenticating themselves.

Returns
a list of groups.

References root_groups.

Referenced by get_details(), and get_keyfile().

+ Here is the caller graph for this function:

string_list const & sbuild::chroot::chroot::get_root_users ( ) const

Get the users allowed to access the chroot as root.

Members of these users can switch to root without authenticating themselves.

Returns
a list of users.

References root_users.

Referenced by get_details(), and get_keyfile().

+ Here is the caller graph for this function:

bool sbuild::chroot::chroot::get_run_setup_scripts ( ) const

Check if chroot setup scripts will be run.

Returns
true if setup scripts will be run, otherwise false.

Referenced by get_details().

+ Here is the caller graph for this function:

std::string const & sbuild::chroot::chroot::get_script_config ( ) const

Get the script configuration file for the chroot.

This is a filename, either relative to the configured pkgsysconfdir or an absolute path.

Returns
the configuration file name.

References script_config.

Referenced by get_details(), get_keyfile(), and setup_env().

+ Here is the caller graph for this function:

facet::facet::session_flags sbuild::chroot::chroot::get_session_flags ( ) const

Get the session flags of the chroot.

These determine how the Session controlling the chroot will operate.

Returns
the session flags.

References facets, and sbuild::chroot::facet::facet::SESSION_NOFLAGS.

Referenced by get_details(), and setup_env().

+ Here is the caller graph for this function:

string_list sbuild::chroot::chroot::get_used_keys ( ) const

Get a list of the keys used during keyfile parsing.

Returns
a list of key names.

References facets.

Referenced by sbuild::chroot::facet::userdata::set_data(), and sbuild::chroot::facet::userdata::set_keyfile().

+ Here is the caller graph for this function:

string_list const & sbuild::chroot::chroot::get_users ( ) const

Get the users allowed to access the chroot.

Returns
a list of users.

References users.

Referenced by get_details(), and get_keyfile().

+ Here is the caller graph for this function:

chroot::verbosity sbuild::chroot::chroot::get_verbosity ( ) const

Get the message verbosity.

Returns
the verbosity level.

References message_verbosity.

const char * sbuild::chroot::chroot::get_verbosity_string ( ) const

Get the message verbosity as a readable string.

Returns
the verbosity level as a readable string.

References sbuild::DEBUG_CRITICAL, sbuild::log_debug(), message_verbosity, VERBOSITY_NORMAL, VERBOSITY_QUIET, and VERBOSITY_VERBOSE.

Referenced by get_details(), and get_keyfile().

+ Here is the caller graph for this function:

string_list sbuild::chroot::chroot::list_facets ( ) const

List all registered chroot facets.

Returns
a list of facets.

References facets.

void sbuild::chroot::chroot::lock ( setup_type  type)

Lock a chroot during setup.

The locking technique (if any) may vary depending upon the chroot type and setup stage. For example, during creation of an LVM snapshot a block device might require locking, but afterwards this will change to the new block device.

An error will be thrown on failure.

Parameters
typethe type of setup being performed

References setup_lock().

void sbuild::chroot::chroot::print_details ( std::ostream &  stream) const

Print detailed information about the chroot to a stream.

The information is printed in plain text with one line per property.

Parameters
streamthe stream to output to.

References sbuild::_(), and get_details().

template<typename T >
void sbuild::chroot::chroot::remove_facet ( )

Remove a chroot facet.

This is a templated method; use the correct type for the facet to remove.

References facets.

Referenced by sbuild::chroot::facet::fsunion::chroot_session_setup(), sbuild::chroot::facet::fsunion::chroot_source_setup(), sbuild::chroot::facet::custom::set_session_cloneable(), and sbuild::chroot::facet::custom::set_source_cloneable().

+ Here is the caller graph for this function:

template<typename T >
void sbuild::chroot::chroot::remove_facet ( std::shared_ptr< T >  facet)

Remove a chroot facet.

Parameters
facetthe facet to remove.
template<typename T >
void sbuild::chroot::chroot::replace_facet ( std::shared_ptr< T >  facet)

Replace an existing chroot facet with a new facet.

Parameters
facetthe replacement facet.

References add_facet().

Referenced by sbuild::chroot::facet::lvm_snapshot::chroot_source_setup(), and sbuild::chroot::facet::btrfs_snapshot::chroot_source_setup().

+ Here is the caller graph for this function:

void sbuild::chroot::chroot::set_aliases ( const string_list aliases)

Set the aliases of the chroot.

These are alternative names for the chroot.

Parameters
aliasesa list of names.

References sbuild::_(), aliases, sbuild::is_valid_sessionname(), NAME_INVALID, sbuild::chroot::config::namespace_separator, and sbuild::error_base::set_reason().

Referenced by set_keyfile().

+ Here is the caller graph for this function:

void sbuild::chroot::chroot::set_command_prefix ( const string_list command_prefix)

Set the command_prefix for the chroot.

This is a command to prefix to any command run in the chroot.

Parameters
command_prefixthe command prefix.

References command_prefix.

Referenced by set_keyfile().

+ Here is the caller graph for this function:

void sbuild::chroot::chroot::set_default_shell ( const std::string &  default_shell)

Set the default shell.

This is the default interactive shell.

Parameters
default_shellthe default shell.

References default_shell.

Referenced by set_keyfile().

+ Here is the caller graph for this function:

void sbuild::chroot::chroot::set_description ( const std::string &  description)

Set the description of the chroot.

Parameters
descriptionthe description.

References description.

Referenced by set_keyfile().

+ Here is the caller graph for this function:

void sbuild::chroot::chroot::set_environment_filter ( const regex environment_filter)

Set the environment filter of the chroot.

This is a POSIX extended regular expression used to remove insecure environment variables from the chroot environment.

Parameters
environment_filterthe filter.

References environment_filter.

Referenced by set_keyfile().

+ Here is the caller graph for this function:

void sbuild::chroot::chroot::set_groups ( const string_list groups)

Set the users allowed to access the chroot.

Parameters
groupsa list of groups.

References groups.

Referenced by set_keyfile().

+ Here is the caller graph for this function:

void sbuild::chroot::chroot::set_keyfile ( const keyfile keyfile)
void sbuild::chroot::chroot::set_mount_location ( const std::string &  location)

Set the mount location of the chroot.

Parameters
locationthe mount location.

References sbuild::is_absname(), LOCATION_ABS, and mount_location.

Referenced by set_keyfile().

+ Here is the caller graph for this function:

void sbuild::chroot::chroot::set_name ( const std::string &  name)

Set the name of the chroot.

Parameters
namethe name.

References sbuild::_(), sbuild::is_valid_sessionname(), name, NAME_INVALID, sbuild::chroot::config::namespace_separator, and sbuild::error_base::set_reason().

Referenced by set_keyfile().

+ Here is the caller graph for this function:

void sbuild::chroot::chroot::set_original ( bool  original)

Set the originality of the chroot.

Parameters
originaltrue if original, false if generated.

References original.

void sbuild::chroot::chroot::set_preserve_environment ( bool  preserve_environment)

Set if the environment should be preserved in the chroot.

Parameters
preserve_environmenttrue to preserve or false to clean.

References preserve_environment.

Referenced by set_keyfile().

+ Here is the caller graph for this function:

void sbuild::chroot::chroot::set_profile ( const std::string &  profile)

Set configuration profile for the chroot.

This is a directory, either relative to the configured pkgsysconfdir or an absolute path.

Parameters
profilethe script configuration file.

References profile.

Referenced by chroot(), and set_keyfile().

+ Here is the caller graph for this function:

void sbuild::chroot::chroot::set_root_groups ( const string_list groups)

Set the groups allowed to access the chroot as root.

Members of these groups can switch to root without authenticating themselves.

Parameters
groupsa list of groups.

References groups, and root_groups.

Referenced by set_keyfile().

+ Here is the caller graph for this function:

void sbuild::chroot::chroot::set_root_users ( const string_list users)

Set the users allowed to access the chroot as root.

Members of these users can switch to root without authenticating themselves.

Parameters
usersa list of users.

References root_users, and users.

Referenced by set_keyfile().

+ Here is the caller graph for this function:

void sbuild::chroot::chroot::set_script_config ( const std::string &  script_config)

Set the script configuration file for the chroot.

This is a filename, either relative to the configured pkgsysconfdir or an absolute path.

Parameters
script_configthe script configuration file.

References profile, and script_config.

Referenced by set_keyfile().

+ Here is the caller graph for this function:

void sbuild::chroot::chroot::set_users ( const string_list users)

Set the users allowed to access the chroot.

Parameters
usersa list of users.

References users.

Referenced by set_keyfile().

+ Here is the caller graph for this function:

void sbuild::chroot::chroot::set_verbosity ( chroot::verbosity  verbosity)

Set the message verbosity.

Parameters
verbositythe verbosity level.

References message_verbosity.

Referenced by set_keyfile().

+ Here is the caller graph for this function:

void sbuild::chroot::chroot::set_verbosity ( const std::string &  verbosity)

Set the message verbosity.

Parameters
verbositythe verbosity level.

References message_verbosity, VERBOSITY_INVALID, VERBOSITY_NORMAL, VERBOSITY_QUIET, and VERBOSITY_VERBOSE.

void sbuild::chroot::chroot::setup_env ( environment env) const
void sbuild::chroot::chroot::setup_lock ( setup_type  type,
bool  lock,
int  status 
)
protected

Unlock a chroot during setup.

The locking technique (if any) may vary depending upon the chroot type and setup stage. For example, during creation of an LVM snapshot a block device might require locking, but afterwards this will change to the new block device.

An error will be thrown on failure.

Parameters
typethe type of setup being performed
locktrue to lock, false to unlock
statusthe exit status of the setup commands (0 for success, nonzero for failure).
Todo:
Delegate to storate or other facet?

Referenced by lock(), and unlock().

+ Here is the caller graph for this function:

void sbuild::chroot::chroot::unlock ( setup_type  type,
int  status 
)

Unlock a chroot during setup.

The locking technique (if any) may vary depending upon the chroot type and setup stage. For example, during creation of an LVM snapshot a block device might require locking, but afterwards this will change to the new block device.

An error will be thrown on failure.

Parameters
typethe type of setup being performed
statusthe exit status of the setup commands (0 for success, nonzero for failure).

References setup_lock().

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  stream,
const ptr rhs 
)
friend

Print detailed information about the chroot to a stream.

The information is printed in plain text with one line per property.

Parameters
streamthe stream to output to.
rhsthe chroot to output.
Returns
the stream.
keyfile& operator<< ( keyfile keyfile,
const ptr rhs 
)
friend

Chroot serialisation to a keyfile.

Parameters
keyfilethe keyfile to use.
rhsthe chroot to output.
Returns
the keyfile.
keyfile const& operator>> ( const keyfile keyfile,
ptr rhs 
)
friend

Chroot initialisation from a keyfile.

Parameters
keyfilethe keyfile to get the properties from.
rhsthe chroot to output.
Returns
the keyfile.

The documentation for this class was generated from the following files: