#include <sbuild-chroot-config.h>

Public Types | |
| enum | error_code { ALIAS_EXIST, CHROOT_NOTFOUND, CHROOT_EXIST, FILE_NOTREG, FILE_OPEN, FILE_OWNER, FILE_PERMS } |
| Error codes. More... | |
| typedef std::vector< chroot::ptr > | chroot_list |
| A list of chroots. | |
| typedef std::map< std::string, std::string > | string_map |
| A map between key-value string pairs. | |
| typedef std::map< std::string, chroot::ptr > | chroot_map |
| A map between a chroot name and a chroot object. | |
| typedef custom_error< error_code > | error |
| Exception type. | |
| typedef std::tr1::shared_ptr < chroot_config > | ptr |
| A shared_ptr to a chroot_config object. | |
Public Member Functions | |
| chroot_config () | |
| The constructor. | |
| chroot_config (std::string const &file, bool active) | |
| The constructor. | |
| virtual | ~chroot_config () |
| The destructor. | |
| void | add (std::string const &location, bool active) |
| Add a configuration file or directory. | |
| chroot_list | get_chroots () const |
| Get a list of available chroots. | |
| const chroot::ptr | find_chroot (std::string const &name) const |
| Find a chroot by its name. | |
| const chroot::ptr | find_alias (std::string const &name) const |
| Find a chroot by its name or an alias. | |
| string_list | get_chroot_list () const |
| Get the names (including aliases) of all the available chroots, sorted in alphabetical order. | |
| void | print_chroot_list (std::ostream &stream) const |
| Print all the available chroots to the specified stream. | |
| void | print_chroot_list_simple (std::ostream &stream) const |
| Print a single line of all the available chroots to the specified stream. | |
| void | print_chroot_info (string_list const &chroots, std::ostream &stream) const |
| Print information about the specified chroots to the specified stream. | |
| void | print_chroot_location (string_list const &chroots, std::ostream &stream) const |
| Print location information about the specified chroots to the specified stream. | |
| void | print_chroot_config (string_list const &chroots, std::ostream &stream) const |
| Print configuration of the specified chroots to the specified stream. | |
| string_list | validate_chroots (string_list const &chroots) const |
| Check that all the chroots specified exist. | |
Protected Member Functions | |
| void | add (chroot::ptr &chroot, keyfile const &kconfig) |
| Add a chroot. | |
| virtual void | parse_data (std::istream &stream, bool active) |
| Parse a loaded configuration file. | |
| virtual void | load_keyfile (keyfile &kconfig, bool active) |
| Load a keyfile. | |
Protected Attributes | |
| chroot_map | chroots |
| A list of chroots (name->chroot mapping). | |
| string_map | aliases |
| A list of aliases (alias->name mapping). | |
Private Member Functions | |
| void | add_config_file (std::string const &file, bool active) |
| Add a configuration file. | |
| void | add_config_directory (std::string const &dir, bool active) |
| Add a configuration directory. | |
| void | load_data (std::string const &file, bool active) |
| Load a configuration file. | |
This class holds the configuration details from the configuration file. Conceptually, it's an opaque container of chroot objects.
Methods are provided to query the available chroots and find specific chroots.
| typedef std::vector<chroot::ptr> sbuild::chroot_config::chroot_list |
A list of chroots.
| typedef std::map<std::string, chroot::ptr> sbuild::chroot_config::chroot_map |
Exception type.
| typedef std::tr1::shared_ptr<chroot_config> sbuild::chroot_config::ptr |
A shared_ptr to a chroot_config object.
| typedef std::map<std::string, std::string> sbuild::chroot_config::string_map |
A map between key-value string pairs.
Error codes.
| ALIAS_EXIST | Alias already associated with chroot. |
| CHROOT_NOTFOUND | No such chroot. |
| CHROOT_EXIST | A chroot or alias already exists with this name. |
| FILE_NOTREG | File is not a regular file. |
| FILE_OPEN | Failed to open file. |
| FILE_OWNER | File is not owned by user root. |
| FILE_PERMS | File has write permissions for others. |
| chroot_config::chroot_config | ( | ) |
The constructor.
| chroot_config::chroot_config | ( | std::string const & | file, | |
| bool | active | |||
| ) |
The constructor.
| file | initialise using a configuration file or a whole directory containing configuration files. | |
| active | true if the chroots in the configuration file are active sessions, otherwise false. |
| chroot_config::~chroot_config | ( | ) | [virtual] |
The destructor.
| void chroot_config::add | ( | chroot::ptr & | chroot, | |
| keyfile const & | kconfig | |||
| ) | [protected] |
Add a chroot.
The lists of chroots and aliases will be updated. If a chroot or alias by the same name exists, the chroot will not be added, and a warning will be logged. Af any of the aliases already exist, a warning will be logged, and the alias will not be added.
References ALIAS_EXIST, aliases, CHROOT_EXIST, chroots, sbuild::basic_keyfile< K, P >::get_line(), sbuild::log_exception_warning(), sbuild::keyfile_base::PASSTHROUGH_G, sbuild::keyfile_base::PASSTHROUGH_GK, sbuild::keyfile_base::PASSTHROUGH_LG, sbuild::keyfile_base::PASSTHROUGH_LGK, and sbuild::error_base::set_reason().
| void chroot_config::add | ( | std::string const & | location, | |
| bool | active | |||
| ) |
Add a configuration file or directory.
The configuration file or directory specified will be loaded.
| location | initialise using a configuration file or a whole directory containing configuration files. | |
| active | true if the chroots in the configuration file are active sessions, otherwise false. |
References add_config_directory(), and add_config_file().
| void chroot_config::add_config_directory | ( | std::string const & | dir, | |
| bool | active | |||
| ) | [private] |
Add a configuration directory.
The configuration files in the directory specified will all be loaded.
| dir | the directory containing the files to load. | |
| active | true if the chroots in the configuration file are active sessions, otherwise false. |
References sbuild::DEBUG_NOTICE, FILE_NOTREG, load_data(), sbuild::log_debug(), sbuild::log_exception_warning(), and sbuild::direntry::name().
Referenced by add().
| void chroot_config::add_config_file | ( | std::string const & | file, | |
| bool | active | |||
| ) | [private] |
Add a configuration file.
The configuration file specified will be loaded.
| file | the file to load. | |
| active | true if the chroots in the configuration file are active sessions, otherwise false. |
References sbuild::DEBUG_NOTICE, load_data(), and sbuild::log_debug().
Referenced by add().
| const sbuild::chroot::ptr chroot_config::find_alias | ( | std::string const & | name | ) | const |
Find a chroot by its name or an alias.
| name | the chroot name or alias. |
References aliases, and find_chroot().
Referenced by print_chroot_config(), print_chroot_info(), print_chroot_location(), and validate_chroots().
| const sbuild::chroot::ptr chroot_config::find_chroot | ( | std::string const & | name | ) | const |
Find a chroot by its name.
| name | the chroot name |
References chroots.
Referenced by find_alias().
| string_list chroot_config::get_chroot_list | ( | ) | const |
Get the names (including aliases) of all the available chroots, sorted in alphabetical order.
References aliases.
Referenced by print_chroot_list().
| chroot_config::chroot_list chroot_config::get_chroots | ( | ) | const |
Get a list of available chroots.
References chroots.
| void chroot_config::load_data | ( | std::string const & | file, | |
| bool | active | |||
| ) | [private] |
Load a configuration file.
If there are problems with the configuration file, an error will be thrown. The file must be owned by root, not writable by other, and be a regular file.
| file | the file to load. | |
| active | true if the chroots in the configuration file are active sessions, otherwise false. |
References sbuild::stat::check_mode(), sbuild::DEBUG_NOTICE, FILE_NOTREG, FILE_OPEN, FILE_OWNER, FILE_PERMS, sbuild::stat::is_regular(), sbuild::lock::LOCK_SHARED, sbuild::log_debug(), parse_data(), sbuild::stat::PERM_OTHER_WRITE, sbuild::file_lock::set_lock(), sbuild::stat::uid(), and sbuild::file_lock::unset_lock().
Referenced by add_config_directory(), and add_config_file().
| void chroot_config::load_keyfile | ( | keyfile & | kconfig, | |
| bool | active | |||
| ) | [protected, virtual] |
Load a keyfile.
If there are problems with the configuration file, an error will be thrown.
| kconfig | the chroot configuration. | |
| active | true if the chroots in the configuration file are active sessions, otherwise false. |
References sbuild::chroot_source::clone_source(), sbuild::chroot::create(), sbuild::chroot::get_active(), sbuild::basic_keyfile< K, P >::get_groups(), sbuild::basic_keyfile< K, P >::get_value(), and sbuild::basic_keyfile< K, P >::set_value().
Referenced by parse_data().
| void chroot_config::parse_data | ( | std::istream & | stream, | |
| bool | active | |||
| ) | [protected, virtual] |
Parse a loaded configuration file.
If there are problems with the configuration file, an error will be thrown.
| stream | the data stream to parse. | |
| active | true if the chroots in the configuration file are active sessions, otherwise false. |
References load_keyfile().
Referenced by load_data().
| void chroot_config::print_chroot_config | ( | string_list const & | chroots, | |
| std::ostream & | stream | |||
| ) | const |
Print configuration of the specified chroots to the specified stream.
| chroots | a list of chroots to print. | |
| stream | the stream to output to. |
References CHROOT_NOTFOUND, find_alias(), and sbuild::log_exception_error().
| void chroot_config::print_chroot_info | ( | string_list const & | chroots, | |
| std::ostream & | stream | |||
| ) | const |
Print information about the specified chroots to the specified stream.
| chroots | a list of chroots to print. | |
| stream | the stream to output to. |
References CHROOT_NOTFOUND, find_alias(), and sbuild::log_exception_error().
| void chroot_config::print_chroot_list | ( | std::ostream & | stream | ) | const |
Print all the available chroots to the specified stream.
| stream | the stream to output to. |
References chroots, and get_chroot_list().
| void chroot_config::print_chroot_list_simple | ( | std::ostream & | stream | ) | const |
| void chroot_config::print_chroot_location | ( | string_list const & | chroots, | |
| std::ostream & | stream | |||
| ) | const |
Print location information about the specified chroots to the specified stream.
| chroots | a list of chroots to print. | |
| stream | the stream to output to. |
References CHROOT_NOTFOUND, find_alias(), and sbuild::log_exception_error().
| string_list chroot_config::validate_chroots | ( | string_list const & | chroots | ) | const |
Check that all the chroots specified exist.
| chroots | a list of chroots to validate. |
References find_alias().
string_map sbuild::chroot_config::aliases [protected] |
A list of aliases (alias->name mapping).
Referenced by add(), find_alias(), get_chroot_list(), and print_chroot_list_simple().
chroot_map sbuild::chroot_config::chroots [protected] |
A list of chroots (name->chroot mapping).
Referenced by add(), find_chroot(), get_chroots(), print_chroot_list(), and print_chroot_list_simple().
1.5.8