]> git.proxmox.com Git - mirror_lxc.git/commitdiff
start: expose LXC_PID to network hooks too
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 2 Jul 2019 10:57:12 +0000 (12:57 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 2 Jul 2019 11:49:33 +0000 (13:49 +0200)
Closes #3066.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/start.c

index 335f6d6fc3624c3a57c6bd6129ec32bc87f4a4f2..ad6e1f67094dd79601322bda4862c5a83f6ce287 100644 (file)
@@ -1756,6 +1756,14 @@ static int lxc_spawn(struct lxc_handler *handler)
                        goto out_delete_net;
        }
 
+       ret = snprintf(pidstr, 20, "%d", handler->pid);
+       if (ret < 0 || ret >= 20)
+               goto out_delete_net;
+
+       ret = setenv("LXC_PID", pidstr, 1);
+       if (ret < 0)
+               SYSERROR("Failed to set environment variable: LXC_PID=%s", pidstr);
+
        for (i = 0; i < LXC_NS_MAX; i++)
                if (handler->ns_on_clone_flags & ns_info[i].clone_flag)
                        INFO("Cloned %s", ns_info[i].flag_name);
@@ -1882,14 +1890,6 @@ static int lxc_spawn(struct lxc_handler *handler)
                }
        }
 
-       ret = snprintf(pidstr, 20, "%d", handler->pid);
-       if (ret < 0 || ret >= 20)
-               goto out_delete_net;
-
-       ret = setenv("LXC_PID", pidstr, 1);
-       if (ret < 0)
-               SYSERROR("Failed to set environment variable: LXC_PID=%s", pidstr);
-
        /* Run any host-side start hooks */
        ret = run_lxc_hooks(name, "start-host", conf, NULL);
        if (ret < 0) {