]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
umount: fix behaviour of -A and -R with --namespace
authorVaclav Dolezal <vdolezal@redhat.com>
Tue, 24 Apr 2018 16:05:04 +0000 (18:05 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 11 Jun 2018 14:20:08 +0000 (16:20 +0200)
Load /proc/self/mountinfo from correct namespace.

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/umount.c

index 244080598bbfde852ff22086f710503d2f0114bb..5478c55b8775d3ba96c92ab1d5ffd91d62219c49 100644 (file)
@@ -219,7 +219,13 @@ static int umount_one(struct libmnt_context *cxt, const char *spec)
 
 static struct libmnt_table *new_mountinfo(struct libmnt_context *cxt)
 {
-       struct libmnt_table *tb = mnt_new_table();
+       struct libmnt_table *tb;
+       struct libmnt_ns *ns_old = mnt_context_switch_target_ns(cxt);
+
+       if (!ns_old)
+               err(MNT_EX_SYSERR, _("failed to switch namespace"));
+
+       tb = mnt_new_table();
        if (!tb)
                err(MNT_EX_SYSERR, _("libmount table allocation failed"));
 
@@ -232,6 +238,9 @@ static struct libmnt_table *new_mountinfo(struct libmnt_context *cxt)
                tb = NULL;
        }
 
+       if (!mnt_context_switch_ns(cxt, ns_old))
+               err(MNT_EX_SYSERR, _("failed to switch namespace"));
+
        return tb;
 }