Dobby  3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Classes | Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
DobbyConfig Class Referenceabstract

Interface that configuration file parser classes have to implement. More...

#include <DobbyConfig.h>

Inheritance diagram for DobbyConfig:
Inheritance graph
[legend]

Classes

struct  _LoopMount
 Loopmount struct used for Storage plugin. More...
 
struct  DevNode
 

Public Types

enum class  NetworkType { None , Nat , Open }
 Network type used for Network plugin.
 
typedef struct DobbyConfig::_LoopMount LoopMount
 Loopmount struct used for Storage plugin.
 

Public Member Functions

virtual bool isValid () const =0
 Getters used for plugins.
 
virtual uid_t userId () const =0
 
virtual gid_t groupId () const =0
 
virtual IDobbyIPCUtils::BusType systemDbus () const =0
 
virtual IDobbyIPCUtils::BusType sessionDbus () const =0
 
virtual IDobbyIPCUtils::BusType debugDbus () const =0
 
virtual bool consoleDisabled () const =0
 
virtual ssize_t consoleLimit () const =0
 
virtual const std::string & consolePath () const =0
 
virtual bool restartOnCrash () const =0
 
virtual const std::string & rootfsPath () const =0
 
virtual std::shared_ptr< rt_dobby_schema > config () const =0
 
virtual const std::map< std::string, Json::Value > & rdkPlugins () const =0
 
bool addMount (const std::string &source, const std::string &target, const std::string &fsType, unsigned long mountFlags, const std::list< std::string > &mountOptions)
 Public api to allow for adding additional mounts. More...
 
bool addEnvironmentVar (const std::string &envVar)
 Public api to allow for adding additional env variables. More...
 
bool changeProcessArgs (const std::string &command)
 
bool addWesterosMount (const std::string &socketPath)
 
bool writeConfigJson (const std::string &filePath) const
 Writes bundle config string to a file. More...
 
const std::string configJson () const
 Get OCI bundle config json as string. More...
 
void printCommand () const
 
bool enableSTrace (const std::string &logsDir)
 Enables strace for the container. More...
 
void setApparmorProfile (const std::string &profileName)
 Set apparmor profile in config. More...
 
void setPidsLimit (int limit)
 Set cgroup pids limit. More...
 

Protected Member Functions

bool writeConfigJsonImpl (const std::string &filePath) const
 
bool updateBundleConfig (const ContainerId &id, std::shared_ptr< rt_dobby_schema > cfg, const std::string &bundlePath)
 Convert the input config.json into an OCI compliant bundle config that adds support for DobbyPluginLauncher to work with rdkPlugins. More...
 
bool setHostnameToContainerId (const ContainerId &id, std::shared_ptr< rt_dobby_schema > cfg, const std::string &bundlePath)
 Sets the container hostname to the container ID. More...
 
bool convertToCompliant (const ContainerId &id, std::shared_ptr< rt_dobby_schema > cfg, const std::string &bundlePath)
 Convert the input config.json into an OCI compliant bundle config that adds support for DobbyPluginLauncher to work with rdkPlugins. More...
 
bool isApparmorProfileLoaded (const char *profile) const
 Check if apparmor profile is loaded. More...
 

Static Protected Member Functions

static std::list< DevNodescanDevNodes (const std::list< std::string > &devNodes)
 Takes a list of glob patterns corresponding to dev node paths and returns a list of structs with their details. More...
 

Protected Attributes

std::mutex mLock
 

Private Member Functions

void addPluginLauncherHooks (std::shared_ptr< rt_dobby_schema > cfg, const std::string &bundlePath)
 Adds OCI hooks to the config. More...
 
void setPluginHookEntry (rt_defs_hook *entry, const std::string &name, const std::string &configPath)
 Populates a hook entry structure with DobbyPluginLauncher data. More...
 
bool findPluginLauncherHookEntry (rt_defs_hook **hook, int len)
 Checks a hook for Dobby plugin launcher entries. More...
 

Detailed Description

Interface that configuration file parser classes have to implement.

Member Function Documentation

◆ addEnvironmentVar()

bool DobbyConfig::addEnvironmentVar ( const std::string &  envVar)

Public api to allow for adding additional env variables.

This can only obviously be called before the config file is persisted to disk.

Parameters
[in]envVarThe environment variable to set
Returns
true if the env var was added, otherwise false.

◆ addMount()

bool DobbyConfig::addMount ( const std::string &  source,
const std::string &  destination,
const std::string &  type,
unsigned long  mountFlags,
const std::list< std::string > &  mountOptions 
)

Public api to allow for adding additional mounts.

This can only obviously be called before the config file is persisted to disk.

Parameters
[in]sourceThe mount source
[in]destinationThe mount destination
[in]typeThe file system type of the mount
[in]mountFlagsThe mount flags
[in]mountOptionsThe mount options (mount(2) data parameter)
Returns
true if the mount point was added, otherwise false.

◆ addPluginLauncherHooks()

void DobbyConfig::addPluginLauncherHooks ( std::shared_ptr< rt_dobby_schema >  cfg,
const std::string &  bundlePath 
)
private

Adds OCI hooks to the config.

Parameters
[in]cfglibocispec config structure instance
[in]bundlePathpath to the container bundle
Returns
true if hooks added successfully, false if not

◆ addWesterosMount()

bool DobbyConfig::addWesterosMount ( const std::string &  socketPath)

Adds a mount into the container for a westeros socket with the correct permissions at /tmp/westeros

Sets WAYLAND_DISPLAY and XDG_RUNTIME_DIR environment variables to ensure container actually uses the display

Parameters
[in]socketPathPath to westeros socket on host

◆ changeProcessArgs()

bool DobbyConfig::changeProcessArgs ( const std::string &  command)

Changes the startup command for the container to a custom command.

Will automatically add DobbyInit to run the process to ensure sub-reaping is handled properly

Parameters
[in]commandThe command to run (including arguments/params)

◆ configJson()

const std::string DobbyConfig::configJson ( ) const

Get OCI bundle config json as string.

Returns
OCI config json

◆ convertToCompliant()

bool DobbyConfig::convertToCompliant ( const ContainerId id,
std::shared_ptr< rt_dobby_schema >  cfg,
const std::string &  bundlePath 
)
protected

Convert the input config.json into an OCI compliant bundle config that adds support for DobbyPluginLauncher to work with rdkPlugins.

Parameters
[in]idcontainer identifier
[in]cfglibocispec config structure instance
[in]bundlePathpath to the container bundle

◆ enableSTrace()

bool DobbyConfig::enableSTrace ( const std::string &  logsDir)

Enables strace for the container.

Parameters
[in]logsDirDirectory to which strace logs will be written
Returns
true if strace was sucessfully enabled for the container, otherwise false.

◆ findPluginLauncherHookEntry()

bool DobbyConfig::findPluginLauncherHookEntry ( rt_defs_hook **  hook,
int  len 
)
private

Checks a hook for Dobby plugin launcher entries.

Parameters
[in]hookpointer to a hook in the bundle config
[in]lennumber of entries in the hook
Returns
true if unexpected Dobby plugin launcher entry found, false if not

◆ isApparmorProfileLoaded()

bool DobbyConfig::isApparmorProfileLoaded ( const char *  profile) const
protected

Check if apparmor profile is loaded.

Parameters
[in]profileThe name of apparmor profile.
Returns
true if the apparmor profile was loaded in kernel space, otherwise false.

◆ printCommand()

void DobbyConfig::printCommand ( ) const

Prints startup command for the container.

◆ scanDevNodes()

std::list< DobbyConfig::DevNode > DobbyConfig::scanDevNodes ( const std::list< std::string > &  devNodes)
staticprotected

Takes a list of glob patterns corresponding to dev node paths and returns a list of structs with their details.

If the glob pattern doesn't match a device node then it is ignored, this is not an error.

Parameters
[in]devNodesThe list of dev nodes paths (or glob patterns).

◆ setApparmorProfile()

void DobbyConfig::setApparmorProfile ( const std::string &  defaultProfileName)

Set apparmor profile in config.

Checks if profile from config is loaded. If not uses default profile if it is loaded.

Parameters
[in]defaultProfileNameThe name of the default apparmor profile.

◆ setHostnameToContainerId()

bool DobbyConfig::setHostnameToContainerId ( const ContainerId id,
std::shared_ptr< rt_dobby_schema >  cfg,
const std::string &  bundlePath 
)
protected

Sets the container hostname to the container ID.

Parameters
[in]idcontainer identifier
[in]cfglibocispec config structure instance
[in]bundlePathpath to the container bundle

◆ setPidsLimit()

void DobbyConfig::setPidsLimit ( int  limit)

Set cgroup pids limit.

Limits the number of processes that containered app can create.

See also
https://www.kernel.org/doc/Documentation/cgroup-v1/pids.txt
Parameters
[in]limitlimit of pids

◆ setPluginHookEntry()

void DobbyConfig::setPluginHookEntry ( rt_defs_hook *  entry,
const std::string &  name,
const std::string &  configPath 
)
private

Populates a hook entry structure with DobbyPluginLauncher data.

Parameters
[in]entrypointer to hook entry to populate
[in]namehook name
[in]configPathpath to the config file

◆ updateBundleConfig()

bool DobbyConfig::updateBundleConfig ( const ContainerId id,
std::shared_ptr< rt_dobby_schema >  cfg,
const std::string &  bundlePath 
)
protected

Convert the input config.json into an OCI compliant bundle config that adds support for DobbyPluginLauncher to work with rdkPlugins.

Parameters
[in]idcontainer identifier
[in]cfglibocispec config structure instance
[in]bundlePathpath to the container bundle

◆ writeConfigJson()

bool DobbyConfig::writeConfigJson ( const std::string &  filePath) const

Writes bundle config string to a file.

Parameters
[in]filePathThe name and path to the file to write to.
Returns
true if the file was written correctly, otherwise false.

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