From: Christian Brauner Date: Tue, 4 May 2021 14:16:36 +0000 (+0200) Subject: attach: introduce explicit personality macro X-Git-Tag: lxc-5.0.0~178^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a881819622a548f5368878a4b799ca905e44d51;p=thirdparty%2Flxc.git attach: introduce explicit personality macro Introduce LXC_ATTACH_DETECT_PERSONALITY to make it explicit what is happening instead of using -1. Signed-off-by: Christian Brauner --- diff --git a/src/lxc/attach.c b/src/lxc/attach.c index b3aa8ca08..97eff7f8e 100644 --- a/src/lxc/attach.c +++ b/src/lxc/attach.c @@ -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; diff --git a/src/lxc/attach_options.h b/src/lxc/attach_options.h index b8e786023..46d1ecd89 100644 --- a/src/lxc/attach_options.h +++ b/src/lxc/attach_options.h @@ -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 = {}, \ } /*!