From: Yu Watanabe Date: Wed, 14 Dec 2022 17:48:59 +0000 (+0900) Subject: mountpoint-util: introduce mount_propagation_flag_is_valid() X-Git-Tag: v253-rc1~274^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=edac5c4636d7b31086cb0bd25646318d664e075a;p=thirdparty%2Fsystemd.git mountpoint-util: introduce mount_propagation_flag_is_valid() --- 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);