]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
start: preserve time namespace 3463/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Fri, 26 Jun 2020 08:39:47 +0000 (10:39 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 26 Jun 2020 08:40:52 +0000 (10:40 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/start.c

index 16e519e993f0a9c110ec44c0419ba6d859c784c1..c49b249fb3578223ada67fff343c8adfdf02a22a 100644 (file)
@@ -1870,6 +1870,20 @@ static int lxc_spawn(struct lxc_handler *handler)
        cgroup_ops->payload_finalize(cgroup_ops);
        TRACE("Finished setting up cgroups");
 
+       if (handler->ns_clone_flags & CLONE_NEWTIME) {
+               /* Now we're ready to preserve the cgroup namespace */
+               ret = lxc_try_preserve_ns(handler->pid, "time");
+               if (ret < 0) {
+                       if (ret != -EOPNOTSUPP) {
+                               SYSERROR("Failed to preserve time namespace");
+                               goto out_delete_net;
+                       }
+               } else {
+                       handler->nsfd[LXC_NS_TIME] = ret;
+                       DEBUG("Preserved time namespace via fd %d", ret);
+               }
+       }
+
        /* Run any host-side start hooks */
        ret = run_lxc_hooks(name, "start-host", conf, NULL);
        if (ret < 0) {