From edac5c4636d7b31086cb0bd25646318d664e075a Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 15 Dec 2022 02:48:59 +0900 Subject: [PATCH] mountpoint-util: introduce mount_propagation_flag_is_valid() --- src/basic/mountpoint-util.c | 4 ++++ src/basic/mountpoint-util.h | 1 + src/core/dbus-execute.c | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/basic/mountpoint-util.c b/src/basic/mountpoint-util.c index 0c9fc0a3505..1136454b7df 100644 --- a/src/basic/mountpoint-util.c +++ b/src/basic/mountpoint-util.c @@ -598,3 +598,7 @@ int mount_propagation_flag_from_string(const char *name, unsigned long *ret) { return -EINVAL; return 0; } + +bool mount_propagation_flag_is_valid(unsigned long flag) { + return IN_SET(flag, 0, MS_SHARED, MS_PRIVATE, MS_SLAVE); +} diff --git a/src/basic/mountpoint-util.h b/src/basic/mountpoint-util.h index c7b24584da2..19709195e84 100644 --- a/src/basic/mountpoint-util.h +++ b/src/basic/mountpoint-util.h @@ -57,3 +57,4 @@ int mount_nofollow(const char *source, const char *target, const char *filesyste const char *mount_propagation_flag_to_string(unsigned long flags); int mount_propagation_flag_from_string(const char *name, unsigned long *ret); +bool mount_propagation_flag_is_valid(unsigned long flag); diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c index 4b41cfe778c..41eeb1ee941 100644 --- a/src/core/dbus-execute.c +++ b/src/core/dbus-execute.c @@ -1600,7 +1600,7 @@ static int parse_personality(const char *s, unsigned long *p) { } static const char* mount_propagation_flag_to_string_with_check(unsigned long n) { - if (!IN_SET(n, 0, MS_SHARED, MS_PRIVATE, MS_SLAVE)) + if (!mount_propagation_flag_is_valid(n)) return NULL; return mount_propagation_flag_to_string(n); -- 2.47.3