GVirSandboxConfig

GVirSandboxConfig — Basic sandbox configuration details

Synopsis

#include <libvirt-sandbox/libvirt-sandbox.h>

struct              GVirSandboxConfig;
struct              GVirSandboxConfigClass;
GVirSandboxConfig * gvir_sandbox_config_load_from_path  (const gchar *path,
                                                         GError **error);
GVirSandboxConfig * gvir_sandbox_config_load_from_data  (const gchar *data,
                                                         GError **error);
gboolean            gvir_sandbox_config_save_to_path    (GVirSandboxConfig *config,
                                                         const gchar *path,
                                                         GError **error);
gchar *             gvir_sandbox_config_save_to_data    (GVirSandboxConfig *config,
                                                         GError **error);
const gchar *       gvir_sandbox_config_get_name        (GVirSandboxConfig *config);
void                gvir_sandbox_config_set_uuid        (GVirSandboxConfig *config,
                                                         const gchar *uuid);
const gchar *       gvir_sandbox_config_get_uuid        (GVirSandboxConfig *config);
void                gvir_sandbox_config_set_root        (GVirSandboxConfig *config,
                                                         const gchar *hostdir);
const gchar *       gvir_sandbox_config_get_root        (GVirSandboxConfig *config);
void                gvir_sandbox_config_set_arch        (GVirSandboxConfig *config,
                                                         const gchar *arch);
const gchar *       gvir_sandbox_config_get_arch        (GVirSandboxConfig *config);
void                gvir_sandbox_config_set_kernrelease (GVirSandboxConfig *config,
                                                         const gchar *kernrelease);
const gchar *       gvir_sandbox_config_get_kernrelease (GVirSandboxConfig *config);
void                gvir_sandbox_config_set_kernpath    (GVirSandboxConfig *config,
                                                         const gchar *kernpath);
const gchar *       gvir_sandbox_config_get_kernpath    (GVirSandboxConfig *config);
void                gvir_sandbox_config_set_kmodpath    (GVirSandboxConfig *config,
                                                         const gchar *kmodpath);
const gchar *       gvir_sandbox_config_get_kmodpath    (GVirSandboxConfig *config);
void                gvir_sandbox_config_set_shell       (GVirSandboxConfig *config,
                                                         gboolean shell);
gboolean            gvir_sandbox_config_get_shell       (GVirSandboxConfig *config);
void                gvir_sandbox_config_set_userid      (GVirSandboxConfig *config,
                                                         guint uid);
guint               gvir_sandbox_config_get_userid      (GVirSandboxConfig *config);
void                gvir_sandbox_config_set_groupid     (GVirSandboxConfig *config,
                                                         guint gid);
guint               gvir_sandbox_config_get_groupid     (GVirSandboxConfig *config);
void                gvir_sandbox_config_set_username    (GVirSandboxConfig *config,
                                                         const gchar *username);
const gchar *       gvir_sandbox_config_get_username    (GVirSandboxConfig *config);
void                gvir_sandbox_config_set_homedir     (GVirSandboxConfig *config,
                                                         const gchar *homedir);
const gchar *       gvir_sandbox_config_get_homedir     (GVirSandboxConfig *config);
void                gvir_sandbox_config_add_network     (GVirSandboxConfig *config,
                                                         GVirSandboxConfigNetwork *network);
GList *             gvir_sandbox_config_get_networks    (GVirSandboxConfig *config);
gboolean            gvir_sandbox_config_add_network_opts
                                                        (GVirSandboxConfig *config,
                                                         const gchar *network,
                                                         GError **error);
gboolean            gvir_sandbox_config_add_network_strv
                                                        (GVirSandboxConfig *config,
                                                         gchar **networks,
                                                         GError **error);
gboolean            gvir_sandbox_config_has_networks    (GVirSandboxConfig *config);
void                gvir_sandbox_config_add_mount       (GVirSandboxConfig *config,
                                                         GVirSandboxConfigMount *mnt);
GList *             gvir_sandbox_config_get_mounts      (GVirSandboxConfig *config);
GList *             gvir_sandbox_config_get_mounts_with_type
                                                        (GVirSandboxConfig *config,
                                                         GType type);
GVirSandboxConfigMount * gvir_sandbox_config_find_mount (GVirSandboxConfig *config,
                                                         const gchar *target);
gboolean            gvir_sandbox_config_add_mount_opts  (GVirSandboxConfig *config,
                                                         const char *mount,
                                                         GError **error);
gboolean            gvir_sandbox_config_add_mount_strv  (GVirSandboxConfig *config,
                                                         gchar **mounts,
                                                         GError **error);
gboolean            gvir_sandbox_config_has_mounts      (GVirSandboxConfig *config);
gboolean            gvir_sandbox_config_has_mounts_with_type
                                                        (GVirSandboxConfig *config,
                                                         GType type);
gboolean            gvir_sandbox_config_add_host_include_strv
                                                        (GVirSandboxConfig *config,
                                                         gchar **includes,
                                                         GError **error);
gboolean            gvir_sandbox_config_add_host_include_file
                                                        (GVirSandboxConfig *config,
                                                         gchar *includefile,
                                                         GError **error);
void                gvir_sandbox_config_set_security_label
                                                        (GVirSandboxConfig *config,
                                                         const gchar *label);
const gchar *       gvir_sandbox_config_get_security_label
                                                        (GVirSandboxConfig *config);
void                gvir_sandbox_config_set_security_dynamic
                                                        (GVirSandboxConfig *config,
                                                         gboolean dynamic);
gboolean            gvir_sandbox_config_get_security_dynamic
                                                        (GVirSandboxConfig *config);
gboolean            gvir_sandbox_config_set_security_opts
                                                        (GVirSandboxConfig *config,
                                                         const gchar *optstr,
                                                         GError **error);
gchar **            gvir_sandbox_config_get_command     (GVirSandboxConfig *config);

Object Hierarchy

  GObject
   +----GVirSandboxConfig
         +----GVirSandboxConfigInteractive
         +----GVirSandboxConfigService

Properties

  "arch"                     gchar*                : Read / Write
  "gid"                      guint                 : Read / Write
  "homedir"                  gchar*                : Read / Write
  "kernpath"                 gchar*                : Read / Write
  "kernrelease"              gchar*                : Read / Write
  "kmodpath"                 gchar*                : Read / Write
  "name"                     gchar*                : Read / Write / Construct Only
  "root"                     gchar*                : Read / Write
  "security-dynamic"         gboolean              : Read / Write
  "security-label"           gchar*                : Read / Write
  "shell"                    gchar*                : Read / Write
  "uid"                      guint                 : Read / Write
  "username"                 gchar*                : Read / Write
  "uuid"                     gchar*                : Read / Write / Construct Only

Description

Provides a base object to store configurations for the application sandbox

The GVirSandboxConfig object stores the basic information required to create application sandboxes with a simple text based console.

Details

struct GVirSandboxConfig

struct GVirSandboxConfig;

struct GVirSandboxConfigClass

struct GVirSandboxConfigClass {
    GObjectClass parent_class;

    gboolean (*load_config)(GVirSandboxConfig *config,
                            GKeyFile *file,
                            GError **error);
    void (*save_config)(GVirSandboxConfig *config,
                        GKeyFile *file);

    gchar **(*get_command)(GVirSandboxConfig *config);

    gpointer padding[LIBVIRT_SANDBOX_CLASS_PADDING];
};

gvir_sandbox_config_load_from_path ()

GVirSandboxConfig * gvir_sandbox_config_load_from_path  (const gchar *path,
                                                         GError **error);

path :

the local path to load

error :

the loader error

Returns :

the new config or NULL. [transfer full]

gvir_sandbox_config_load_from_data ()

GVirSandboxConfig * gvir_sandbox_config_load_from_data  (const gchar *data,
                                                         GError **error);

data :

the .ini data string to load

error :

the loader error

Returns :

the new config or NULL. [transfer full]

gvir_sandbox_config_save_to_path ()

gboolean            gvir_sandbox_config_save_to_path    (GVirSandboxConfig *config,
                                                         const gchar *path,
                                                         GError **error);

gvir_sandbox_config_save_to_data ()

gchar *             gvir_sandbox_config_save_to_data    (GVirSandboxConfig *config,
                                                         GError **error);

gvir_sandbox_config_get_name ()

const gchar *       gvir_sandbox_config_get_name        (GVirSandboxConfig *config);

Retrieves the sandbox name

config :

the sandbox config. [transfer none]

Returns :

the current name. [transfer none]

gvir_sandbox_config_set_uuid ()

void                gvir_sandbox_config_set_uuid        (GVirSandboxConfig *config,
                                                         const gchar *uuid);

Set the UUID for the container, to overide the automatically generated value.

config :

the sandbox config. [transfer none]

uuid :

the uuid in string format. [transfer none]

gvir_sandbox_config_get_uuid ()

const gchar *       gvir_sandbox_config_get_uuid        (GVirSandboxConfig *config);

Retrieves the sandbox UUID

config :

the sandbox config. [transfer none]

Returns :

the current uuid. [transfer none]

gvir_sandbox_config_set_root ()

void                gvir_sandbox_config_set_root        (GVirSandboxConfig *config,
                                                         const gchar *hostdir);

Set the host directory to use as the root for the sandbox. The defualt root is "/".

config :

the sandbox config. [transfer none]

hostdir :

the host directory. [transfer none]

gvir_sandbox_config_get_root ()

const gchar *       gvir_sandbox_config_get_root        (GVirSandboxConfig *config);

Retrieves the sandbox root directory

config :

the sandbox config. [transfer none]

Returns :

the current root. [transfer none]

gvir_sandbox_config_set_arch ()

void                gvir_sandbox_config_set_arch        (GVirSandboxConfig *config,
                                                         const gchar *arch);

Set the architecture to use in the sandbox. If none is provided, it will default to matching the host architecture.

config :

the sandbox config. [transfer none]

arch :

the host directory. [transfer none]

gvir_sandbox_config_get_arch ()

const gchar *       gvir_sandbox_config_get_arch        (GVirSandboxConfig *config);

Retrieves the sandbox binary architecture

config :

the sandbox config. [transfer none]

Returns :

the current architecture. [transfer none]

gvir_sandbox_config_set_kernrelease ()

void                gvir_sandbox_config_set_kernrelease (GVirSandboxConfig *config,
                                                         const gchar *kernrelease);

Set the kernel release version to use in the sandbox. If none is provided, it will default to matching the current running kernel.

config :

the sandbox config. [transfer none]

kernrelease :

the host directory. [transfer none]

gvir_sandbox_config_get_kernrelease ()

const gchar *       gvir_sandbox_config_get_kernrelease (GVirSandboxConfig *config);

Retrieves the sandbox kernel release version

config :

the sandbox config. [transfer none]

Returns :

the current kernel release version. [transfer none]

gvir_sandbox_config_set_kernpath ()

void                gvir_sandbox_config_set_kernpath    (GVirSandboxConfig *config,
                                                         const gchar *kernpath);

Set the kernel image path to use in the sandbox. If none is provided, it will default to matching /boot/vmlinuz-[kernel release].

config :

the sandbox config. [transfer none]

kernpath :

the host directory. [transfer none]

gvir_sandbox_config_get_kernpath ()

const gchar *       gvir_sandbox_config_get_kernpath    (GVirSandboxConfig *config);

Retrieves the sandbox kernel image path

config :

the sandbox config. [transfer none]

Returns :

the current kernel image path. [transfer none]

gvir_sandbox_config_set_kmodpath ()

void                gvir_sandbox_config_set_kmodpath    (GVirSandboxConfig *config,
                                                         const gchar *kmodpath);

Sets the generic path to the kernel modules directory. It will default to "/lib/modules", modules being searched in /lib/modules/[kernel release]. If "/path" is given as argument modules will be searched in /path/[kernel release]

config :

the sandbox config. [transfer none]

kmodpath :

the kernel modules path. [transfer none]

gvir_sandbox_config_get_kmodpath ()

const gchar *       gvir_sandbox_config_get_kmodpath    (GVirSandboxConfig *config);

Retrieves the sandbox kernel modules path

config :

the sandbox config. [transfer none]

Returns :

the current kernel modules path. [transfer none]

gvir_sandbox_config_set_shell ()

void                gvir_sandbox_config_set_shell       (GVirSandboxConfig *config,
                                                         gboolean shell);

Set whether the container console should have a interactive shell.

config :

the sandbox config. [transfer none]

shell :

true if the container should have a shell. [transfer none]

gvir_sandbox_config_get_shell ()

gboolean            gvir_sandbox_config_get_shell       (GVirSandboxConfig *config);

Retrieves the sandbox shell flag

config :

the sandbox config. [transfer none]

Returns :

the shell flag. [transfer none]

gvir_sandbox_config_set_userid ()

void                gvir_sandbox_config_set_userid      (GVirSandboxConfig *config,
                                                         guint uid);

Set the user ID to invoke the sandbox application under. Defaults to the user ID of the current program.

config :

the sandbox config. [transfer none]

uid :

the sandbox user ID. [transfer none]

gvir_sandbox_config_get_userid ()

guint               gvir_sandbox_config_get_userid      (GVirSandboxConfig *config);

Get the user ID to invoke the sandbox application under.

config :

the sandbox config. [transfer none]

Returns :

the user ID. [transfer none]

gvir_sandbox_config_set_groupid ()

void                gvir_sandbox_config_set_groupid     (GVirSandboxConfig *config,
                                                         guint gid);

Set the group ID to invoke the sandbox application under. Defaults to the group ID of the current program.

config :

the sandbox config. [transfer none]

gid :

the sandbox group ID. [transfer none]

gvir_sandbox_config_get_groupid ()

guint               gvir_sandbox_config_get_groupid     (GVirSandboxConfig *config);

Get the group ID to invoke the sandbox application under.

config :

the sandbox config. [transfer none]

Returns :

the group ID. [transfer none]

gvir_sandbox_config_set_username ()

void                gvir_sandbox_config_set_username    (GVirSandboxConfig *config,
                                                         const gchar *username);

Set the user name associated with the sandbox user ID. Defaults to the user name of the current program.

config :

the sandbox config. [transfer none]

username :

the sandbox user name. [transfer none]

gvir_sandbox_config_get_username ()

const gchar *       gvir_sandbox_config_get_username    (GVirSandboxConfig *config);

Get the user name to invoke the sandbox application under.

config :

the sandbox config. [transfer none]

Returns :

the user name. [transfer none]

gvir_sandbox_config_set_homedir ()

void                gvir_sandbox_config_set_homedir     (GVirSandboxConfig *config,
                                                         const gchar *homedir);

Set the home directory associated with the sandbox user ID. Defaults to the home directory of the current program.

config :

the sandbox config. [transfer none]

homedir :

the sandbox home directory. [transfer none]

gvir_sandbox_config_get_homedir ()

const gchar *       gvir_sandbox_config_get_homedir     (GVirSandboxConfig *config);

Get the home directory associated with the sandbox user ID

config :

the sandbox config. [transfer none]

Returns :

the home directory. [transfer none]

gvir_sandbox_config_add_network ()

void                gvir_sandbox_config_add_network     (GVirSandboxConfig *config,
                                                         GVirSandboxConfigNetwork *network);

Adds a new network connection to the sandbox

config :

the sandbox config. [transfer none]

network :

the network configuration. [transfer none]

gvir_sandbox_config_get_networks ()

GList *             gvir_sandbox_config_get_networks    (GVirSandboxConfig *config);

Retrieves the list of custom networks in the sandbox

config :

the sandbox config. [transfer none]

Returns :

the list of networks. [transfer full][element-type GVirSandboxConfigNetwork]

gvir_sandbox_config_add_network_opts ()

gboolean            gvir_sandbox_config_add_network_opts
                                                        (GVirSandboxConfig *config,
                                                         const gchar *network,
                                                         GError **error);

Parses network whose elements are in the format KEY=VALUE, creating GVirSandboxConfigNetwork instances for each element.

dhcp,source=default source=private,address=192.168.122.1/24192.168.122.255, address=192.168.122.1/24192.168.122.255,address=2001:212::204:2/64 route=192.168.122.255/24192.168.1.1

config :

the sandbox config. [transfer none]

network :

the network config. [transfer none]

gvir_sandbox_config_add_network_strv ()

gboolean            gvir_sandbox_config_add_network_strv
                                                        (GVirSandboxConfig *config,
                                                         gchar **networks,
                                                         GError **error);

Parses networks whose elements are in the format KEY=VALUE, creating GVirSandboxConfigNetwork instances for each element.

config :

the sandbox config. [transfer none]

networks :

the list of networks. [transfer none][array zero-terminated=1]

gvir_sandbox_config_has_networks ()

gboolean            gvir_sandbox_config_has_networks    (GVirSandboxConfig *config);

gvir_sandbox_config_add_mount ()

void                gvir_sandbox_config_add_mount       (GVirSandboxConfig *config,
                                                         GVirSandboxConfigMount *mnt);

Adds a new custom mount to the sandbox, to override part of the host filesystem

config :

the sandbox config. [transfer none]

mnt :

the mount configuration. [transfer none]

gvir_sandbox_config_get_mounts ()

GList *             gvir_sandbox_config_get_mounts      (GVirSandboxConfig *config);

Retrieves the list of custom mounts in the sandbox

config :

the sandbox config. [transfer none]

Returns :

the list of mounts. [transfer full][element-type GVirSandboxConfigMount]

gvir_sandbox_config_get_mounts_with_type ()

GList *             gvir_sandbox_config_get_mounts_with_type
                                                        (GVirSandboxConfig *config,
                                                         GType type);

Retrieves the list of custom mounts in the sandbox

config :

the sandbox config. [transfer none]

Returns :

the list of mounts. [transfer full][element-type GVirSandboxConfigMount]

gvir_sandbox_config_find_mount ()

GVirSandboxConfigMount * gvir_sandbox_config_find_mount (GVirSandboxConfig *config,
                                                         const gchar *target);

Finds the GVirSandboxConfigMount object corresponding to a guest path of target.

config :

the sandbox config. [transfer none]

target :

the guest target path

Returns :

a mount object or NULL. [transfer full][allow-none]

gvir_sandbox_config_add_mount_opts ()

gboolean            gvir_sandbox_config_add_mount_opts  (GVirSandboxConfig *config,
                                                         const char *mount,
                                                         GError **error);

Parses mount whose elements are in the format TYPE:TARGET=SOURCE creating GVirSandboxConfigMount instances for each element. For example

  • host-bind:/tmp=/var/lib/sandbox/demo/tmp

  • host-image:/=/var/lib/sandbox/demo.img

  • guest-bind:/home=/tmp/home

  • ram:/tmp=500M

config :

the sandbox config. [transfer none]

mount :

the mount config. [transfer none]

gvir_sandbox_config_add_mount_strv ()

gboolean            gvir_sandbox_config_add_mount_strv  (GVirSandboxConfig *config,
                                                         gchar **mounts,
                                                         GError **error);

Parses mounts whose elements are in the format TYPE:TARGET=SOURCE creating GVirSandboxConfigMount instances for each element. For example

  • host-bind:/tmp=/var/lib/sandbox/demo/tmp

  • host-image:/=/var/lib/sandbox/demo.img

  • guest-bind:/home=/tmp/home

config :

the sandbox config. [transfer none]

mounts :

the list of mounts. [transfer none][array zero-terminated=1]

gvir_sandbox_config_has_mounts ()

gboolean            gvir_sandbox_config_has_mounts      (GVirSandboxConfig *config);

gvir_sandbox_config_has_mounts_with_type ()

gboolean            gvir_sandbox_config_has_mounts_with_type
                                                        (GVirSandboxConfig *config,
                                                         GType type);

gvir_sandbox_config_add_host_include_strv ()

gboolean            gvir_sandbox_config_add_host_include_strv
                                                        (GVirSandboxConfig *config,
                                                         gchar **includes,
                                                         GError **error);

Parses includes whose elements are in the format GUEST-TARGET=ROOT-PATH. If ROOT_PATH is omitted, then it is assumed to be the same as GUEST-TARGET

config :

the sandbox config. [transfer none]

includes :

the list of includes. [transfer none][array zero-terminated=1]

gvir_sandbox_config_add_host_include_file ()

gboolean            gvir_sandbox_config_add_host_include_file
                                                        (GVirSandboxConfig *config,
                                                         gchar *includefile,
                                                         GError **error);

gvir_sandbox_config_set_security_label ()

void                gvir_sandbox_config_set_security_label
                                                        (GVirSandboxConfig *config,
                                                         const gchar *label);

Set the sandbox security label. By default a dynamic security label is chosen. A static security label must be specified if any custom mounts are added

config :

the sandbox config. [transfer none]

label :

the host directory. [transfer none]

gvir_sandbox_config_get_security_label ()

const gchar *       gvir_sandbox_config_get_security_label
                                                        (GVirSandboxConfig *config);

Retrieve the sandbox security label

config :

the sandbox config. [transfer none]

Returns :

the security label. [transfer none]

gvir_sandbox_config_set_security_dynamic ()

void                gvir_sandbox_config_set_security_dynamic
                                                        (GVirSandboxConfig *config,
                                                         gboolean dynamic);

Set the SELinux security dynamic for the sandbox. The default dynamic is "svirt_sandbox_t"

config :

the sandbox config. [transfer none]

dynamic :

the security mode. [transfer none]

gvir_sandbox_config_get_security_dynamic ()

gboolean            gvir_sandbox_config_get_security_dynamic
                                                        (GVirSandboxConfig *config);

Retrieve the sandbox security mode

config :

the sandbox config. [transfer none]

Returns :

the security mode. [transfer none]

gvir_sandbox_config_set_security_opts ()

gboolean            gvir_sandbox_config_set_security_opts
                                                        (GVirSandboxConfig *config,
                                                         const gchar *optstr,
                                                         GError **error);

gvir_sandbox_config_get_command ()

gchar **            gvir_sandbox_config_get_command     (GVirSandboxConfig *config);

Retrieve the sandbox command and arguments

config :

the sandbox config. [transfer none]

Returns :

the command path and arguments. [transfer full][array zero-terminated=1]

Property Details

The "arch" property

  "arch"                     gchar*                : Read / Write

The sandbox architecture.

Default value: NULL


The "gid" property

  "gid"                      guint                 : Read / Write

The group ID.

Default value: 501


The "homedir" property

  "homedir"                  gchar*                : Read / Write

The home directory.

Default value: "/home/berrange"


The "kernpath" property

  "kernpath"                 gchar*                : Read / Write

The kernel image path.

Default value: NULL


The "kernrelease" property

  "kernrelease"              gchar*                : Read / Write

The kernel release version.

Default value: NULL


The "kmodpath" property

  "kmodpath"                 gchar*                : Read / Write

Kernel modules path.

Default value: NULL


The "name" property

  "name"                     gchar*                : Read / Write / Construct Only

The sandbox name.

Default value: NULL


The "root" property

  "root"                     gchar*                : Read / Write

The sandbox root.

Default value: NULL


The "security-dynamic" property

  "security-dynamic"         gboolean              : Read / Write

The security mode.

Default value: TRUE


The "security-label" property

  "security-label"           gchar*                : Read / Write

The security label.

Default value: NULL


The "shell" property

  "shell"                    gchar*                : Read / Write

SHELL.

Default value: NULL


The "uid" property

  "uid"                      guint                 : Read / Write

The user ID.

Default value: 501


The "username" property

  "username"                 gchar*                : Read / Write

The username.

Default value: "berrange"


The "uuid" property

  "uuid"                     gchar*                : Read / Write / Construct Only

The sandbox UUID.

Default value: NULL