sbuild  1.6.0
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
sbuild::chroot_facet_userdata Class Reference

Chroot support for extensible user metadata. More...

#include <sbuild-chroot-facet-userdata.h>

+ Inheritance diagram for sbuild::chroot_facet_userdata:
+ Collaboration diagram for sbuild::chroot_facet_userdata:

List of all members.

Public Types

enum  error_code { ENV_AMBIGUOUS, KEY_AMBIGUOUS, KEY_DISALLOWED, KEYNAME_INVALID }
 Error codes. More...
typedef custom_error< error_codeerror
 Exception type.
typedef std::shared_ptr
< chroot_facet_userdata
ptr
 A shared_ptr to a chroot facet object.
typedef std::shared_ptr< const
chroot_facet_userdata
const_ptr
 A shared_ptr to a const chroot facet object.
- Public Types inherited from sbuild::chroot_facet

Public Member Functions

virtual ~chroot_facet_userdata ()
 The destructor.
virtual chroot_facet::ptr clone () const
 Copy the chroot facet.
virtual std::string const & get_name () const
 Get the name of the chroot facet.
virtual void setup_env (chroot const &chroot, environment &env) const
 Set environment.
virtual chroot::session_flags get_session_flags (chroot const &chroot) const
 Get the session flags of the chroot.
virtual void get_details (chroot const &chroot, format_detail &detail) const
 Get detailed information about the chroot for output.
virtual void get_keyfile (chroot const &chroot, keyfile &keyfile) const
 Copy the chroot properties into a keyfile.
virtual void set_keyfile (chroot &chroot, keyfile const &keyfile, string_list &used_keys)
 Set the chroot properties from a keyfile.
string_map const & get_data () const
 Get user data as a map of key-value pairs.
bool get_data (std::string const &key, std::string &value) const
 Get the value of a single user data key.
void set_data (string_map const &data)
 Set user data from a string map.
void set_data (std::string const &key, std::string const &value)
 Set a single key-value pair.
void set_system_data (std::string const &key, std::string const &value)
 Set a single key-value pair.
void remove_data (std::string const &key)
 Remove a single key.
string_set const & get_user_modifiable_keys () const
 Get the set of keys allowed to be modified by a user.
void set_user_modifiable_keys (string_set const &keys)
 Set the set of keys allowed to be modified by a user.
string_set const & get_root_modifiable_keys () const
 Get the set of keys allowed to be modified by root.
void set_root_modifiable_keys (string_set const &keys)
 Set the set of keys allowed to be modified by root.
void set_user_data (string_map const &data)
 Set data for the current user.
void set_root_data (string_map const &data)
 Set data for root.
void set_system_data (string_map const &data)
 Set data without user or root checks.
- Public Member Functions inherited from sbuild::chroot_facet
virtual ~chroot_facet ()
 The destructor.

Static Public Member Functions

static ptr create ()
 Create a chroot facet.

Private Member Functions

 chroot_facet_userdata ()
 The constructor.
void set_data (string_map const &data, string_set const &allowed_keys, bool root)
 Generic function for setting data for any user.

Private Attributes

string_map userdata
 Mapping between user keys and values.
string_set env
 Environment checking.
string_set user_modifiable_keys
 Keys modifiable by users.
string_set root_modifiable_keys
 Keys modifiable by root.

Additional Inherited Members

- Protected Member Functions inherited from sbuild::chroot_facet
 chroot_facet ()
 The constructor.
void set_chroot (chroot &chroot)
 Set containing chroot.
- Protected Attributes inherited from sbuild::chroot_facet
chrootowner
 Chroot owning this facet.

Detailed Description

Chroot support for extensible user metadata.

This facet contains user-specific configuration, both additional keys in schroot.conf, and also set from the command-line.


Member Enumeration Documentation

Error codes.

Enumerator:
ENV_AMBIGUOUS 

Environment variable name is ambiguous.

KEY_AMBIGUOUS 

Configuration key name is ambiguous.

KEY_DISALLOWED 

Configuration key is not allowed to be modified.

KEYNAME_INVALID 

Invalid name for configuration key.


Member Function Documentation

chroot_facet::ptr chroot_facet_userdata::clone ( ) const
virtual

Copy the chroot facet.

This is a virtual copy constructor.

 @returns a shared_ptr to the new copy of the chroot facet.

Implements sbuild::chroot_facet.

References chroot_facet_userdata().

chroot_facet_userdata::ptr chroot_facet_userdata::create ( )
static

Create a chroot facet.

Returns:
a shared_ptr to the new chroot facet.

References chroot_facet_userdata().

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

+ Here is the caller graph for this function:

string_map const & chroot_facet_userdata::get_data ( ) const

Get user data as a map of key-value pairs.

Returns:
a reference to a string map.

References userdata.

bool chroot_facet_userdata::get_data ( std::string const &  key,
std::string &  value 
) const

Get the value of a single user data key.

Parameters:
keythe key to search for.
valuethe string to store the key's value in. Only modified if the key is found.
Returns:
true if found, false if not found.

References userdata.

void chroot_facet_userdata::get_details ( chroot const &  chroot,
format_detail detail 
) const
virtual

Get detailed information about the chroot for output.

Parameters:
chrootthe chroot to use.
detailthe details to output to.

Implements sbuild::chroot_facet.

References sbuild::_(), sbuild::format_detail::add(), root_modifiable_keys, user_modifiable_keys, and userdata.

void chroot_facet_userdata::get_keyfile ( chroot const &  chroot,
keyfile keyfile 
) const
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.

Parameters:
chrootthe chroot to use.
keyfilethe keyfile to use.

Implements sbuild::chroot_facet.

References sbuild::chroot::get_name(), get_root_modifiable_keys(), get_user_modifiable_keys(), sbuild::basic_keyfile< K, P >::set_object_set_value(), sbuild::basic_keyfile< K, P >::set_value(), and userdata.

std::string const & chroot_facet_userdata::get_name ( ) const
virtual

Get the name of the chroot facet.

Returns:
the chroot facet name.

Implements sbuild::chroot_facet.

string_set const & chroot_facet_userdata::get_root_modifiable_keys ( ) const

Get the set of keys allowed to be modified by root.

Returns:
a string set of keys.

References root_modifiable_keys.

Referenced by get_keyfile().

+ Here is the caller graph for this function:

sbuild::chroot::session_flags chroot_facet_userdata::get_session_flags ( chroot const &  chroot) const
virtual

Get the session flags of the chroot.

These determine how the Session controlling the chroot will operate.

Parameters:
chrootthe chroot to use.
Returns:
the session flags.

Implements sbuild::chroot_facet.

References sbuild::chroot::SESSION_NOFLAGS.

string_set const & chroot_facet_userdata::get_user_modifiable_keys ( ) const

Get the set of keys allowed to be modified by a user.

Returns:
a string set of keys.

References user_modifiable_keys.

Referenced by get_keyfile().

+ Here is the caller graph for this function:

void chroot_facet_userdata::remove_data ( std::string const &  key)

Remove a single key.

If present, the specified key is removed.

 @param key the key to remove.

References userdata.

void chroot_facet_userdata::set_data ( string_map const &  data)

Set user data from a string map.

Note that this method does not perform permissions checking.

Parameters:
datathe user data to set.

Referenced by set_data(), set_root_data(), and set_user_data().

+ Here is the caller graph for this function:

void chroot_facet_userdata::set_data ( std::string const &  key,
std::string const &  value 
)

Set a single key-value pair.

Note that this method does not perform permissions checking.

Parameters:
keythe key to set.
valuethe value of the key.

References KEYNAME_INVALID, and set_system_data().

void chroot_facet_userdata::set_data ( string_map const &  data,
string_set const &  allowed_keys,
bool  root 
)
private

Generic function for setting data for any user.

Parameters:
dataa map of key-value pairs.
allowed_keysthe keys which may be used.
rootwhether or not the user is the root user.

References sbuild::_(), KEY_DISALLOWED, set_data(), and sbuild::error_base::set_reason().

void chroot_facet_userdata::set_keyfile ( chroot chroot,
keyfile const &  keyfile,
string_list used_keys 
)
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.

Parameters:
chrootthe chroot to use.
keyfilethe keyfile to get the properties from.
used_keysa list of the keys used will be set.

Implements sbuild::chroot_facet.

References sbuild::chroot::get_name(), sbuild::basic_keyfile< K, P >::get_object_set_value(), sbuild::keyfile_base::PRIORITY_OPTIONAL, set_root_modifiable_keys(), and set_user_modifiable_keys().

void chroot_facet_userdata::set_root_data ( string_map const &  data)

Set data for root.

Only keys set using set_user_modifiable_keys() and set_root_modifiable_keys() are permitted to be set, otherwise an exception will be thrown.

Parameters:
dataa map of key-value pairs.

References root_modifiable_keys, set_data(), and user_modifiable_keys.

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

+ Here is the caller graph for this function:

void chroot_facet_userdata::set_root_modifiable_keys ( string_set const &  keys)

Set the set of keys allowed to be modified by root.

Parameters:
keysa string set of keys.

References root_modifiable_keys.

Referenced by set_keyfile().

+ Here is the caller graph for this function:

void chroot_facet_userdata::set_system_data ( std::string const &  key,
std::string const &  value 
)

Set a single key-value pair.

Note that this method does not perform permissions checking or key name validation.

Parameters:
keythe key to set.
valuethe value of the key.

References sbuild::_(), env, KEY_AMBIGUOUS, sbuild::error_base::set_reason(), and userdata.

Referenced by set_data(), and set_system_data().

+ Here is the caller graph for this function:

void chroot_facet_userdata::set_system_data ( string_map const &  data)

Set data without user or root checks.

Parameters:
string_mapa map of key-value pairs.

References set_system_data().

void chroot_facet_userdata::set_user_data ( string_map const &  data)

Set data for the current user.

Only keys set using set_user_modifiable_keys() are permitted to be set, otherwise an exception will be thrown.

Parameters:
string_mapa map of key-value pairs.

References set_data(), and user_modifiable_keys.

void chroot_facet_userdata::set_user_modifiable_keys ( string_set const &  keys)

Set the set of keys allowed to be modified by a user.

Parameters:
keysa string set of keys.

References user_modifiable_keys.

Referenced by set_keyfile().

+ Here is the caller graph for this function:

void chroot_facet_userdata::setup_env ( chroot const &  chroot,
environment env 
) const
virtual

Set environment.

Set the environment that the setup scripts will see during execution.

Parameters:
chrootthe chroot to use.
envthe environment to set.

Implements sbuild::chroot_facet.

References sbuild::_(), sbuild::environment::add(), ENV_AMBIGUOUS, sbuild::environment::get(), sbuild::error_base::set_reason(), and userdata.


The documentation for this class was generated from the following files: