]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
attach: introduce explicit personality macro 3825/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 4 May 2021 14:16:36 +0000 (16:16 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 4 May 2021 14:16:36 +0000 (16:16 +0200)
Introduce LXC_ATTACH_DETECT_PERSONALITY to make it explicit what is
happening instead of using -1.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/attach.c
src/lxc/attach_options.h

index b3aa8ca08cedd56107d5e1ff51751251818364db..97eff7f8ef65dc4b9437e2cdbda79327391056be 100644 (file)
@@ -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;
index b8e786023d16dc8ab0b5511269201ef2a85a1788..46d1ecd895db428a30cc8611fc51f22921f96e19 100644 (file)
@@ -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         = {},                                   \
        }
 
 /*!