sbuild
1.7.1
|
Debian source builder components. More...
Namespaces | |
auth | |
Authentication and authorisation handling. | |
chroot | |
Handling and configuration of chroots. | |
Classes | |
class | custom_error |
Custom error. More... | |
class | environment |
Container of environment variables. More... | |
class | error_base |
Error exception base class. More... | |
class | error |
Error exception class. More... | |
class | feature |
class | format_detail |
Format names and values for output. More... | |
class | keyfile_reader |
Keyfile reader. More... | |
class | keyfile_writer |
Keyfile writer. More... | |
class | keyfile |
Configuration file parser. More... | |
class | lock |
Advisory locking. More... | |
class | file_lock |
File lock. More... | |
class | mntstream |
Access mounts. More... | |
class | basic_nbuf |
Null stream buffer. More... | |
class | basic_nostream |
Null output stream. More... | |
class | parse_error |
Parse error. More... | |
class | personality |
Chroot personality. More... | |
class | regex |
POSIX extended regular expression. More... | |
class | run_parts |
Run all scripts or programs within a directory. More... | |
class | session |
Session handler. More... | |
class | date_base |
A date representation. More... | |
class | gmdate |
A date representation in UTC. More... | |
class | date |
A date representation in local time. More... | |
class | isodate |
A date representation in ISO-8601 format. More... | |
class | stat |
Get file status. More... | |
class | passwd |
System passwd database entry. More... | |
class | group |
System group database entry. More... | |
Typedefs | |
typedef parse_error < ctty_error_code > | ctty_error |
Exception type. | |
typedef boost::iostreams::stream < boost::iostreams::file_descriptor > | fdstream |
typedef boost::iostreams::stream < boost::iostreams::file_descriptor_source > | fdistream |
typedef boost::iostreams::stream < boost::iostreams::file_descriptor_sink > | fdostream |
typedef basic_nostream< char > | nostream |
A null ostream. | |
typedef basic_nostream< wchar_t > | wnostream |
A wide null ostream. | |
typedef parse_error < parse_value_error_code > | parse_value_error |
Exception type. | |
typedef std::vector< std::string > | string_list |
A string vector. | |
typedef std::set< std::string > | string_set |
A string set. | |
typedef std::map< std::string, std::string > | string_map |
A string map. | |
Enumerations | |
enum | ctty_error_code { CTTY_CLOEXEC, CTTY_DUP } |
Error codes. More... | |
enum | debug_level { DEBUG_NONE = -1, DEBUG_NOTICE = 1, DEBUG_INFO = 2, DEBUG_WARNING = 3, DEBUG_CRITICAL = 4 } |
Debugging level. More... | |
enum | parse_value_error_code { BAD_VALUE } |
Error codes. More... | |
Functions | |
const int | CTTY_FILENO (open_ctty()) |
fdstream | cctty (cttybuf_fd(), boost::iostreams::close_handle) |
const char * | gettext (const char *message) |
Get a translated message. More... | |
const char * | gettext (const std::string &message) |
Get a translated message. More... | |
const char * | _ (const char *message) |
Get a translated message. More... | |
const char * | gettext_noop (const char *message) |
Get a message with no translation. More... | |
const char * | N_ (const char *message) |
Get a message with no translation. More... | |
sbuild::keyfile | operator+ (const sbuild::keyfile &lhs, const sbuild::keyfile &rhs) |
std::ostream & | log_info () |
Log an informational message. More... | |
std::ostream & | log_warning () |
Log a warning message. More... | |
std::ostream & | log_error () |
Log an error message. More... | |
std::ostream & | log_debug (debug_level level) |
Log a debug message. More... | |
std::ostream & | log_ctty_info () |
Log an informational message to the Controlling TTY. More... | |
std::ostream & | log_ctty_warning () |
Log a warning message to the Controlling TTY. More... | |
std::ostream & | log_ctty_error () |
Log an error message to the Controlling TTY. More... | |
void | log_exception_warning (const std::exception &e) |
Log an exception as a warning. More... | |
void | log_exception_error (const std::exception &e) |
Log an exception as an error. More... | |
void | log_ctty_exception_warning (const std::exception &e) |
Log an exception as a warning to the Controlling TTY. More... | |
void | log_ctty_exception_error (const std::exception &e) |
Log an exception as an error to the Controlling TTY. More... | |
void | log_unknown_exception_error () |
Log an unknown exception as an error. | |
mntstream & | operator>> (mntstream &stream, mntstream::mntentry &entry) |
The overloaded extraction operator. More... | |
void | parse_value (const std::string &value, bool &parsed_value) |
Parse a boolean value. More... | |
void | parse_value (const std::string &value, std::string &parsed_value) |
Parse a string value. More... | |
template<typename T > | |
void | parse_value (const std::string &value, T &parsed_value) |
Parse a value of type T. More... | |
bool | regex_search (const std::string &str, const regex ®ex) |
Search using the regular expression. | |
std::string | basename (std::string name) |
Strip the directory path from a filename. More... | |
std::string | dirname (std::string name) |
Strip the fileame from a pathname. More... | |
std::string | normalname (std::string name) |
Normalise a pathname. More... | |
bool | is_absname (const std::string &name) |
Check if a pathname is absolute. More... | |
bool | is_valid_sessionname (const std::string &name) |
Check if a filename matches the allowed pattern(s). More... | |
bool | is_valid_filename (const std::string &name, bool lsb_mode=true) |
Check if a filename matches the allowed pattern(s). More... | |
std::string | getcwd () |
Get the current working directory. More... | |
std::string | unique_identifier () |
Get a unique string for use as a session identifier. More... | |
std::string | string_list_to_string (const string_list &list, const std::string &separator) |
Convert a string_list into a string. More... | |
string_list | split_string (const std::string &value, const std::string &separator) |
Split a string into a string_list. More... | |
string_list | split_string_strict (const std::string &value, const std::string &separator) |
Split a string into a string_list. More... | |
std::wstring | widen_string (const std::string &str, std::locale locale) |
Widen a string. More... | |
std::string | narrow_string (const std::wstring &str, std::locale locale) |
Narrow a string. More... | |
std::string | find_program_in_path (const std::string &program, const std::string &path, const std::string &prefix) |
Find a program in the PATH search path. More... | |
char ** | string_list_to_strv (const string_list &str) |
Create a string vector from a string_list. More... | |
void | strv_delete (char **strv) |
Delete a string vector. More... | |
int | exec (const std::string &file, const string_list &command, const environment &env) |
execve wrapper. More... | |
template<typename S > | |
std::vector< S > | split_string (S const &value, S const &separator) |
Split a string into a string_list. More... | |
template<typename S > | |
std::vector< S > | split_string_strict (S const &value, S const &separator) |
Split a string into a string_list. More... | |
template<typename T > | |
std::string | type_name () |
Get the type name of a type, demangled if possible. | |
stat::mode_bits | operator| (const stat::mode_bits &lhs, const stat::mode_bits &rhs) |
Bitwise-OR of specifed mode bits. More... | |
stat::mode_bits | operator| (const mode_t &lhs, const stat::mode_bits &rhs) |
Bitwise-OR of specifed mode bits. More... | |
stat::mode_bits | operator| (const stat::mode_bits &lhs, const mode_t &rhs) |
Bitwise-OR of specifed mode bits. More... | |
stat::mode_bits | operator& (const stat::mode_bits &lhs, const stat::mode_bits &rhs) |
Bitwise-AND of specifed mode bits. More... | |
stat::mode_bits | operator& (const mode_t &lhs, const stat::mode_bits &rhs) |
Bitwise-AND of specifed mode bits. More... | |
stat::mode_bits | operator& (const stat::mode_bits &lhs, const mode_t &rhs) |
Bitwise-AND of specifed mode bits. More... | |
Variables | |
const int | CTTY_FILENO |
CTTY fd. More... | |
fdstream | cctty |
CTTY stream. More... | |
debug_level | debug_log_level = DEBUG_NONE |
The debugging level in use. | |
nostream | cnull |
A null ostream. | |
Debian source builder components.
enum sbuild::debug_level |
|
inline |
Get a translated message.
This function is a shorthand for gettext, which also marks up the string for translation.
message | the message to translate. |
References gettext().
Referenced by sbuild::format_detail::add(), sbuild::chroot::config::add(), sbuild::auth::deny::authenticate(), sbuild::auth::pam::authenticate(), sbuild::keyfile::check_keys(), sbuild::keyfile::check_priority(), sbuild::chroot::facet::session_clonable::clone_session(), sbuild::chroot::facet::source_clonable::clone_source(), sbuild::date_base::get_date_format(), sbuild::chroot::facet::personality::get_details(), sbuild::chroot::facet::directory_base::get_details(), sbuild::chroot::facet::userdata::get_details(), sbuild::chroot::facet::block_device_base::get_details(), sbuild::chroot::facet::loopback::get_details(), sbuild::chroot::facet::session::get_details(), sbuild::chroot::facet::mountable::get_details(), sbuild::chroot::facet::lvm_snapshot::get_details(), sbuild::chroot::facet::unshare::get_details(), sbuild::chroot::facet::file::get_details(), sbuild::chroot::facet::btrfs_snapshot::get_details(), sbuild::chroot::facet::source_clonable::get_details(), sbuild::chroot::facet::fsunion::get_details(), sbuild::chroot::chroot::get_details(), sbuild::session::get_login_command(), sbuild::personality::get_personalities(), sbuild::format_detail::get_title(), sbuild::session::get_user_command(), log_ctty_error(), log_ctty_info(), log_ctty_warning(), log_debug(), log_error(), log_info(), log_unknown_exception_error(), log_warning(), sbuild::chroot::config::print_chroot_list_simple(), sbuild::chroot::chroot::print_details(), sbuild::session::restore_termios(), sbuild::run_parts::run_child(), sbuild::session::run_child(), sbuild::session::run_chroot(), sbuild::session::save_termios(), sbuild::chroot::chroot::set_aliases(), sbuild::chroot::facet::userdata::set_data(), sbuild::chroot::chroot::set_name(), sbuild::chroot::facet::userdata::set_system_data(), sbuild::session::setup_chroot(), sbuild::chroot::facet::userdata::setup_env(), and sbuild::session::wait_for_child().
std::string sbuild::basename | ( | std::string | name) |
Strip the directory path from a filename.
This is similar to basename(3).
name | the filename to strip of its path. |
Referenced by sbuild::session::get_login_command(), and sbuild::chroot::facet::lvm_snapshot::setup_env().
std::string sbuild::dirname | ( | std::string | name) |
Strip the fileame from a pathname.
This is similar to dirname(3).
name | the path to strip of its filename. |
Referenced by sbuild::chroot::facet::lvm_snapshot::chroot_session_setup().
int sbuild::exec | ( | const std::string & | file, |
const string_list & | command, | ||
const environment & | env | ||
) |
execve wrapper.
Run the command specified by file (an absolute pathname), using command and env as the argv and environment, respectively.
file | the program to execute. |
command | the arguments to pass to the executable. |
env | the environment. |
References sbuild::environment::get_strv(), string_list_to_strv(), and strv_delete().
Referenced by sbuild::run_parts::run_child(), and sbuild::session::run_child().
std::string sbuild::find_program_in_path | ( | const std::string & | program, |
const std::string & | path, | ||
const std::string & | prefix | ||
) |
Find a program in the PATH search path.
program | the program to search for. |
path | the search path; typically the value of $PATH. |
prefix | a directory prefix the add to the search path. This may be left empty to search the root filesystem. |
References sbuild::stat::is_regular(), and split_string().
Referenced by sbuild::session::get_user_command(), and sbuild::session::run_child().
std::string sbuild::getcwd | ( | ) |
Get the current working directory.
If it can't be found, fall back to root.
Referenced by sbuild::session::run_child().
|
inline |
Get a translated message.
message | the message to translate. |
Referenced by _(), sbuild::error< T >::get_error(), and gettext().
|
inline |
Get a translated message.
message | the message to translate. |
References gettext().
|
inline |
Get a message with no translation.
message | the message to not translate. |
Referenced by N_().
bool sbuild::is_absname | ( | const std::string & | name) |
Check if a pathname is absolute.
name | the path to check. |
Referenced by sbuild::chroot::facet::block_device_base::set_device(), sbuild::chroot::facet::directory_base::set_directory(), sbuild::chroot::facet::loopback::set_filename(), sbuild::chroot::facet::file::set_filename(), sbuild::chroot::facet::file::set_location(), sbuild::chroot::facet::mountable::set_location(), sbuild::chroot::chroot::set_mount_location(), sbuild::chroot::facet::lvm_snapshot::set_snapshot_device(), sbuild::chroot::facet::btrfs_snapshot::set_snapshot_directory(), sbuild::chroot::facet::btrfs_snapshot::set_snapshot_name(), sbuild::chroot::facet::btrfs_snapshot::set_source_subvolume(), sbuild::chroot::facet::fsunion::set_union_overlay_directory(), and sbuild::chroot::facet::fsunion::set_union_underlay_directory().
bool sbuild::is_valid_filename | ( | const std::string & | name, |
bool | lsb_mode = true |
||
) |
Check if a filename matches the allowed pattern(s).
This will not match dotfiles, backup files, dpkg configuration backup files, etc. This uses the same rules as run-parts(8).
name | the filename to check. |
lsb_mode | true to use LSB mode, otherwise false. |
References regex_search().
Referenced by sbuild::run_parts::run_parts().
bool sbuild::is_valid_sessionname | ( | const std::string & | name) |
Check if a filename matches the allowed pattern(s).
This will not match dotfiles, backup files, dpkg configuration backup files, etc.
name | the filename to check. |
References regex_search().
Referenced by sbuild::chroot::config::add_config_directory(), sbuild::chroot::chroot::set_aliases(), and sbuild::chroot::chroot::set_name().
std::ostream & sbuild::log_ctty_error | ( | ) |
Log an error message to the Controlling TTY.
Referenced by sbuild::auth::pam_conv_tty::conversation(), and log_ctty_exception_error().
void sbuild::log_ctty_exception_error | ( | const std::exception & | e) |
Log an exception as an error to the Controlling TTY.
e | the exception to log. |
References log_ctty_error().
void sbuild::log_ctty_exception_warning | ( | const std::exception & | e) |
Log an exception as a warning to the Controlling TTY.
e | the exception to log. |
References log_ctty_warning().
Referenced by sbuild::auth::pam_conv_tty::get_delay().
std::ostream & sbuild::log_ctty_info | ( | ) |
Log an informational message to the Controlling TTY.
Referenced by sbuild::auth::pam_conv_tty::conversation().
std::ostream & sbuild::log_ctty_warning | ( | ) |
Log a warning message to the Controlling TTY.
Referenced by log_ctty_exception_warning().
std::ostream & sbuild::log_debug | ( | debug_level | level) |
Log a debug message.
level | the debug level of the message being logged. |
References _(), cnull, and debug_log_level.
Referenced by sbuild::auth::pam::account(), sbuild::format_detail::add(), sbuild::environment::add(), sbuild::chroot::config::add_config_directory(), sbuild::chroot::config::add_config_file(), sbuild::auth::deny::authenticate(), sbuild::auth::pam::authenticate(), sbuild::chroot::facet::session_clonable::clone_session(), sbuild::auth::pam::close_session(), sbuild::auth::pam_conv_tty::conversation(), sbuild::auth::pam::cred_delete(), sbuild::auth::pam::cred_establish(), sbuild::chroot::facet::unshare::do_unshare(), sbuild::chroot::config::find_alias(), sbuild::chroot::config::find_chroot_in_namespace(), sbuild::environment::get(), sbuild::session::get_chroot_membership(), sbuild::session::get_login_command(), sbuild::session::get_user_command(), sbuild::keyfile::get_value(), sbuild::chroot::chroot::get_verbosity_string(), sbuild::session::is_group_member(), sbuild::chroot::config::load_data(), sbuild::chroot::config::load_keyfile(), sbuild::chroot::config::lookup_alias(), sbuild::auth::pam::open_session(), parse_value(), sbuild::run_parts::run_child(), sbuild::session::run_child(), sbuild::session::run_impl(), sbuild::auth::auth::set_ruser(), sbuild::auth::auth::set_user(), sbuild::session::setup_chroot(), sbuild::auth::pam::setupenv(), sbuild::auth::deny::start(), sbuild::auth::pam::start(), and sbuild::auth::pam::stop().
std::ostream & sbuild::log_error | ( | ) |
Log an error message.
References _().
Referenced by log_exception_error(), log_unknown_exception_error(), sbuild::run_parts::run_child(), sbuild::session::run_chroot(), and sbuild::session::setup_chroot().
void sbuild::log_exception_error | ( | const std::exception & | e) |
Log an exception as an error.
e | the exception to log. |
References log_error().
Referenced by sbuild::run_parts::run_child(), sbuild::session::run_chroot(), sbuild::session::setup_chroot(), sbuild::session::wait_for_child(), sbuild::auth::auth::~auth(), sbuild::auth::deny::~deny(), and sbuild::auth::pam::~pam().
void sbuild::log_exception_warning | ( | const std::exception & | e) |
Log an exception as a warning.
e | the exception to log. |
References log_warning().
Referenced by sbuild::chroot::config::add(), sbuild::chroot::config::add_config_directory(), sbuild::keyfile::check_keys(), sbuild::keyfile::check_priority(), sbuild::keyfile::get_list_value(), sbuild::keyfile::get_set_value(), sbuild::session::get_shell(), sbuild::keyfile::get_value(), sbuild::session::run_child(), sbuild::chroot::facet::userdata::set_keyfile(), and sbuild::file_lock::~file_lock().
std::ostream & sbuild::log_info | ( | ) |
Log an informational message.
References _().
Referenced by sbuild::session::get_login_command(), sbuild::session::get_user_command(), and sbuild::run_parts::run_child().
std::ostream & sbuild::log_warning | ( | ) |
Log a warning message.
References _().
Referenced by sbuild::environment::get(), log_exception_warning(), sbuild::session::restore_termios(), and sbuild::session::save_termios().
|
inline |
Get a message with no translation.
This macro is a shorthand for gettext_noop, which also marks up the string for translation.
message | the message to not translate. |
References gettext_noop().
std::string sbuild::narrow_string | ( | const std::wstring & | str, |
std::locale | locale | ||
) |
Narrow a string.
The wide string is converted into a narrow string. Note that any conversion error will cause the string to be clipped at the point of error.
str | the string to narrow. |
locale | the locale to use for the conversion. |
std::string sbuild::normalname | ( | std::string | name) |
Normalise a pathname.
This strips all trailing separators, and duplicate separators within a path.
name | the path to normalise. |
Referenced by sbuild::chroot::chroot::setup_env().
|
inline |
Bitwise-AND of specifed mode bits.
lhs | mode bits |
rhs | mode bits |
|
inline |
Bitwise-AND of specifed mode bits.
lhs | mode bits |
rhs | mode bits |
|
inline |
Bitwise-AND of specifed mode bits.
lhs | mode bits |
rhs | mode bits |
sbuild::keyfile sbuild::operator+ | ( | const sbuild::keyfile & | lhs, |
const sbuild::keyfile & | rhs | ||
) |
lhs | the keyfile to add to. |
rhs | the values to add. |
mntstream & sbuild::operator>> | ( | mntstream & | stream, |
mntstream::mntentry & | entry | ||
) |
The overloaded extraction operator.
This is used to pull mntentries from a mntstream.
stream | the mntstream to get input from. |
entry | the mntentry to set. |
References sbuild::mntstream::data, sbuild::mntstream::eof_status, and sbuild::mntstream::read().
|
inline |
Bitwise-OR of specifed mode bits.
lhs | mode bits |
rhs | mode bits |
|
inline |
Bitwise-OR of specifed mode bits.
lhs | mode bits |
rhs | mode bits |
|
inline |
Bitwise-OR of specifed mode bits.
lhs | mode bits |
rhs | mode bits |
void sbuild::parse_value | ( | const std::string & | value, |
bool & | parsed_value | ||
) |
Parse a boolean value.
value | the value to parse. |
parsed_value | the variable to store the parsed value. |
References BAD_VALUE, DEBUG_NOTICE, and log_debug().
Referenced by sbuild::environment::get(), sbuild::keyfile::get_list_value(), sbuild::keyfile::get_set_value(), and sbuild::keyfile::get_value().
void sbuild::parse_value | ( | const std::string & | value, |
std::string & | parsed_value | ||
) |
Parse a string value.
value | the value to parse. |
parsed_value | the variable to store the parsed value. |
References DEBUG_NOTICE, and log_debug().
void sbuild::parse_value | ( | const std::string & | value, |
T & | parsed_value | ||
) |
Parse a value of type T.
value | the value to parse. |
parsed_value | the variable to store the parsed value. |
References BAD_VALUE, DEBUG_NOTICE, and log_debug().
std::vector<S> sbuild::split_string | ( | S const & | value, |
S const & | separator | ||
) |
Split a string into a string_list.
The string is split using separator as a delimiter. Note that only non-zero-length strings are preserved, so multiple concatenated delimiters or delimiters at the beginning and end of the string will not result in empty strings in the list.
value | the string to split. |
separator | the delimiting character or characters. |
std::vector< std::string > sbuild::split_string | ( | const std::string & | value, |
const std::string & | separator | ||
) |
Split a string into a string_list.
The string is split using separator as a delimiter. Multiple delimiters, or delimiters at the start of the start or end of the string will be discarded and not result in empty strings being returned (see split_string_strict).
value | the string to split. |
separator | the delimiting character or characters. |
Referenced by find_program_in_path(), sbuild::keyfile::get_list_value(), and sbuild::keyfile::get_set_value().
std::vector<S> sbuild::split_string_strict | ( | S const & | value, |
S const & | separator | ||
) |
Split a string into a string_list.
The string is split using separator as a delimiter. All delimiters are used as string separators, so delimiters at the beginning or end of a string, or which are concatenated together, will result in empty strings in the string list (use split_string to avoid this).
value | the string to split. |
separator | the delimiting character or characters. |
std::vector< std::string > sbuild::split_string_strict | ( | const std::string & | value, |
const std::string & | separator | ||
) |
Split a string into a string_list.
The string is split using separator as a delimiter. All delimiters are used as string separators, so delimiters at the beginning or end of a string, or which are concatenated together, will result in empty strings in the string list.
value | the string to split. |
separator | the delimiting character or characters. |
Referenced by sbuild::run_parts::run_child().
std::string sbuild::string_list_to_string | ( | const string_list & | list, |
const std::string & | separator | ||
) |
Convert a string_list into a string.
The strings are concatenated using separator as a delimiter.
list | the list to concatenate. |
separator | the delimiting character. |
Referenced by sbuild::format_detail::add(), sbuild::session::get_user_command(), sbuild::run_parts::run_child(), sbuild::session::run_child(), and sbuild::chroot::config::validate_chroots().
char ** sbuild::string_list_to_strv | ( | const string_list & | str) |
Create a string vector from a string_list.
The strings in the vector, as well as the vector itself, are allocated with new, and should be freed as a whole with strv_delete.
str | the string_list to use. |
Referenced by exec().
void sbuild::strv_delete | ( | char ** | strv) |
Delete a string vector.
The strings in the vector, as well as the vector itself, must have been previously allocated with new, for example sbuild::environment::get_strv.
strv | the string vector to delete. |
Referenced by exec().
std::string sbuild::unique_identifier | ( | ) |
Get a unique string for use as a session identifier.
Referenced by sbuild::session::run_impl().
std::wstring sbuild::widen_string | ( | const std::string & | str, |
std::locale | locale | ||
) |
Widen a string.
The narrow string is converted into a wide string. Note that any conversion error will cause the string to be clipped at the point of error.
str | the string to widen. |
locale | the locale to use for the conversion. |
fdstream sbuild::cctty |
CTTY stream.
A stream to the Controlling TTY, or standard input if not available.
Referenced by log_ctty_error(), log_ctty_info(), log_ctty_warning(), and sbuild::auth::pam_conv_tty::read_string().
const int sbuild::CTTY_FILENO |
CTTY fd.
The fd number of the Controlling TTY, or -1 if not available.
Referenced by sbuild::auth::pam_conv_tty::read_string(), sbuild::session::restore_termios(), and sbuild::session::save_termios().