SbuildSession

SbuildSession — session object

Synopsis




enum        SbuildSessionError;
#define     SBUILD_SESSION_ERROR
            SbuildSession;
            SbuildSessionClass;
SbuildSession* sbuild_session_new           (SbuildConfig *config,
                                             char **chroots);
const char* sbuild_session_get_user         (const SbuildSession *restrict session);
void        sbuild_session_set_user         (SbuildSession *session,
                                             const char *user);
char**      sbuild_session_get_command      (const SbuildSession *restrict session);
void        sbuild_session_set_command      (SbuildSession *session,
                                             char **command);
char**      sbuild_session_get_environment  (const SbuildSession *restrict session);
void        sbuild_session_set_environment  (SbuildSession *session,
                                             char **environment);
SbuildConfig* sbuild_session_get_config     (const SbuildSession *restrict session);
void        sbuild_session_set_config       (SbuildSession *session,
                                             SbuildConfig *config);
char**      sbuild_session_get_chroots      (const SbuildSession *restrict session);
void        sbuild_session_set_chroots      (SbuildSession *session,
                                             char **chroots);
gboolean    sbuild_session_get_quiet        (const SbuildSession *restrict session);
void        sbuild_session_set_quiet        (SbuildSession *session,
                                             gboolean quiet);
gboolean    sbuild_session_run              (SbuildSession *session,
                                             int *child_status,
                                             GError **error);

Object Hierarchy


  GObject
   +----SbuildSession

Properties


  "chroots"              GStrv                 : Read / Write / Construct
  "command"              GStrv                 : Read / Write
  "config"               SbuildConfig          : Read / Write / Construct
  "environment"          GStrv                 : Read / Write
  "gid"                  gint                  : Read
  "quiet"                gboolean              : Read / Write
  "ruid"                 gint                  : Read
  "ruser"                gchararray            : Read
  "shell"                gchararray            : Read
  "uid"                  gint                  : Read
  "user"                 gchararray            : Read / Write

Description

Details

enum SbuildSessionError

typedef enum
{
  SBUILD_SESSION_ERROR_PAM_STARTUP,
  SBUILD_SESSION_ERROR_PAM_SET_ITEM,
  SBUILD_SESSION_ERROR_HOSTNAME,
  SBUILD_SESSION_ERROR_PAM_AUTHENTICATE,
  SBUILD_SESSION_ERROR_PAM_PUTENV,
  SBUILD_SESSION_ERROR_PAM_ACCOUNT,
  SBUILD_SESSION_ERROR_PAM_CREDENTIALS,
  SBUILD_SESSION_ERROR_PAM_SESSION_OPEN,
  SBUILD_SESSION_ERROR_PAM_SESSION_CLOSE,
  SBUILD_SESSION_ERROR_PAM_DELETE_CREDENTIALS,
  SBUILD_SESSION_ERROR_PAM_SHUTDOWN,
  SBUILD_SESSION_ERROR_FORK,
  SBUILD_SESSION_ERROR_CHILD
} SbuildSessionError;

The errors which can occur while running a session.

SBUILD_SESSION_ERROR_PAM_STARTUP PAM failed to start up
SBUILD_SESSION_ERROR_PAM_SET_ITEM PAM failed to set a configuration item
SBUILD_SESSION_ERROR_HOSTNAME The hostname could not be obtained
SBUILD_SESSION_ERROR_PAM_AUTHENTICATE PAM authentication failed
SBUILD_SESSION_ERROR_PAM_PUTENV Setting PAM environment failed
SBUILD_SESSION_ERROR_PAM_ACCOUNT PAM account management failed
SBUILD_SESSION_ERROR_PAM_CREDENTIALS PAM could not set user credentials
SBUILD_SESSION_ERROR_PAM_SESSION_OPEN PAM could not open a session
SBUILD_SESSION_ERROR_PAM_SESSION_CLOSE PAM could not close a session
SBUILD_SESSION_ERROR_PAM_DELETE_CREDENTIALS PAM could not delete user credentials
SBUILD_SESSION_ERROR_PAM_SHUTDOWN PAM could not shut down
SBUILD_SESSION_ERROR_FORK A child process could not be created
SBUILD_SESSION_ERROR_CHILD An error occured during execution of the child process

SBUILD_SESSION_ERROR

#define SBUILD_SESSION_ERROR sbuild_session_error_quark()

The error domain for sbuild session errors.


SbuildSession

typedef struct _SbuildSession SbuildSession;

SbuildSession object.


SbuildSessionClass

typedef struct {
  GObjectClass parent;
} SbuildSessionClass;

SbuildSession class.


sbuild_session_new ()

SbuildSession* sbuild_session_new           (SbuildConfig *config,
                                             char **chroots);

Creates a new SbuildSession. The session will use the provided configuration data, and will run in the list of chroots specified.

config : an SbuildConfig
chroots : the chroots to use
Returns : the newly created SbuildSession.

sbuild_session_get_user ()

const char* sbuild_session_get_user         (const SbuildSession *restrict session);

Get the name of the user. This is the user to run as in the chroot.

session : an SbuildSession
Returns : a string. This string points to internally allocated storage in the chroot and must not be freed, modified or stored.

sbuild_session_set_user ()

void        sbuild_session_set_user         (SbuildSession *session,
                                             const char *user);

Get the name of the user. This is the user to run as in the chroot.

As a side effect, the "uid", "gid" and "shell" properties will also be set.

session : an SbuildSession.
user : the name to set.

sbuild_session_get_command ()

char**      sbuild_session_get_command      (const SbuildSession *restrict session);

Get the command to run in the chroot.

session : an SbuildSession
Returns : a string vector. This string vector points to internally allocated storage in the chroot and must not be freed, modified or stored.

sbuild_session_set_command ()

void        sbuild_session_set_command      (SbuildSession *session,
                                             char **command);

Set the command to run in the chroot.

session : an SbuildSession.
command : the command to set.

sbuild_session_get_environment ()

char**      sbuild_session_get_environment  (const SbuildSession *restrict session);

Get the environment to use in session.

session : an SbuildSession
Returns : a string vector. This string vector points to internally allocated storage in the chroot and must not be freed, modified or stored.

sbuild_session_set_environment ()

void        sbuild_session_set_environment  (SbuildSession *session,
                                             char **environment);

Set the environment to use in session.

session : an SbuildSession
environment : the environment to use

sbuild_session_get_config ()

SbuildConfig* sbuild_session_get_config     (const SbuildSession *restrict session);

Get the configuration associated with session.

session : an SbuildSession
Returns : an SbuildConfig.

sbuild_session_set_config ()

void        sbuild_session_set_config       (SbuildSession *session,
                                             SbuildConfig *config);

Set the configuration associated with session.

session : an SbuildSession
config : an SbuildConfig

sbuild_session_get_chroots ()

char**      sbuild_session_get_chroots      (const SbuildSession *restrict session);

Get the chroots to use in session.

session : an SbuildSession
Returns : a string vector. This string vector points to internally allocated storage in the chroot and must not be freed, modified or stored.

sbuild_session_set_chroots ()

void        sbuild_session_set_chroots      (SbuildSession *session,
                                             char **chroots);

Set the chroots to use in session.

session : an SbuildSession
chroots : the chroots to use

sbuild_session_get_quiet ()

gboolean    sbuild_session_get_quiet        (const SbuildSession *restrict session);

Get the message verbosity of session.

session : an SbuildSession
Returns : TRUE if quiet messages are enabled, otherwise FALSE.

sbuild_session_set_quiet ()

void        sbuild_session_set_quiet        (SbuildSession *session,
                                             gboolean quiet);

Set the message verbosity of session.

session : an SbuildSession
quiet : the quiet to use

sbuild_session_run ()

gboolean    sbuild_session_run              (SbuildSession *session,
                                             int *child_status,
                                             GError **error);

Run a session. If a command has been specified, this will be run in each of the specified chroots. If no command has been specified, a login shell will run in the specified chroot.

If required, the user may be required to authenticate themselves. This usually occurs when running as a different user. The user must be a member of the appropriate groups in order to satisfy the groups and root-groups requirements in the chroot configuration.

session : an SbuildSession
child_status : a location to place the child exit status
error : a GError, or NULL to ignore errors
Returns : TRUE on success, FALSE on failure (error will be set to indicate the cause of the failure).

Properties

The "chroots" property

  "chroots"              GStrv                 : Read / Write / Construct

The chroots to use.


The "command" property

  "command"              GStrv                 : Read / Write

The command to run in the chroot, or NULL for a login shell.


The "config" property

  "config"               SbuildConfig          : Read / Write / Construct

The chroot configuration data.


The "environment" property

  "environment"          GStrv                 : Read / Write

The user environment to set in the chroot.


The "gid" property

  "gid"                  gint                  : Read

The GID to run as in the chroot.

Allowed values: >= 0

Default value: 0


The "quiet" property

  "quiet"                gboolean              : Read / Write

Suppress non-essential messages.

Default value: FALSE


The "ruid" property

  "ruid"                 gint                  : Read

The UID of the current user.

Allowed values: >= 0

Default value: 0


The "ruser" property

  "ruser"                gchararray            : Read

The current user's login name.

Default value: ""


The "shell" property

  "shell"                gchararray            : Read

The login shell for the user to run as in the chroot.

Default value: "/bin/false"


The "uid" property

  "uid"                  gint                  : Read

The UID to run as in the chroot.

Allowed values: >= 0

Default value: 0


The "user" property

  "user"                 gchararray            : Read / Write

The user login name to run as in the chroot.

Default value: ""