sbuild
1.6.10
|
Common chroot data. More...
#include <sbuild-chroot.h>
Public Types | |
enum | setup_type { SETUP_START, SETUP_RECOVER, SETUP_STOP } |
Type of setup to perform. More... | |
enum | session_flags { SESSION_NOFLAGS = 0, SESSION_CREATE = 1 << 0, SESSION_CLONE = 1 << 1, SESSION_PURGE = 1 << 2, SESSION_SOURCE = 1 << 3 } |
Chroot session properties. 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_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_code > | error |
Exception type. | |
typedef std::shared_ptr< chroot > | ptr |
A shared_ptr to a chroot object. | |
typedef std::shared_ptr< const chroot > | const_ptr |
A shared_ptr to a const chroot object. | |
Public Member Functions | |
virtual | ~chroot () |
The destructor. | |
virtual ptr | clone () const =0 |
Copy the chroot. More... | |
virtual chroot::ptr | clone_session (std::string const &session_id, std::string const &alias, std::string const &user, bool root) const =0 |
Create a session chroot. More... | |
virtual chroot::ptr | clone_source () const =0 |
Create a source chroot. More... | |
std::string const & | get_name () const |
Get the name of the chroot. More... | |
void | set_name (std::string const &name) |
Set the name of the chroot. More... | |
std::string const & | get_description () const |
Get the description of the chroot. More... | |
void | set_description (std::string const &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 (std::string const &location) |
Set the mount location of the chroot. More... | |
virtual std::string | get_path () const =0 |
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 (string_list const &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 (string_list const &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 (string_list const &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 (string_list const &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 (string_list const &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 (std::string const &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 (regex const &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 (std::string const &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 (std::string const &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 (string_list const &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 (std::string const &verbosity) |
Set the message verbosity. More... | |
virtual std::string const & | get_chroot_type () const =0 |
Get the type of the chroot. More... | |
void | setup_env (environment &env) const |
Set environment. More... | |
virtual void | setup_env (chroot const &chroot, environment &env) const =0 |
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 > | |
void | add_facet (std::shared_ptr< T > facet) |
Add a chroot facet. 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... | |
session_flags | get_session_flags () const |
Get the session flags of the chroot. More... | |
virtual chroot::session_flags | get_session_flags (chroot const &chroot) const =0 |
Get the session flags of the chroot. More... | |
void | get_details (format_detail &detail) const |
Get detailed information about the chroot for output. More... | |
virtual void | get_details (chroot const &chroot, format_detail &detail) const =0 |
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 (keyfile const &keyfile) |
Set the chroot properties from a keyfile. More... | |
Static Public Member Functions | |
static ptr | create (std::string const &type) |
Create a chroot. More... | |
Protected Member Functions | |
chroot () | |
The constructor. | |
chroot (const chroot &rhs) | |
The copy constructor. More... | |
void | set_run_setup_scripts (bool run_setup_scripts) |
Set whether chroot setup scripts will be run. More... | |
virtual void | setup_session_info (bool start) |
Set up persistent session information. More... | |
virtual void | setup_lock (setup_type type, bool lock, int status)=0 |
Unlock a chroot during setup. More... | |
virtual void | get_keyfile (chroot const &chroot, keyfile &keyfile) const =0 |
Copy the chroot properties into a keyfile. More... | |
virtual void | set_keyfile (chroot &chroot, keyfile const &keyfile, string_list &used_keys)=0 |
Set the chroot properties from a keyfile. More... | |
Private Types | |
typedef std::shared_ptr< chroot_facet > | facet_ptr |
A shared pointer to a chroot facet. | |
typedef std::list< facet_ptr > | facet_list |
A list of chroot facets. | |
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? | |
bool | run_setup_scripts |
Run chroot setup scripts? | |
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, ptr const &rhs) |
Print detailed information about the chroot to a stream. More... | |
keyfile const & | operator>> (keyfile const &keyfile, ptr &rhs) |
Chroot initialisation from a keyfile. More... | |
keyfile & | operator<< (keyfile &keyfile, ptr const &rhs) |
Chroot serialisation to a keyfile. More... | |
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.
Error codes.
|
protected |
void sbuild::chroot::add_facet | ( | std::shared_ptr< T > | facet | ) |
Add a chroot facet.
facet | the facet to add. |
References FACET_INVALID, FACET_PRESENT, and facets.
Referenced by chroot(), sbuild::chroot_block_device::chroot_block_device(), sbuild::chroot_block_device_base::chroot_block_device_base(), sbuild::chroot_btrfs_snapshot::chroot_btrfs_snapshot(), sbuild::chroot_directory::chroot_directory(), sbuild::chroot_file::chroot_file(), sbuild::chroot_loopback::chroot_loopback(), sbuild::chroot_lvm_snapshot::chroot_lvm_snapshot(), replace_facet(), sbuild::chroot_custom::set_session_cloneable(), sbuild::chroot_custom::set_source_cloneable(), and sbuild::chroot_facet_union::set_union_type().
|
pure virtual |
Copy the chroot.
This is a virtual copy constructor.
Implemented in sbuild::chroot_block_device, sbuild::chroot_directory, sbuild::chroot_custom, sbuild::chroot_loopback, sbuild::chroot_btrfs_snapshot, sbuild::chroot_file, sbuild::chroot_lvm_snapshot, and sbuild::chroot_plain.
|
pure virtual |
Create a session chroot.
session_id | the identifier (session_id) for the new session. |
alias | used to initially identify the chroot. |
user | the user creating the session. |
root | true if the user has root access, otherwise false. |
Implemented in sbuild::chroot_block_device, sbuild::chroot_directory, sbuild::chroot_custom, sbuild::chroot_loopback, sbuild::chroot_btrfs_snapshot, sbuild::chroot_file, sbuild::chroot_lvm_snapshot, and sbuild::chroot_plain.
Referenced by sbuild::session::run_impl().
|
pure virtual |
Create a source chroot.
Implemented in sbuild::chroot_block_device, sbuild::chroot_directory, sbuild::chroot_custom, sbuild::chroot_loopback, sbuild::chroot_btrfs_snapshot, sbuild::chroot_file, sbuild::chroot_lvm_snapshot, and sbuild::chroot_plain.
|
static |
Create a chroot.
This is a factory function.
type | the type of chroot to create. |
References CHROOT_CREATE, and CHROOT_TYPE.
Referenced by sbuild::chroot_config::load_keyfile().
bool sbuild::chroot::get_active | ( | ) | const |
Get the activity status of the chroot.
The chroot is active if it has been cloned as a session.
string_list const & sbuild::chroot::get_aliases | ( | ) | const |
Get the aliases of the chroot.
These are alternative names for the chroot.
References aliases.
Referenced by get_details(), and get_keyfile().
|
pure virtual |
Get the type of the chroot.
Implemented in sbuild::chroot_file, sbuild::chroot_btrfs_snapshot, sbuild::chroot_custom, sbuild::chroot_lvm_snapshot, sbuild::chroot_loopback, sbuild::chroot_directory, sbuild::chroot_block_device, and sbuild::chroot_plain.
Referenced by get_details(), get_keyfile(), and setup_env().
string_list const & sbuild::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.
References command_prefix.
Referenced by get_details(), and get_keyfile().
std::string const & sbuild::chroot::get_default_shell | ( | ) | const |
Get default shell.
References default_shell.
Referenced by get_details(), and get_keyfile().
std::string const & sbuild::chroot::get_description | ( | ) | const |
Get the description of the chroot.
References description.
Referenced by get_details(), get_keyfile(), and setup_env().
void sbuild::chroot::get_details | ( | format_detail & | detail | ) | const |
Get detailed information about the chroot for output.
detail | the details to output to. |
References facets.
Referenced by sbuild::chroot_directory_base::get_details(), sbuild::chroot_block_device_base::get_details(), sbuild::chroot_loopback::get_details(), sbuild::chroot_custom::get_details(), sbuild::chroot_btrfs_snapshot::get_details(), sbuild::chroot_file::get_details(), and print_details().
|
pure virtual |
Get detailed information about the chroot for output.
chroot | the chroot to use. |
detail | the details to output to. |
Implemented in sbuild::chroot_file, sbuild::chroot_btrfs_snapshot, sbuild::chroot_custom, sbuild::chroot_lvm_snapshot, sbuild::chroot_loopback, sbuild::chroot_block_device, sbuild::chroot_directory, sbuild::chroot_block_device_base, and sbuild::chroot_directory_base.
References sbuild::_(), sbuild::format_detail::add(), get_aliases(), get_chroot_type(), get_command_prefix(), get_default_shell(), get_description(), get_environment_filter(), get_groups(), get_mount_location(), get_name(), get_path(), get_preserve_environment(), get_profile(), get_root_groups(), get_root_users(), get_run_setup_scripts(), get_script_config(), get_session_flags(), get_users(), get_verbosity_string(), SESSION_CLONE, SESSION_CREATE, and SESSION_PURGE.
regex const & sbuild::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.
References environment_filter.
Referenced by get_details(), and get_keyfile().
std::shared_ptr< T > sbuild::chroot::get_facet | ( | ) |
Get a chroot facet.
This is a templated method; use the correct type for the facet required.
References facets.
Referenced by sbuild::chroot_facet_session_clonable::clone_session_setup(), sbuild::chroot_facet_mountable::get_keyfile(), sbuild::chroot_custom::get_session_flags(), sbuild::chroot_file::get_session_flags(), sbuild::chroot_facet_union::get_session_flags(), sbuild::chroot_facet_source_clonable::get_session_flags(), sbuild::session::run_impl(), sbuild::chroot_facet_mountable::set_keyfile(), sbuild::chroot_facet_union::set_keyfile(), sbuild::chroot_facet_union::set_union_type(), and sbuild::chroot_block_device::setup_lock().
const std::shared_ptr< const T > sbuild::chroot::get_facet | ( | ) | const |
Get a chroot facet.
This is a templated method; use the correct type for the facet required.
References facets.
string_list const & sbuild::chroot::get_groups | ( | ) | const |
Get the groups allowed to access the chroot.
References groups.
Referenced by get_details(), and get_keyfile().
void sbuild::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.
keyfile | the keyfile to use. |
References facets.
Referenced by sbuild::chroot_directory_base::get_keyfile(), sbuild::chroot_block_device_base::get_keyfile(), sbuild::chroot_loopback::get_keyfile(), sbuild::chroot_custom::get_keyfile(), sbuild::chroot_btrfs_snapshot::get_keyfile(), sbuild::chroot_file::get_keyfile(), and setup_session_info().
|
protectedpure virtual |
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.
chroot | the chroot to use. |
keyfile | the keyfile to use. |
Implemented in sbuild::chroot_file, sbuild::chroot_btrfs_snapshot, sbuild::chroot_custom, sbuild::chroot_lvm_snapshot, sbuild::chroot_loopback, sbuild::chroot_block_device, sbuild::chroot_directory, sbuild::chroot_block_device_base, and sbuild::chroot_directory_base.
References 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::basic_keyfile< K, P >::remove_group(), sbuild::basic_keyfile< K, P >::set_object_list_value(), and sbuild::basic_keyfile< K, P >::set_object_value().
std::string const & sbuild::chroot::get_mount_location | ( | ) | const |
Get the mount location of the chroot.
References mount_location.
Referenced by get_details(), get_keyfile(), sbuild::chroot_directory::get_path(), sbuild::chroot_block_device_base::get_path(), sbuild::chroot_loopback::get_path(), sbuild::chroot_custom::get_path(), sbuild::chroot_btrfs_snapshot::get_path(), sbuild::chroot_file::get_path(), and setup_env().
std::string const & sbuild::chroot::get_name | ( | ) | const |
Get the name of the chroot.
References name.
Referenced by sbuild::chroot_facet_session::get_details(), get_details(), sbuild::chroot_directory_base::get_keyfile(), sbuild::chroot_block_device_base::get_keyfile(), sbuild::chroot_facet_personality::get_keyfile(), sbuild::chroot_facet_userdata::get_keyfile(), sbuild::chroot_loopback::get_keyfile(), sbuild::chroot_lvm_snapshot::get_keyfile(), sbuild::chroot_custom::get_keyfile(), sbuild::chroot_facet_mountable::get_keyfile(), sbuild::chroot_facet_session::get_keyfile(), sbuild::chroot_btrfs_snapshot::get_keyfile(), sbuild::chroot_file::get_keyfile(), sbuild::chroot_facet_union::get_keyfile(), sbuild::chroot_facet_source_clonable::get_keyfile(), get_keyfile(), sbuild::session::run_impl(), sbuild::chroot_directory_base::set_keyfile(), sbuild::chroot_block_device_base::set_keyfile(), sbuild::chroot_facet_userdata::set_keyfile(), sbuild::chroot_facet_personality::set_keyfile(), sbuild::chroot_loopback::set_keyfile(), sbuild::chroot_lvm_snapshot::set_keyfile(), sbuild::chroot_custom::set_keyfile(), sbuild::chroot_facet_mountable::set_keyfile(), sbuild::chroot_facet_session::set_keyfile(), sbuild::chroot_btrfs_snapshot::set_keyfile(), sbuild::chroot_file::set_keyfile(), sbuild::chroot_facet_union::set_keyfile(), sbuild::chroot_facet_source_clonable::set_keyfile(), set_keyfile(), setup_env(), and setup_session_info().
bool sbuild::chroot::get_original | ( | ) | const |
Get the originality of the chroot.
References original.
|
pure virtual |
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.
Implemented in sbuild::chroot_file, sbuild::chroot_btrfs_snapshot, sbuild::chroot_custom, sbuild::chroot_loopback, sbuild::chroot_block_device_base, sbuild::chroot_directory, and sbuild::chroot_plain.
Referenced by get_details(), and setup_env().
bool sbuild::chroot::get_preserve_environment | ( | ) | const |
Check if the environment should be preserved in the chroot.
References preserve_environment.
Referenced by get_details(), and get_keyfile().
std::string const & sbuild::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.
References profile.
Referenced by chroot(), get_details(), get_keyfile(), and setup_env().
string_list const & sbuild::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.
References root_groups.
Referenced by get_details(), and get_keyfile().
string_list const & sbuild::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.
References root_users.
Referenced by get_details(), and get_keyfile().
bool sbuild::chroot::get_run_setup_scripts | ( | ) | const |
Check if chroot setup scripts will be run.
References run_setup_scripts.
Referenced by get_details().
std::string const & sbuild::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.
References script_config.
Referenced by get_details(), get_keyfile(), and setup_env().
sbuild::chroot::session_flags sbuild::chroot::get_session_flags | ( | ) | const |
Get the session flags of the chroot.
These determine how the Session controlling the chroot will operate.
References facets.
Referenced by get_details(), sbuild::chroot_block_device::get_session_flags(), and setup_env().
|
pure virtual |
Get the session flags of the chroot.
These determine how the Session controlling the chroot will operate.
chroot | the chroot to use. |
Implemented in sbuild::chroot_file, sbuild::chroot_btrfs_snapshot, sbuild::chroot_custom, sbuild::chroot_lvm_snapshot, sbuild::chroot_loopback, sbuild::chroot_block_device, sbuild::chroot_directory, sbuild::chroot_block_device_base, and sbuild::chroot_plain.
string_list const & sbuild::chroot::get_users | ( | ) | const |
Get the users allowed to access the chroot.
References users.
Referenced by get_details(), and get_keyfile().
sbuild::chroot::verbosity sbuild::chroot::get_verbosity | ( | ) | const |
const char * sbuild::chroot::get_verbosity_string | ( | ) | const |
Get the message verbosity 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().
string_list sbuild::chroot::list_facets | ( | ) | const |
void sbuild::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.
type | the type of setup being performed |
References setup_lock().
Referenced by setup_session_info().
void sbuild::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.
stream | the stream to output to. |
References sbuild::_(), and get_details().
void sbuild::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_union::set_union_type().
void sbuild::chroot::remove_facet | ( | std::shared_ptr< T > | facet | ) |
Remove a chroot facet.
facet | the facet to remove. |
void sbuild::chroot::replace_facet | ( | std::shared_ptr< T > | facet | ) |
Replace an existing chroot facet with a new facet.
facet | the replacement facet. |
References add_facet().
void sbuild::chroot::set_aliases | ( | string_list const & | aliases | ) |
Set the aliases of the chroot.
These are alternative names for the chroot.
aliases | a 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().
void sbuild::chroot::set_command_prefix | ( | string_list const & | command_prefix | ) |
Set the command_prefix for the chroot.
This is a command to prefix to any command run in the chroot.
command_prefix | the command prefix. |
References command_prefix.
Referenced by set_keyfile().
void sbuild::chroot::set_default_shell | ( | std::string const & | default_shell | ) |
Set the default shell.
This is the default interactive shell.
default_shell | the default shell. |
References default_shell.
Referenced by set_keyfile().
void sbuild::chroot::set_description | ( | std::string const & | description | ) |
Set the description of the chroot.
description | the description. |
References description.
Referenced by set_keyfile().
void sbuild::chroot::set_environment_filter | ( | regex const & | 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.
environment_filter | the filter. |
References environment_filter.
Referenced by set_keyfile().
void sbuild::chroot::set_groups | ( | string_list const & | groups | ) |
Set the users allowed to access the chroot.
groups | a list of groups. |
References groups.
Referenced by set_keyfile().
void sbuild::chroot::set_keyfile | ( | keyfile const & | keyfile | ) |
Set the chroot properties from a keyfile.
The chroot name must have previously been set, so that the correct keyfile group may be determined.
keyfile | the keyfile to get the properties from. |
References sbuild::_(), facets, sbuild::basic_keyfile< K, P >::get_keys(), sbuild::basic_keyfile< K, P >::get_line(), get_name(), sbuild::error_base::get_reason(), sbuild::basic_keyfile< K, P >::get_value(), sbuild::keyfile_base::INVALID_KEY, sbuild::log_exception_warning(), sbuild::keyfile_base::PASSTHROUGH_LGK, and sbuild::error_base::set_reason().
Referenced by sbuild::chroot_directory_base::set_keyfile(), sbuild::chroot_block_device_base::set_keyfile(), sbuild::chroot_loopback::set_keyfile(), sbuild::chroot_custom::set_keyfile(), sbuild::chroot_btrfs_snapshot::set_keyfile(), and sbuild::chroot_file::set_keyfile().
|
protectedpure virtual |
Set the chroot properties from a keyfile.
The chroot name must have previously been set, so that the correct keyfile group may be determined.
chroot | the chroot to use. |
keyfile | the keyfile to get the properties from. |
used_keys | a list of the keys used will be set. |
Implemented in sbuild::chroot_file, sbuild::chroot_btrfs_snapshot, sbuild::chroot_custom, sbuild::chroot_lvm_snapshot, sbuild::chroot_loopback, sbuild::chroot_block_device, sbuild::chroot_directory, sbuild::chroot_block_device_base, and sbuild::chroot_directory_base.
References sbuild::basic_keyfile< K, P >::get_keys(), get_name(), sbuild::basic_keyfile< K, P >::get_object_list_value(), sbuild::basic_keyfile< K, P >::get_object_value(), sbuild::keyfile_base::PRIORITY_DEPRECATED, sbuild::keyfile_base::PRIORITY_DISALLOWED, sbuild::keyfile_base::PRIORITY_OBSOLETE, sbuild::keyfile_base::PRIORITY_OPTIONAL, sbuild::keyfile_base::PRIORITY_REQUIRED, sbuild::regex_search(), set_aliases(), set_command_prefix(), set_default_shell(), set_description(), set_environment_filter(), set_groups(), set_mount_location(), set_name(), set_preserve_environment(), set_profile(), set_root_groups(), set_root_users(), set_script_config(), set_users(), and set_verbosity().
void sbuild::chroot::set_mount_location | ( | std::string const & | location | ) |
Set the mount location of the chroot.
location | the mount location. |
References sbuild::is_absname(), LOCATION_ABS, and mount_location.
Referenced by set_keyfile().
void sbuild::chroot::set_name | ( | std::string const & | name | ) |
Set the name of the chroot.
name | the 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().
void sbuild::chroot::set_original | ( | bool | original | ) |
Set the originality of the chroot.
original | true if original, false if generated. |
References original.
void sbuild::chroot::set_preserve_environment | ( | bool | preserve_environment | ) |
Set if the environment should be preserved in the chroot.
preserve_environment | true to preserve or false to clean. |
References preserve_environment.
Referenced by set_keyfile().
void sbuild::chroot::set_profile | ( | std::string const & | profile | ) |
Set configuration profile for the chroot.
This is a directory, either relative to the configured pkgsysconfdir or an absolute path.
profile | the script configuration file. |
References profile.
Referenced by chroot(), and set_keyfile().
void sbuild::chroot::set_root_groups | ( | string_list const & | groups | ) |
Set the groups allowed to access the chroot as root.
Members of these groups can switch to root without authenticating themselves.
groups | a list of groups. |
References groups, and root_groups.
Referenced by set_keyfile().
void sbuild::chroot::set_root_users | ( | string_list const & | users | ) |
Set the users allowed to access the chroot as root.
Members of these users can switch to root without authenticating themselves.
users | a list of users. |
References root_users, and users.
Referenced by set_keyfile().
|
protected |
Set whether chroot setup scripts will be run.
run_setup_scripts | true if setup scripts will be run, otherwise false. |
References run_setup_scripts.
Referenced by sbuild::chroot_plain::chroot_plain().
void sbuild::chroot::set_script_config | ( | std::string const & | script_config | ) |
Set the script configuration file for the chroot.
This is a filename, either relative to the configured pkgsysconfdir or an absolute path.
script_config | the script configuration file. |
References profile, and script_config.
Referenced by set_keyfile().
void sbuild::chroot::set_users | ( | string_list const & | users | ) |
Set the users allowed to access the chroot.
users | a list of users. |
References users.
Referenced by set_keyfile().
void sbuild::chroot::set_verbosity | ( | chroot::verbosity | verbosity | ) |
Set the message verbosity.
verbosity | the verbosity level. |
References message_verbosity.
Referenced by sbuild::session::run_impl(), and set_keyfile().
void sbuild::chroot::set_verbosity | ( | std::string const & | verbosity | ) |
Set the message verbosity.
verbosity | the verbosity level. |
References message_verbosity, VERBOSITY_INVALID, VERBOSITY_NORMAL, VERBOSITY_QUIET, and VERBOSITY_VERBOSE.
void sbuild::chroot::setup_env | ( | environment & | env | ) | const |
Set environment.
Set the environment that the setup scripts will see during execution.
env | the environment to set. |
References facets.
Referenced by sbuild::chroot_directory_base::setup_env(), sbuild::chroot_block_device_base::setup_env(), sbuild::chroot_loopback::setup_env(), sbuild::chroot_custom::setup_env(), sbuild::chroot_file::setup_env(), and sbuild::chroot_btrfs_snapshot::setup_env().
|
pure virtual |
Set environment.
Set the environment that the setup scripts will see during execution.
chroot | the chroot to use. |
env | the environment to set. |
Implemented in sbuild::chroot_btrfs_snapshot, sbuild::chroot_file, sbuild::chroot_custom, sbuild::chroot_lvm_snapshot, sbuild::chroot_loopback, sbuild::chroot_block_device, sbuild::chroot_block_device_base, sbuild::chroot_directory_base, and sbuild::chroot_directory.
References sbuild::environment::add(), get_chroot_type(), get_description(), get_mount_location(), get_name(), get_path(), get_profile(), get_script_config(), get_session_flags(), sbuild::normalname(), SESSION_CLONE, SESSION_CREATE, SESSION_PURGE, and SESSION_SOURCE.
|
protectedpure virtual |
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.
type | the type of setup being performed |
lock | true to lock, false to unlock |
status | the exit status of the setup commands (0 for success, nonzero for failure). |
Implemented in sbuild::chroot_file, sbuild::chroot_btrfs_snapshot, sbuild::chroot_custom, sbuild::chroot_lvm_snapshot, sbuild::chroot_loopback, sbuild::chroot_block_device, sbuild::chroot_directory, and sbuild::chroot_plain.
Referenced by lock(), and unlock().
|
protectedvirtual |
Set up persistent session information.
start | true if startion, or false if ending a session. |
References FILE_LOCK, FILE_UNLOCK, get_keyfile(), get_name(), lock(), sbuild::lock::LOCK_EXCLUSIVE, SESSION_UNLINK, SESSION_WRITE, sbuild::file_lock::set_lock(), and sbuild::file_lock::unset_lock().
Referenced by sbuild::chroot_block_device::setup_lock(), sbuild::chroot_directory::setup_lock(), sbuild::chroot_loopback::setup_lock(), sbuild::chroot_lvm_snapshot::setup_lock(), sbuild::chroot_custom::setup_lock(), sbuild::chroot_btrfs_snapshot::setup_lock(), and sbuild::chroot_file::setup_lock().
void sbuild::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.
type | the type of setup being performed |
status | the exit status of the setup commands (0 for success, nonzero for failure). |
References setup_lock().
|
friend |
Print detailed information about the chroot to a stream.
The information is printed in plain text with one line per property.
stream | the stream to output to. |
rhs | the chroot to output. |
Chroot serialisation to a keyfile.
keyfile | the keyfile to use. |
rhs | the chroot to output. |
Chroot initialisation from a keyfile.
keyfile | the keyfile to get the properties from. |
rhs | the chroot to output. |