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 84fc7c27
...@@ -1147,7 +1147,7 @@ __noreturn static void do_attach(struct attach_payload *ap) ...@@ -1147,7 +1147,7 @@ __noreturn static void do_attach(struct attach_payload *ap)
if (options->attach_flags & LXC_ATTACH_SET_PERSONALITY) { if (options->attach_flags & LXC_ATTACH_SET_PERSONALITY) {
long new_personality; long new_personality;
if (options->personality < 0) if (options->personality == LXC_ATTACH_DETECT_PERSONALITY)
new_personality = ctx->personality; new_personality = ctx->personality;
else else
new_personality = options->personality; new_personality = options->personality;
......
...@@ -82,6 +82,8 @@ typedef struct lxc_groups_t { ...@@ -82,6 +82,8 @@ typedef struct lxc_groups_t {
gid_t *list; gid_t *list;
} lxc_groups_t; } lxc_groups_t;
#define LXC_ATTACH_DETECT_PERSONALITY ~0L
/*! /*!
* LXC attach options for \ref lxc_container \c attach(). * LXC attach options for \ref lxc_container \c attach().
*/ */
...@@ -92,7 +94,7 @@ typedef struct lxc_attach_options_t { ...@@ -92,7 +94,7 @@ typedef struct lxc_attach_options_t {
/*! The namespaces to attach to (CLONE_NEW... flags) */ /*! The namespaces to attach to (CLONE_NEW... flags) */
int namespaces; 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 * \warning This may be ignored if lxc is compiled without personality
* support) * support)
*/ */
...@@ -156,23 +158,23 @@ typedef struct lxc_attach_options_t { ...@@ -156,23 +158,23 @@ typedef struct lxc_attach_options_t {
} lxc_attach_options_t; } lxc_attach_options_t;
/*! Default attach options to use */ /*! Default attach options to use */
#define LXC_ATTACH_OPTIONS_DEFAULT \ #define LXC_ATTACH_OPTIONS_DEFAULT \
{ \ { \
.attach_flags = LXC_ATTACH_DEFAULT, \ .attach_flags = LXC_ATTACH_DEFAULT, \
.namespaces = -1, \ .namespaces = -1, \
.personality = -1, \ .personality = LXC_ATTACH_DETECT_PERSONALITY, \
.initial_cwd = NULL, \ .initial_cwd = NULL, \
.uid = (uid_t)-1, \ .uid = (uid_t)-1, \
.gid = (gid_t)-1, \ .gid = (gid_t)-1, \
.env_policy = LXC_ATTACH_KEEP_ENV, \ .env_policy = LXC_ATTACH_KEEP_ENV, \
.extra_env_vars = NULL, \ .extra_env_vars = NULL, \
.extra_keep_env = NULL, \ .extra_keep_env = NULL, \
.stdin_fd = 0, \ .stdin_fd = 0, \
.stdout_fd = 1, \ .stdout_fd = 1, \
.stderr_fd = 2, \ .stderr_fd = 2, \
.log_fd = -EBADF, \ .log_fd = -EBADF, \
.lsm_label = NULL, \ .lsm_label = NULL, \
.groups = {}, \ .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