Classes | Typedefs | Enumerations | Functions | Variables

sbuild Namespace Reference

Classes

class  auth_null
 Null Authentication handler. More...
class  auth_pam_conv_tty
 Authentication conversation handler for terminal devices. More...
class  auth_pam_conv
 Authentication conversation handler interface. More...
class  auth_pam_message
 Authentication messages. More...
class  auth_pam
 Authentication handler. More...
class  auth
 Authentication handler. More...
class  basic_keyfile_parser
class  basic_keyfile
 Configuration file parser. More...
class  chroot_block_device_base
 A base class for block-device chroots. More...
class  chroot_block_device
 A chroot stored on an unmounted block device. More...
class  chroot_btrfs_snapshot
 A chroot stored on an BTRFS logical volume (LV). More...
class  chroot_config
 Chroot configuration. More...
class  chroot_directory_base
 A base class for chroots located in a local directory. More...
class  chroot_directory
 A chroot located in the filesystem. More...
class  chroot_facet_mountable
 Chroot support for mountable devices and filesystems. More...
class  chroot_facet_personality
 Chroot support for kernel personalities (execution domains). More...
class  chroot_facet_session_clonable
 Chroot support for creation of sessions. More...
class  chroot_facet_session
 Chroot support for sessions. More...
class  chroot_facet_source_clonable
 Chroot support for creation of source chroots. More...
class  chroot_facet_source
 Chroot support for clonable sources. More...
class  chroot_facet_union
 Chroot support for filesystem union based sessions. More...
class  chroot_facet
 Common chroot data. More...
class  chroot_file
 A chroot stored in a file archive (tar or zip). More...
class  chroot_loopback
 A chroot stored in a file for loopback mounting. More...
class  chroot_lvm_snapshot
 A chroot stored on an LVM logical volume (LV). More...
class  chroot_plain
 A chroot located in the filesystem (scripts disabled). More...
class  chroot
 Common chroot data. More...
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  format_detail
 Format names and values for output. More...
class  keyfile_base
 Base class for key-value configuration file formats. More...
struct  keyfile_traits
 Traits class for an INI-style configuration file. More...
class  keyfile_parser
class  lock
 Advisory locking. More...
class  file_lock
 File lock. More...
class  device_lock
 Device lock. More...
class  mntstream
 Access mounts. More...
class  basic_nbuf
 Null stream buffer. More...
class  basic_nostream
 Null output stream. More...
class  null
 Null. 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
typedef basic_keyfile
< keyfile_traits,
keyfile_parser< keyfile_traits > > 
keyfile
 Configuration file parser.
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
typedef std::vector< std::string > string_list
 A string vector.
typedef std::set< std::string > string_set
 A string set.

Enumerations

enum  ctty_error_code { CTTY_CLOEXEC, CTTY_DUP }
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 }

Functions

chroot::session_flags operator| (chroot::session_flags const &lhs, chroot::session_flags const &rhs)
 Bitwise-OR of specifed session properties.
chroot::session_flags operator& (chroot::session_flags const &lhs, chroot::session_flags const &rhs)
 Bitwise-AND of specifed session properties.
const char * gettext (const char *message)
 Get a translated message.
const char * _ (const char *message)
 Get a translated message.
const char * gettext_noop (const char *message)
 Get a message with no translation.
const char * N_ (const char *message)
 Get a message with no translation.
std::ostream & log_info ()
 Log an informational message.
std::ostream & log_warning ()
 Log a warning message.
std::ostream & log_error ()
 Log an error message.
std::ostream & log_debug (debug_level level)
 Log a debug message.
std::ostream & log_ctty_info ()
 Log an informational message to the Controlling TTY.
std::ostream & log_ctty_warning ()
 Log a warning message to the Controlling TTY.
std::ostream & log_ctty_error ()
 Log an error message to the Controlling TTY.
void log_exception_warning (std::exception const &e)
 Log an exception as a warning.
void log_exception_error (std::exception const &e)
 Log an exception as an error.
void log_ctty_exception_warning (std::exception const &e)
 Log an exception as a warning to the Controlling TTY.
void log_ctty_exception_error (std::exception const &e)
 Log an exception as an error to the Controlling TTY.
void log_unknown_exception_error ()
 Log an unknown exception as an error.
mntstreamoperator>> (mntstream &stream, mntstream::mntentry &entry)
 The overloaded extraction operator.
void parse_value (std::string const &value, bool &parsed_value)
 Parse a boolean value.
void parse_value (std::string const &value, std::string &parsed_value)
 Parse a string value.
template<typename T >
void parse_value (std::string const &value, T &parsed_value)
 Parse a value of type T.
std::string basename (std::string name)
 Strip the directory path from a filename.
std::string dirname (std::string name)
 Strip the fileame from a pathname.
std::string normalname (std::string name)
 Normalise a pathname.
bool is_absname (std::string const &name)
 Check if a pathname is absolute.
bool is_valid_filename (std::string const &name, bool lsb_mode=true)
 Check if a filename matches the allowed pattern(s).
std::string getcwd ()
 Get the current working directory.
std::string unique_identifier ()
 Get a unique string for use as a session identifier.
std::string string_list_to_string (string_list const &list, std::string const &separator)
 Convert a string_list into a string.
template<typename S >
std::vector< S > split_string (S const &value, S const &separator)
 Split a string into a string_list.
std::vector< std::string > split_string (std::string const &value, std::string const &separator)
template<typename S >
std::vector< S > split_string_strict (S const &value, S const &separator)
 Split a string into a string_list.
std::vector< std::string > split_string_strict (std::string const &value, std::string const &separator)
std::wstring widen_string (std::string const &str, std::locale locale)
 Widen a string.
std::string narrow_string (std::wstring const &str, std::locale locale)
 Narrow a string.
std::string find_program_in_path (std::string const &program, std::string const &path, std::string const &prefix)
 Find a program in the PATH search path.
char ** string_list_to_strv (string_list const &str)
 Create a string vector from a string_list.
void strv_delete (char **strv)
 Delete a string vector.
int exec (std::string const &file, string_list const &command, environment const &env)
 execve wrapper.
stat::mode_bits operator| (stat::mode_bits const &lhs, stat::mode_bits const &rhs)
 Bitwise-OR of specifed mode bits.
stat::mode_bits operator| (mode_t const &lhs, stat::mode_bits const &rhs)
 Bitwise-OR of specifed mode bits.
stat::mode_bits operator| (stat::mode_bits const &lhs, mode_t const &rhs)
 Bitwise-OR of specifed mode bits.
stat::mode_bits operator& (stat::mode_bits const &lhs, stat::mode_bits const &rhs)
 Bitwise-AND of specifed mode bits.
stat::mode_bits operator& (mode_t const &lhs, stat::mode_bits const &rhs)
 Bitwise-AND of specifed mode bits.
stat::mode_bits operator& (stat::mode_bits const &lhs, mode_t const &rhs)
 Bitwise-AND of specifed mode bits.

Variables

const int CTTY_FILENO
 CTTY fd.
std::iostream cctty
 CTTY stream.
debug_level debug_log_level = sbuild::DEBUG_NONE
 The debugging level in use.
nostream cnull
 A null ostream.

Typedef Documentation

Configuration file parser.

This class loads an INI-style configuration file from a file or stream. The format is documented in schroot.conf(5).

A null ostream.

typedef std::vector<std::string> sbuild::string_list

A string vector.

typedef std::set<std::string> sbuild::string_set

A string set.

A wide null ostream.


Enumeration Type Documentation

Enumerator:
CTTY_CLOEXEC 

The controlling terminal close-on-execute flag could not be set.

CTTY_DUP 

The controlling terminal file descriptor could not be duplicated.

Debugging level.

Enumerator:
DEBUG_NONE 

No debugging.

DEBUG_NOTICE 

Notification messages.

DEBUG_INFO 

Informational messages.

DEBUG_WARNING 

Warning messages.

DEBUG_CRITICAL 

Critical messages.

Enumerator:
BAD_VALUE 

The value could not be parsed.


Function Documentation

const char* sbuild::_ ( const char *  message  )  [inline]

Get a translated message.

This function is a shorthand for gettext, which also marks up the string for translation.

Parameters:
message the message to translate.
Returns:
the translated message.

References gettext().

Referenced by sbuild::format_detail::add(), sbuild::chroot_config::add(), sbuild::auth_pam::authenticate(), sbuild::auth_null::authenticate(), sbuild::basic_keyfile< K, P >::check_keys(), sbuild::basic_keyfile< K, P >::check_priority(), sbuild::chroot_facet_session_clonable::clone_session_setup(), sbuild::chroot_facet_source_clonable::clone_source_setup(), sbuild::date_base::get_date_format(), sbuild::chroot::get_details(), sbuild::chroot_lvm_snapshot::get_details(), sbuild::chroot_loopback::get_details(), sbuild::chroot_file::get_details(), sbuild::chroot_facet_union::get_details(), sbuild::chroot_facet_source_clonable::get_details(), sbuild::chroot_facet_session::get_details(), sbuild::chroot_facet_personality::get_details(), sbuild::chroot_facet_mountable::get_details(), sbuild::chroot_directory_base::get_details(), sbuild::chroot_btrfs_snapshot::get_details(), sbuild::chroot_block_device_base::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::null::null_output(), sbuild::chroot_config::print_chroot_list_simple(), sbuild::chroot::print_details(), sbuild::session::restore_termios(), sbuild::run_parts::run_child(), sbuild::session::run_chroot(), sbuild::session::save_termios(), sbuild::session::setup_chroot(), 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).

Parameters:
name the filename to strip of its path.
Returns:
the base name.

Referenced by sbuild::session::get_login_command(), and sbuild::chroot_lvm_snapshot::setup_env().

std::string sbuild::dirname ( std::string  name  ) 

Strip the fileame from a pathname.

This is similar to dirname(3).

Parameters:
name the path to strip of its filename.
Returns:
the directory name.

Referenced by sbuild::chroot_facet_session_clonable::clone_session_setup().

int sbuild::exec ( std::string const &  file,
string_list const &  command,
environment const &  env 
)

execve wrapper.

Run the command specified by file (an absolute pathname), using command and env as the argv and environment, respectively.

Parameters:
file the program to execute.
command the arguments to pass to the executable.
env the environment.
Returns:
the return value of the execve system call on failure.

References sbuild::environment::get_strv(), string_list_to_strv(), and strv_delete().

Referenced by sbuild::session::run_child(), and sbuild::run_parts::run_child().

std::string sbuild::find_program_in_path ( std::string const &  program,
std::string const &  path,
std::string const &  prefix 
)

Find a program in the PATH search path.

Parameters:
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.
Returns:
the absolute path of the program, or an empty string if the program could not be found.

References 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.

Returns:
the current working directory.

Referenced by sbuild::session::run_child().

const char* sbuild::gettext ( const char *  message  )  [inline]

Get a translated message.

Parameters:
message the message to translate.
Returns:
the translated message.

Referenced by _(), and sbuild::error< T >::get_error().

const char* sbuild::gettext_noop ( const char *  message  )  [inline]

Get a message with no translation.

Parameters:
message the message to not translate.
Returns:
the message.

Referenced by N_().

bool sbuild::is_absname ( std::string const &  name  ) 
bool sbuild::is_valid_filename ( std::string const &  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).

Parameters:
name the filename to check.
lsb_mode true to use LSB mode, otherwise false.
Returns:
true if it matches, false if not.

Referenced by sbuild::chroot_config::add_config_directory(), and sbuild::run_parts::run_parts().

std::ostream & sbuild::log_ctty_error (  ) 

Log an error message to the Controlling TTY.

Returns:
an ostream.

References _(), and cctty.

Referenced by sbuild::auth_pam_conv_tty::conversation(), and log_ctty_exception_error().

void sbuild::log_ctty_exception_error ( std::exception const &  e  ) 

Log an exception as an error to the Controlling TTY.

Parameters:
e the exception to log.

References log_ctty_error().

void sbuild::log_ctty_exception_warning ( std::exception const &  e  ) 

Log an exception as a warning to the Controlling TTY.

Parameters:
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.

Returns:
an ostream.

References _(), and cctty.

Referenced by sbuild::auth_pam_conv_tty::conversation().

std::ostream & sbuild::log_ctty_warning (  ) 

Log a warning message to the Controlling TTY.

Returns:
an ostream.

References _(), and cctty.

Referenced by log_ctty_exception_warning().

std::ostream & sbuild::log_debug ( sbuild::debug_level  level  ) 
std::ostream & sbuild::log_error (  ) 
void sbuild::log_exception_error ( std::exception const &  e  ) 
void sbuild::log_exception_warning ( std::exception const &  e  ) 
std::ostream & sbuild::log_info (  ) 

Log an informational message.

Returns:
an ostream.

References _().

Referenced by sbuild::session::get_login_command(), sbuild::session::get_user_command(), and sbuild::run_parts::run_child().

void sbuild::log_unknown_exception_error (  ) 

Log an unknown exception as an error.

References _(), and log_error().

std::ostream & sbuild::log_warning (  ) 

Log a warning message.

Returns:
an ostream.

References _().

Referenced by sbuild::environment::get(), log_exception_warning(), sbuild::session::restore_termios(), and sbuild::session::save_termios().

const char* sbuild::N_ ( const char *  message  )  [inline]

Get a message with no translation.

This macro is a shorthand for gettext_noop, which also marks up the string for translation.

Parameters:
message the message to not translate.
Returns:
the message.

References gettext_noop().

std::string sbuild::narrow_string ( std::wstring const &  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.

Parameters:
str the string to narrow.
locale the locale to use for the conversion.
Returns:
a narrow string.
std::string sbuild::normalname ( std::string  name  ) 

Normalise a pathname.

This strips all trailing separators, and duplicate separators within a path.

Parameters:
name the path to normalise.
Returns:
the normalised name.

Referenced by sbuild::chroot::setup_env().

stat::mode_bits sbuild::operator& ( stat::mode_bits const &  lhs,
mode_t const &  rhs 
) [inline]

Bitwise-AND of specifed mode bits.

Parameters:
lhs mode bits
rhs mode bits
Returns:
result of AND.
stat::mode_bits sbuild::operator& ( stat::mode_bits const &  lhs,
stat::mode_bits const &  rhs 
) [inline]

Bitwise-AND of specifed mode bits.

Parameters:
lhs mode bits
rhs mode bits
Returns:
result of AND.
chroot::session_flags sbuild::operator& ( chroot::session_flags const &  lhs,
chroot::session_flags const &  rhs 
) [inline]

Bitwise-AND of specifed session properties.

Parameters:
lhs session properties
rhs session properties
Returns:
result of AND.
stat::mode_bits sbuild::operator& ( mode_t const &  lhs,
stat::mode_bits const &  rhs 
) [inline]

Bitwise-AND of specifed mode bits.

Parameters:
lhs mode bits
rhs mode bits
Returns:
result of AND.
mntstream & sbuild::operator>> ( mntstream stream,
mntstream::mntentry entry 
)

The overloaded extraction operator.

This is used to pull mntentries from a mntstream.

Parameters:
stream the mntstream to get input from.
entry the mntentry to set.
Returns:
the mntstream.

References sbuild::mntstream::data, sbuild::mntstream::eof_status, and sbuild::mntstream::read().

chroot::session_flags sbuild::operator| ( chroot::session_flags const &  lhs,
chroot::session_flags const &  rhs 
) [inline]

Bitwise-OR of specifed session properties.

Parameters:
lhs session properties
rhs session properties
Returns:
result of OR.
stat::mode_bits sbuild::operator| ( mode_t const &  lhs,
stat::mode_bits const &  rhs 
) [inline]

Bitwise-OR of specifed mode bits.

Parameters:
lhs mode bits
rhs mode bits
Returns:
result of OR.
stat::mode_bits sbuild::operator| ( stat::mode_bits const &  lhs,
stat::mode_bits const &  rhs 
) [inline]

Bitwise-OR of specifed mode bits.

Parameters:
lhs mode bits
rhs mode bits
Returns:
result of OR.
stat::mode_bits sbuild::operator| ( stat::mode_bits const &  lhs,
mode_t const &  rhs 
) [inline]

Bitwise-OR of specifed mode bits.

Parameters:
lhs mode bits
rhs mode bits
Returns:
result of OR.
void sbuild::parse_value ( std::string const &  value,
std::string &  parsed_value 
)

Parse a string value.

Parameters:
value the value to parse.
parsed_value the variable to store the parsed value.
Returns:
true on success, false on failure.

References DEBUG_NOTICE, and log_debug().

void sbuild::parse_value ( std::string const &  value,
bool &  parsed_value 
)

Parse a boolean value.

Parameters:
value the value to parse.
parsed_value the variable to store the parsed value.
Returns:
true on success, false on failure.

References BAD_VALUE, DEBUG_NOTICE, and log_debug().

Referenced by sbuild::environment::get(), sbuild::basic_keyfile< K, P >::get_list_value(), and sbuild::basic_keyfile< K, P >::get_value().

template<typename T >
void sbuild::parse_value ( std::string const &  value,
T &  parsed_value 
)

Parse a value of type T.

Parameters:
value the value to parse.
parsed_value the variable to store the parsed value.
Returns:
true on success, false on failure.

References BAD_VALUE, DEBUG_NOTICE, and log_debug().

string_list sbuild::split_string ( std::string const &  value,
std::string const &  separator 
)
template<typename S >
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.

Parameters:
value the string to split.
separator the delimiting character or characters.
Returns:
a string_list.
Todo:
Provide an alternative that splits the string in place using an iterator interface.

Referenced by find_program_in_path(), and sbuild::basic_keyfile< K, P >::get_list_value().

string_list sbuild::split_string_strict ( std::string const &  value,
std::string const &  separator 
)
template<typename S >
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.

Parameters:
value the string to split.
separator the delimiting character or characters.
Returns:
a string_list.
Todo:
Provide an alternative that splits the string in place using an iterator interface.

Referenced by sbuild::run_parts::run_child().

std::string sbuild::string_list_to_string ( sbuild::string_list const &  list,
std::string const &  separator 
)

Convert a string_list into a string.

The strings are concatenated using separator as a delimiter.

Parameters:
list the list to concatenate.
separator the delimiting character.
Returns:
a string.

Referenced by sbuild::format_detail::add(), sbuild::session::get_user_command(), sbuild::session::run_child(), and sbuild::run_parts::run_child().

char ** sbuild::string_list_to_strv ( string_list const &  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.

Parameters:
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.

Parameters:
strv the string vector to delete.

Referenced by exec().

std::string sbuild::unique_identifier (  ) 

Get a unique string for use as a session identifier.

Depending upon the available facilities, this may be a UUID or a combinatin of the process ID and system time.

Returns:
a session identifier.

Referenced by sbuild::session::run_impl().

std::wstring sbuild::widen_string ( std::string const &  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.

Parameters:
str the string to widen.
locale the locale to use for the conversion.
Returns:
a wide string.

Variable Documentation

std::iostream 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().

A null ostream.

Referenced by log_debug().

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().

The debugging level in use.

Referenced by log_debug().