umount: fix behaviour of -A and -R with --namespace

Load /proc/self/mountinfo from correct namespace.

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Vaclav Dolezal 2018-04-24 18:05:04 +02:00 committed by Karel Zak
parent c1e70afedf
commit 6e965d0f4a
1 changed files with 10 additions and 1 deletions

View 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;
}