attach: introduce explicit personality macro

Introduce LXC_ATTACH_DETECT_PERSONALITY to make it explicit what is happening instead of using -1. Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 64a04c84
......@@ -1147,7 +1147,7 @@ __noreturn static void do_attach(struct attach_payload *ap)
if (options->attach_flags & LXC_ATTACH_SET_PERSONALITY) {
long new_personality;
if (options->personality < 0)
if (options->personality == LXC_ATTACH_DETECT_PERSONALITY)
new_personality = ctx->personality;
else
new_personality = options->personality;
......
......@@ -82,6 +82,8 @@ typedef struct lxc_groups_t {
gid_t *list;
} lxc_groups_t;
#define LXC_ATTACH_DETECT_PERSONALITY ~0L
/*!
* LXC attach options for \ref lxc_container \c attach().
*/
......@@ -92,7 +94,7 @@ typedef struct lxc_attach_options_t {
/*! The namespaces to attach to (CLONE_NEW... flags) */
int namespaces;
/*! Initial personality (\c -1 to autodetect).
/*! Initial personality (\c LXC_ATTACH_DETECT_PERSONALITY to autodetect).
* \warning This may be ignored if lxc is compiled without personality
* support)
*/
......@@ -156,23 +158,23 @@ typedef struct lxc_attach_options_t {
} lxc_attach_options_t;
/*! Default attach options to use */
#define LXC_ATTACH_OPTIONS_DEFAULT \
{ \
.attach_flags = LXC_ATTACH_DEFAULT, \
.namespaces = -1, \
.personality = -1, \
.initial_cwd = NULL, \
.uid = (uid_t)-1, \
.gid = (gid_t)-1, \
.env_policy = LXC_ATTACH_KEEP_ENV, \
.extra_env_vars = NULL, \
.extra_keep_env = NULL, \
.stdin_fd = 0, \
.stdout_fd = 1, \
.stderr_fd = 2, \
.log_fd = -EBADF, \
.lsm_label = NULL, \
.groups = {}, \
#define LXC_ATTACH_OPTIONS_DEFAULT \
{ \
.attach_flags = LXC_ATTACH_DEFAULT, \
.namespaces = -1, \
.personality = LXC_ATTACH_DETECT_PERSONALITY, \
.initial_cwd = NULL, \
.uid = (uid_t)-1, \
.gid = (gid_t)-1, \
.env_policy = LXC_ATTACH_KEEP_ENV, \
.extra_env_vars = NULL, \
.extra_keep_env = NULL, \
.stdin_fd = 0, \
.stdout_fd = 1, \
.stderr_fd = 2, \
.log_fd = -EBADF, \
.lsm_label = NULL, \
.groups = {}, \
}
/*!
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment