]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
conf: use O_CLOEXEC in lxc_pivot_root()
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 20 Oct 2018 09:35:41 +0000 (11:35 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Mon, 22 Oct 2018 14:47:44 +0000 (16:47 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/conf.c

index d1783aebdc2eea4f94c5e660c274160b302b00ed..c3358b2feed0089fc88f3eecff97180882fd4f32 100644 (file)
@@ -1497,13 +1497,13 @@ static int lxc_pivot_root(const char *rootfs)
        int oldroot;
        int newroot = -1, ret = -1;
 
-       oldroot = open("/", O_DIRECTORY | O_RDONLY);
+       oldroot = open("/", O_DIRECTORY | O_RDONLY | O_CLOEXEC);
        if (oldroot < 0) {
                SYSERROR("Failed to open old root directory");
                return -1;
        }
 
-       newroot = open(rootfs, O_DIRECTORY | O_RDONLY);
+       newroot = open(rootfs, O_DIRECTORY | O_RDONLY | O_CLOEXEC);
        if (newroot < 0) {
                SYSERROR("Failed to open new root directory");
                goto on_error;