sbuild::Config Class Reference

Chroot configuration. More...

#include <sbuild-config.h>

List of all members.

Public Types

typedef std::vector< Chroot::chroot_ptrchroot_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::chroot_ptr
chroot_map
 A map between a chroot name and a Chroot object.
typedef runtime_error_custom<
Config
error
 Exception type.

Public Member Functions

 Config ()
 The constructor.
 Config (std::string const &file, bool active)
 The constructor.
virtual ~Config ()
 The destructor.
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.
chroot_list get_chroots () const
 Get a list of available chroots.
const Chroot::chroot_ptr find_chroot (std::string const &name) const
 Find a chroot by its name.
const Chroot::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_info (string_list const &chroots, std::ostream &stream) const
 Print information about the specified chroots to the specified stream.
string_list validate_chroots (string_list const &chroots) const
 Check that all the chroots specified exist.

Private Member Functions

void check_security (int fd) const
 Check the permissions and ownership of a configuration file.
void load (std::string const &file, bool active)
 Load a configuration file.

Private Attributes

chroot_map chroots
 A list of chroots (name->chroot mapping).
string_map aliases
 A list of aliases (alias->name mapping).


Detailed Description

Chroot configuration.

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.


Member Typedef Documentation

typedef std::vector<Chroot::chroot_ptr> sbuild::Config::chroot_list
 

A list of chroots.

typedef std::map<std::string, Chroot::chroot_ptr> sbuild::Config::chroot_map
 

A map between a chroot name and a Chroot object.

typedef runtime_error_custom<Config> sbuild::Config::error
 

Exception type.

typedef std::map<std::string, std::string> sbuild::Config::string_map
 

A map between key-value string pairs.


Constructor & Destructor Documentation

Config::Config  ) 
 

The constructor.

Config::Config std::string const &  file,
bool  active
 

The constructor.

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

Config::~Config  )  [virtual]
 

The destructor.


Member Function Documentation

void Config::add_config_directory std::string const &  dir,
bool  active
 

Add a configuration directory.

The configuration files in the directory specified will all be loaded.

Parameters:
dir the directory containing the files to load.
active true if the chroots in the configuration file are active sessions, otherwise false.

void Config::add_config_file std::string const &  file,
bool  active
 

Add a configuration file.

The configuration file specified will be loaded.

Parameters:
file the file to load.
active true if the chroots in the configuration file are active sessions, otherwise false.

void Config::check_security int  fd  )  const [private]
 

Check the permissions and ownership of a configuration file.

The file must be owned by root, not writable by other, and be a regular file.

An error will be thrown on failure.

Parameters:
fd the file descriptor to check.

const Chroot::chroot_ptr Config::find_alias std::string const &  name  )  const
 

Find a chroot by its name or an alias.

Parameters:
name the chroot name or alias.
Returns:
the chroot if found, otherwise 0.

const Chroot::chroot_ptr Config::find_chroot std::string const &  name  )  const
 

Find a chroot by its name.

Parameters:
name the chroot name
Returns:
the chroot if found, otherwise 0.

string_list Config::get_chroot_list  )  const
 

Get the names (including aliases) of all the available chroots, sorted in alphabetical order.

Returns:
the list. The list will be empty if no chroots are available.

Config::chroot_list Config::get_chroots  )  const
 

Get a list of available chroots.

Returns:
a list of available chroots. The list will be empty if no chroots are available.

void Config::load std::string const &  file,
bool  active
[private]
 

Load a configuration file.

If there are problems with the configuration file, the program will be aborted immediately.

Parameters:
file the file to load.
active true if the chroots in the configuration file are active sessions, otherwise false.

void Config::print_chroot_info string_list const &  chroots,
std::ostream &  stream
const
 

Print information about the specified chroots to the specified stream.

Parameters:
chroots a list of chroots to print.
stream the stream to output to.

void Config::print_chroot_list std::ostream &  stream  )  const
 

Print all the available chroots to the specified stream.

Parameters:
stream the stream to output to.

string_list Config::validate_chroots string_list const &  chroots  )  const
 

Check that all the chroots specified exist.

Parameters:
chroots a list of chroots to validate.
Returns:
a list of invalid chroots. The list will be empty if all chroots are valid.


Member Data Documentation

string_map sbuild::Config::aliases [private]
 

A list of aliases (alias->name mapping).

chroot_map sbuild::Config::chroots [private]
 

A list of chroots (name->chroot mapping).


The documentation for this class was generated from the following files:
Generated on Mon Jan 30 13:23:57 2006 for schroot by  doxygen 1.4.6