sbuild
1.7.1
|
Chroot support for filesystem union based sessions. More...
#include <fsunion.h>
Public Types | |
enum | error_code { FSUNION_TYPE_UNKNOWN, FSUNION_OVERLAY_ABS, FSUNION_UNDERLAY_ABS } |
Error codes. More... | |
typedef custom_error< error_code > | error |
Exception type. | |
typedef std::shared_ptr< fsunion > | ptr |
A shared_ptr to a chroot facet object. | |
typedef std::shared_ptr< const fsunion > | const_ptr |
A shared_ptr to a const chroot facet object. | |
![]() | |
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< facet > | ptr |
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. | |
![]() | |
typedef std::shared_ptr < session_setup > | ptr |
A shared_ptr to a chroot session_setup object. | |
typedef std::shared_ptr< const session_setup > | const_ptr |
A shared_ptr to a const chroot session_setup object. | |
![]() | |
typedef std::shared_ptr < source_setup > | ptr |
A shared_ptr to a chroot source_setup object. | |
typedef std::shared_ptr< const source_setup > | const_ptr |
A shared_ptr to a const chroot source_setup object. | |
Public Member Functions | |
virtual | ~fsunion () |
The destructor. | |
virtual facet::ptr | clone () const |
Copy the chroot facet. More... | |
std::string const & | get_name () const |
Get the name of the chroot facet. More... | |
bool | get_union_configured () const |
Get fs union configured state. More... | |
virtual std::string const & | get_union_type () const |
Get the filesystem union type. More... | |
virtual void | set_union_type (const std::string &union_type) |
Set the filesystem union type. More... | |
virtual std::string const & | get_union_mount_options () const |
Get the filesystem union mount options (branch configuration). More... | |
virtual void | set_union_mount_options (const std::string &union_mount_options) |
Set the filesystem union mount options (branch configuration). More... | |
virtual std::string const & | get_union_overlay_directory () const |
Get the union overlay directory. More... | |
virtual void | set_union_overlay_directory (const std::string &directory) |
Set the union overlay directory. More... | |
virtual std::string const & | get_union_underlay_directory () const |
Get the union underlay directory. More... | |
virtual void | set_union_underlay_directory (const std::string &directory) |
Set the union underlay directory. More... | |
virtual void | setup_env (environment &env) const |
Set environment. More... | |
virtual session_flags | get_session_flags () const |
Get the session flags of the chroot. 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... | |
virtual void | chroot_session_setup (const chroot &parent, const std::string &session_id, const std::string &alias, const std::string &user, bool root) |
Set up a newly-cloned session chroot. More... | |
virtual void | chroot_source_setup (const chroot &parent) |
Set up a newly-cloned source chroot. More... | |
![]() | |
virtual | ~facet () |
The destructor. | |
![]() | |
virtual | ~session_setup () |
The destructor. | |
![]() | |
virtual | ~source_setup () |
The destructor. | |
Static Public Member Functions | |
static ptr | create () |
Create a chroot facet. More... | |
Private Member Functions | |
fsunion () | |
The constructor. | |
Private Attributes | |
std::string | union_type |
filesystem union type. | |
std::string | union_mount_options |
Union mount options (branch configuration). | |
std::string | union_overlay_directory |
Union read-write overlay directory. | |
std::string | union_underlay_directory |
Union read-only underlay directory. | |
Additional Inherited Members | |
![]() | |
facet () | |
The constructor. | |
virtual void | set_chroot (chroot &chroot, bool copy=false) |
Set containing chroot. More... | |
![]() | |
session_setup () | |
The constructor. | |
![]() | |
source_setup () | |
The constructor. | |
![]() | |
chroot * | owner |
Chroot owning this facet. | |
Chroot support for filesystem union based sessions.
A chroot may offer session support using a filesystem union like aufs or unionfs. A new union type may need to adapt the 10mount or 05union script to properly populate the underlay and mount directory. The overlay directory and union setup is already handled.
|
virtual |
Set up a newly-cloned session chroot.
parent | the parent of the cloned chroot. |
session_id | the identifier (session_id) for the new session. |
alias | used to initially identify the chroot. |
user | the user creating the session. |
root | true if the user has root access, otherwise false. |
Implements sbuild::chroot::facet::session_setup.
References sbuild::chroot::chroot::get_name(), get_union_overlay_directory(), get_union_underlay_directory(), sbuild::chroot::facet::facet::owner, sbuild::chroot::chroot::remove_facet(), set_union_overlay_directory(), and set_union_underlay_directory().
|
virtual |
Set up a newly-cloned source chroot.
parent | the parent of the cloned chroot. |
Implements sbuild::chroot::facet::source_setup.
References sbuild::chroot::facet::facet::owner, and sbuild::chroot::chroot::remove_facet().
|
virtual |
Copy the chroot facet.
This is a virtual copy constructor.
Implements sbuild::chroot::facet::facet.
References fsunion().
|
static |
Create a chroot facet.
References fsunion().
Referenced by sbuild::chroot::facet::loopback::set_chroot(), sbuild::chroot::facet::block_device::set_chroot(), and sbuild::chroot::facet::directory::set_chroot().
|
virtual |
Get detailed information about the chroot for output.
detail | the details to output to. |
Reimplemented from sbuild::chroot::facet::facet.
References sbuild::_(), sbuild::format_detail::add(), get_union_configured(), get_union_mount_options(), get_union_overlay_directory(), get_union_type(), get_union_underlay_directory(), union_overlay_directory, and union_underlay_directory.
|
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.
keyfile | the keyfile to use. |
Reimplemented from sbuild::chroot::facet::facet.
References sbuild::chroot::chroot::get_name(), get_union_configured(), get_union_mount_options(), get_union_overlay_directory(), get_union_type(), get_union_underlay_directory(), sbuild::chroot::facet::facet::owner, and sbuild::keyfile::set_object_value().
|
virtual |
Get the name of the chroot facet.
Implements sbuild::chroot::facet::facet.
|
virtual |
Get the session flags of the chroot.
These determine how the Session controlling the chroot will operate.
chroot | the chroot to use. |
Reimplemented from sbuild::chroot::facet::facet.
References sbuild::chroot::chroot::get_facet(), get_union_configured(), sbuild::chroot::facet::facet::owner, sbuild::chroot::facet::facet::SESSION_NOFLAGS, and sbuild::chroot::facet::facet::SESSION_PURGE.
bool sbuild::chroot::facet::fsunion::get_union_configured | ( | ) | const |
Get fs union configured state.
References get_union_type().
Referenced by get_details(), get_keyfile(), get_session_flags(), set_keyfile(), and setup_env().
|
virtual |
Get the filesystem union mount options (branch configuration).
References union_mount_options.
Referenced by get_details(), get_keyfile(), and setup_env().
|
virtual |
Get the union overlay directory.
References union_overlay_directory.
Referenced by chroot_session_setup(), get_details(), get_keyfile(), and setup_env().
|
virtual |
Get the filesystem union type.
References union_type.
Referenced by get_details(), get_keyfile(), get_union_configured(), and setup_env().
|
virtual |
Get the union underlay directory.
References union_underlay_directory.
Referenced by chroot_session_setup(), get_details(), get_keyfile(), and setup_env().
|
virtual |
Get a list of the keys used during keyfile parsing.
Reimplemented from sbuild::chroot::facet::facet.
|
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.
keyfile | the keyfile to get the properties from. |
Reimplemented from sbuild::chroot::facet::facet.
References sbuild::chroot::chroot::get_facet(), sbuild::chroot::chroot::get_name(), sbuild::keyfile::get_object_value(), get_union_configured(), sbuild::chroot::facet::facet::owner, sbuild::keyfile::PRIORITY_OPTIONAL, sbuild::keyfile::PRIORITY_REQUIRED, set_union_mount_options(), set_union_overlay_directory(), set_union_type(), and set_union_underlay_directory().
|
virtual |
Set the filesystem union mount options (branch configuration).
Normally a temporary directory is used as the writeable branch, which is removed on session end. This allows the building of a complex union which can merge multiple branches. The string has to be constructed as expected by the filesystem union type and is directly used as the mount '-o' option string.
union_mount_options | a union filesystem-specific branch description |
Referenced by set_keyfile().
|
virtual |
Set the union overlay directory.
directory | the writeable overlay directory. |
References sbuild::is_absname().
Referenced by chroot_session_setup(), and set_keyfile().
|
virtual |
Set the filesystem union type.
Currently supported values are aufs, unionfs and none.
union_type | the filesystem type. |
References sbuild::chroot::facet::source_clonable::create(), FSUNION_TYPE_UNKNOWN, sbuild::chroot::facet::facet::owner, and union_type.
Referenced by set_keyfile().
|
virtual |
Set the union underlay directory.
directory | the writeable underlay directory. |
References sbuild::is_absname().
Referenced by chroot_session_setup(), and set_keyfile().
|
virtual |
Set environment.
Set the environment that the setup scripts will see during execution.
env | the environment to set. |
Reimplemented from sbuild::chroot::facet::facet.
References sbuild::environment::add(), get_union_configured(), get_union_mount_options(), get_union_overlay_directory(), get_union_type(), and get_union_underlay_directory().