sbuild  1.7.1
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
sbuild::chroot::facet::userdata Class Reference

Chroot support for extensible user metadata. More...

#include <userdata.h>

+ Inheritance diagram for sbuild::chroot::facet::userdata:
+ Collaboration diagram for sbuild::chroot::facet::userdata:

Public Types

enum  error_code {
  ENV_AMBIGUOUS, KEY_AMBIGUOUS, KEY_DISALLOWED, KEYNAME_INVALID,
  PARSE_ERROR
}
 Error codes. More...
 
typedef custom_error< error_codeerror
 Exception type.
 
typedef std::shared_ptr< userdataptr
 A shared_ptr to a chroot facet object.
 
typedef std::shared_ptr< const
userdata
const_ptr
 A shared_ptr to a const chroot facet object.
 
- Public Types inherited from sbuild::chroot::facet::facet
enum  session_flags { SESSION_NOFLAGS = 0, SESSION_CREATE = 1 << 0, SESSION_CLONE = 1 << 1, SESSION_PURGE = 1 << 2 }
 Chroot session properties. More...
 
typedef std::shared_ptr< facetptr
 A shared_ptr to a chroot facet object.
 
typedef std::shared_ptr< const
facet
const_ptr
 A shared_ptr to a const chroot facet object.
 

Public Member Functions

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

Static Public Member Functions

static ptr create ()
 Create a chroot facet. More...
 

Private Member Functions

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

Private Attributes

string_map data
 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::facet
 facet ()
 The constructor.
 
virtual void set_chroot (chroot &chroot, bool copy=false)
 Set containing chroot. More...
 
- Protected Attributes inherited from sbuild::chroot::facet::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.

PARSE_ERROR 

Error parsing value.

Member Function Documentation

facet::ptr sbuild::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::facet.

References userdata().

userdata::ptr sbuild::chroot::facet::userdata::create ( )
static

Create a chroot facet.

Returns
a shared_ptr to the new chroot facet.

References userdata().

string_map const & sbuild::chroot::facet::userdata::get_data ( ) const

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

Returns
a reference to a string map.

References data.

bool sbuild::chroot::facet::userdata::get_data ( const std::string &  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 data.

void sbuild::chroot::facet::userdata::get_details ( format_detail detail) const
virtual

Get detailed information about the chroot for output.

Parameters
detailthe details to output to.

Reimplemented from sbuild::chroot::facet::facet.

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

void sbuild::chroot::facet::userdata::get_keyfile ( 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
keyfilethe keyfile to use.

Reimplemented from sbuild::chroot::facet::facet.

References data, sbuild::chroot::chroot::get_name(), get_root_modifiable_keys(), get_user_modifiable_keys(), sbuild::chroot::facet::facet::owner, sbuild::keyfile::set_object_set_value(), and sbuild::keyfile::set_value().

std::string const & sbuild::chroot::facet::userdata::get_name ( ) const
virtual

Get the name of the chroot facet.

Returns
the chroot facet name.

Implements sbuild::chroot::facet::facet.

Referenced by set_keyfile().

+ Here is the caller graph for this function:

string_set const & sbuild::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:

void sbuild::chroot::facet::userdata::get_used_keys ( string_list used_keys) const
virtual

Get a list of the keys used during keyfile parsing.

Returns
a list of key names.

Reimplemented from sbuild::chroot::facet::facet.

string_set const & sbuild::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 sbuild::chroot::facet::userdata::remove_data ( const std::string &  key)

Remove a single key.

If present, the specified key is removed.

Parameters
keythe key to remove.

References data.

void sbuild::chroot::facet::userdata::set_data ( const string_map 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_keyfile(), set_root_data(), and set_user_data().

+ Here is the caller graph for this function:

void sbuild::chroot::facet::userdata::set_data ( const std::string &  key,
const std::string &  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 sbuild::chroot::facet::userdata::set_data ( const string_map data,
const string_set 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::_(), sbuild::chroot::chroot::get_keyfile(), sbuild::chroot::chroot::get_used_keys(), KEY_DISALLOWED, sbuild::chroot::facet::facet::owner, set_data(), sbuild::chroot::chroot::set_keyfile(), and sbuild::error_base::set_reason().

void sbuild::chroot::facet::userdata::set_keyfile ( const keyfile keyfile)
virtual
void sbuild::chroot::facet::userdata::set_root_data ( const string_map 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 sbuild::chroot::facet::userdata::set_root_modifiable_keys ( const string_set 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 sbuild::chroot::facet::userdata::set_system_data ( const std::string &  key,
const std::string &  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::_(), data, env, KEY_AMBIGUOUS, and sbuild::error_base::set_reason().

Referenced by set_data(), and set_system_data().

+ Here is the caller graph for this function:

void sbuild::chroot::facet::userdata::set_system_data ( const string_map data)

Set data without user or root checks.

Parameters
string_mapa map of key-value pairs.

References set_system_data().

void sbuild::chroot::facet::userdata::set_user_data ( const string_map 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 sbuild::chroot::facet::userdata::set_user_modifiable_keys ( const string_set 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 sbuild::chroot::facet::userdata::setup_env ( environment env) const
virtual

Set environment.

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

Parameters
envthe environment to set.

Reimplemented from sbuild::chroot::facet::facet.

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


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