From 6e965d0f4a1e1b9c6da92d51e1dafa9571467388 Mon Sep 17 00:00:00 2001 From: Vaclav Dolezal Date: Tue, 24 Apr 2018 18:05:04 +0200 Subject: [PATCH] umount: fix behaviour of -A and -R with --namespace Load /proc/self/mountinfo from correct namespace. Signed-off-by: Vaclav Dolezal Signed-off-by: Karel Zak --- sys-utils/umount.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sys-utils/umount.c b/sys-utils/umount.c index 244080598..5478c55b8 100644 --- a/sys-utils/umount.c +++ b/sys-utils/umount.c @@ -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; }