From 2f2d81d957b2d5ef7a0f8a702dcf7f71348cffe3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 23 Apr 2019 23:52:15 +0200 Subject: [PATCH] shared/mount-util: make sure utab is ignored in umount_recursive() See https://github.com/systemd/systemd/pull/12218#pullrequestreview-226029985. --- src/shared/libmount-util.h | 7 ++++++- src/shared/mount-util.c | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/shared/libmount-util.h b/src/shared/libmount-util.h index 6e8e61ed6ca..7c3b855df52 100644 --- a/src/shared/libmount-util.h +++ b/src/shared/libmount-util.h @@ -29,10 +29,15 @@ static inline int libmount_parse( if (!table || !iter) return -ENOMEM; + /* If source or path are specified, we use on the functions which ignore utab. + * Only if both are empty, we use mnt_table_parse_mtab(). */ + if (source) r = mnt_table_parse_stream(table, source, path); + else if (path) + r = mnt_table_parse_file(table, path); else - r = mnt_table_parse_mtab(table, path); + r = mnt_table_parse_mtab(table, NULL); if (r < 0) return r; diff --git a/src/shared/mount-util.c b/src/shared/mount-util.c index 97cc7b44c57..d84f28250db 100644 --- a/src/shared/mount-util.c +++ b/src/shared/mount-util.c @@ -38,7 +38,7 @@ int umount_recursive(const char *prefix, int flags) { again = false; - r = libmount_parse(NULL, NULL, &table, &iter); + r = libmount_parse("/proc/self/mountinfo", NULL, &table, &iter); if (r < 0) return log_debug_errno(r, "Failed to parse /proc/self/mountinfo: %m"); -- 2.47.3