The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7156

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
From e6faae922025e8c2362c418ae172c3973d7bac8f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com>
Date: Tue, 7 Apr 2020 22:26:58 -0400
Subject: [PATCH] lxd/main: Move forkzfs mntns to cgo
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
---
 lxd/main_forkzfs.go | 8 +-------
 lxd/main_nsexec.go  | 9 ++++++++-
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/lxd/main_forkzfs.go b/lxd/main_forkzfs.go
index 9927259e24..3ce0e06863 100644
--- a/lxd/main_forkzfs.go
+++ b/lxd/main_forkzfs.go
@@ -51,14 +51,8 @@ func (c *cmdForkZFS) Run(cmd *cobra.Command, args []string) 
error {
                return fmt.Errorf("This must be run as root")
        }
 
-       // Unshare a clean mount namespace
-       err := unix.Unshare(unix.CLONE_NEWNS)
-       if err != nil {
-               return err
-       }
-
        // Mark mount tree as private
-       err = unix.Mount("none", "/", "", unix.MS_REC|unix.MS_PRIVATE, "")
+       err := unix.Mount("none", "/", "", unix.MS_REC|unix.MS_PRIVATE, "")
        if err != nil {
                return err
        }
diff --git a/lxd/main_nsexec.go b/lxd/main_nsexec.go
index 9568df2031..279f7f8411 100644
--- a/lxd/main_nsexec.go
+++ b/lxd/main_nsexec.go
@@ -287,6 +287,7 @@ static char *file_to_buf(char *path, ssize_t *length)
 
 __attribute__((constructor)) void init(void) {
        __do_free char *cmdline = NULL;
+       int ret;
 
        cmdline_buf = file_to_buf("/proc/self/cmdline", &cmdline_size);
        if (!cmdline_buf)
@@ -317,7 +318,13 @@ __attribute__((constructor)) void init(void) {
                forkproxy();
        else if (strcmp(cmdline_cur, "forkuevent") == 0)
                forkuevent();
-       else if (strncmp(cmdline_cur, "-", 1) == 0 || strcmp(cmdline_cur, 
"daemon") == 0)
+       else if (strcmp(cmdline_cur, "forkzfs") == 0) {
+               ret = unshare(CLONE_NEWNS);
+               if (ret < 0) {
+                       fprintf(stderr, "Failed unshare of mount namespace: 
%s\n", strerror(errno));
+                       return;
+               }
+       } else if (strncmp(cmdline_cur, "-", 1) == 0 || strcmp(cmdline_cur, 
"daemon") == 0)
                checkfeature();
 }
 */
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to