diff --git a/src/basic/mountpoint-util.c b/src/basic/mountpoint-util.c index 0c9fc0a350..1136454b7d 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 c7b24584da..19709195e8 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 4b41cfe778..41eeb1ee94 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);