]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
namespace: support CLONE_PIDFD with lxc_clone()
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 9 May 2019 15:09:51 +0000 (17:09 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 9 May 2019 15:09:51 +0000 (17:09 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c
src/lxc/namespace.c
src/lxc/namespace.h
src/lxc/start.c
src/lxc/storage/nbd.c
src/lxc/tools/lxc_unshare.c

index 2515c881ef0d7916a47d9e4e8d992fec9ea65a33..0fbbbfa7971aabc25dc66bd65ebd6c65734095c0 100644 (file)
@@ -4419,7 +4419,7 @@ int userns_exec_full(struct lxc_conf *conf, int (*fn)(void *), void *data,
        d.p[1] = p[1];
 
        /* Clone child in new user namespace. */
-       pid = lxc_clone(run_userns_fn, &d, CLONE_NEWUSER);
+       pid = lxc_clone(run_userns_fn, &d, CLONE_NEWUSER, NULL);
        if (pid < 0) {
                ERROR("Failed to clone process in new user namespace");
                goto on_error;
index e22d9a4bf01f3537ceb89a3773a8a274c9c54616..59fba412dd20f6d40a4338bf074af99788d7f363 100644 (file)
@@ -54,7 +54,7 @@ static int do_clone(void *arg)
 }
 
 #define __LXC_STACK_SIZE 4096
-pid_t lxc_clone(int (*fn)(void *), void *arg, int flags)
+pid_t lxc_clone(int (*fn)(void *), void *arg, int flags, int *pidfd)
 {
        size_t stack_size;
        pid_t ret;
@@ -66,9 +66,9 @@ pid_t lxc_clone(int (*fn)(void *), void *arg, int flags)
        stack_size = __LXC_STACK_SIZE;
 
 #ifdef __ia64__
-       ret = __clone2(do_clone, stack, stack_size, flags | SIGCHLD, &clone_arg);
+       ret = __clone2(do_clone, stack, stack_size, flags | SIGCHLD, &clone_arg, pidfd);
 #else
-       ret = clone(do_clone, stack + stack_size, flags | SIGCHLD, &clone_arg);
+       ret = clone(do_clone, stack + stack_size, flags | SIGCHLD, &clone_arg, pidfd);
 #endif
        if (ret < 0)
                SYSERROR("Failed to clone (%#x)", flags);
index ab583da76aa554c868c128e95e413ef7cd0d15ca..f2c2ad82c671051c37ef939ea7848dbb5e91b8af 100644 (file)
@@ -133,7 +133,7 @@ int clone(int (*fn)(void *), void *child_stack,
  * - should call lxc_raw_getpid():
  *   The child should use lxc_raw_getpid() to retrieve its pid.
  */
-extern pid_t lxc_clone(int (*fn)(void *), void *arg, int flags);
+extern pid_t lxc_clone(int (*fn)(void *), void *arg, int flags, int *pidfd);
 
 extern int lxc_namespace_2_cloneflag(const char *namespace);
 extern int lxc_namespace_2_ns_idx(const char *namespace);
index 34798292cfe86287f002326b6482575489e4aa14..48ba2b4240c440ded5bccf1a882978715e8c5dea 100644 (file)
@@ -1735,7 +1735,7 @@ static int lxc_spawn(struct lxc_handler *handler)
                pid_t attacher_pid;
 
                attacher_pid = lxc_clone(do_share_ns, handler,
-                                        CLONE_VFORK | CLONE_VM | CLONE_FILES);
+                                        CLONE_VFORK | CLONE_VM | CLONE_FILES, NULL);
                if (attacher_pid < 0) {
                        SYSERROR(LXC_CLONE_ERROR);
                        goto out_delete_net;
index ab4f752c9d0122e76176c1ea6b43bc21bafdece9..dc68ee623eb30a8f63086dfd767507a84eff0ec9 100644 (file)
@@ -266,7 +266,7 @@ static bool clone_attach_nbd(const char *nbd, const char *path)
        data.nbd = nbd;
        data.path = path;
 
-       pid = lxc_clone(do_attach_nbd, &data, CLONE_NEWPID);
+       pid = lxc_clone(do_attach_nbd, &data, CLONE_NEWPID, NULL);
        if (pid < 0)
                return false;
 
index 1bc04ce9281c7c4535b95002d68fa879f41b1b94..421d92c2ad4a3dfd8ea9f0260c0fe9fd24730e3f 100644 (file)
@@ -388,7 +388,7 @@ int main(int argc, char *argv[])
        start_arg.want_hostname = my_args.want_hostname;
        start_arg.want_default_mounts = my_args.want_default_mounts;
 
-       pid = lxc_clone(do_start, &start_arg, my_args.flags);
+       pid = lxc_clone(do_start, &start_arg, my_args.flags, NULL);
        if (pid < 0) {
                ERROR("Failed to clone");
                free_ifname_list();