From: Yu Watanabe Date: Fri, 15 Jun 2018 03:29:29 +0000 (+0900) Subject: namespace: drop protect_{home,system}_or_bool_from_string() X-Git-Tag: v239~49 X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fsystemd.git;a=commitdiff_plain;h=1e8c7bd55c288869d69aed3b943d3d970c3a98ae namespace: drop protect_{home,system}_or_bool_from_string() The functions protect_{home,system}_from_string() are not used except for defining protect_{home,system}_or_bool_from_string(). This makes protect_{home,system}_from_string() support boolean strings, and drops protect_{home,system}_or_bool_from_string(). --- diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c index e2afeba19c6..c44970c10c8 100644 --- a/src/core/dbus-execute.c +++ b/src/core/dbus-execute.c @@ -1020,8 +1020,8 @@ static BUS_DEFINE_SET_TRANSIENT_IS_VALID(nice, "i", int32_t, int, "%" PRIi32, ni static BUS_DEFINE_SET_TRANSIENT_PARSE(std_input, ExecInput, exec_input_from_string); static BUS_DEFINE_SET_TRANSIENT_PARSE(std_output, ExecOutput, exec_output_from_string); static BUS_DEFINE_SET_TRANSIENT_PARSE(utmp_mode, ExecUtmpMode, exec_utmp_mode_from_string); -static BUS_DEFINE_SET_TRANSIENT_PARSE(protect_system, ProtectSystem, protect_system_or_bool_from_string); -static BUS_DEFINE_SET_TRANSIENT_PARSE(protect_home, ProtectHome, protect_home_or_bool_from_string); +static BUS_DEFINE_SET_TRANSIENT_PARSE(protect_system, ProtectSystem, protect_system_from_string); +static BUS_DEFINE_SET_TRANSIENT_PARSE(protect_home, ProtectHome, protect_home_from_string); static BUS_DEFINE_SET_TRANSIENT_PARSE(keyring_mode, ExecKeyringMode, exec_keyring_mode_from_string); static BUS_DEFINE_SET_TRANSIENT_PARSE(preserve_mode, ExecPreserveMode, exec_preserve_mode_from_string); static BUS_DEFINE_SET_TRANSIENT_PARSE_PTR(personality, unsigned long, parse_personality); diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index beb08dfe9b0..d9a5094aa09 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -82,8 +82,8 @@ DEFINE_CONFIG_PARSE_ENUM(config_parse_exec_utmp_mode, exec_utmp_mode, ExecUtmpMo DEFINE_CONFIG_PARSE_ENUM(config_parse_job_mode, job_mode, JobMode, "Failed to parse job mode"); DEFINE_CONFIG_PARSE_ENUM(config_parse_kill_mode, kill_mode, KillMode, "Failed to parse kill mode"); DEFINE_CONFIG_PARSE_ENUM(config_parse_notify_access, notify_access, NotifyAccess, "Failed to parse notify access specifier"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_protect_home, protect_home_or_bool, ProtectHome, "Failed to parse protect home value"); -DEFINE_CONFIG_PARSE_ENUM(config_parse_protect_system, protect_system_or_bool, ProtectSystem, "Failed to parse protect system value"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_protect_home, protect_home, ProtectHome, "Failed to parse protect home value"); +DEFINE_CONFIG_PARSE_ENUM(config_parse_protect_system, protect_system, ProtectSystem, "Failed to parse protect system value"); DEFINE_CONFIG_PARSE_ENUM(config_parse_runtime_preserve_mode, exec_preserve_mode, ExecPreserveMode, "Failed to parse runtime directory preserve mode"); DEFINE_CONFIG_PARSE_ENUM(config_parse_service_type, service_type, ServiceType, "Failed to parse service type"); DEFINE_CONFIG_PARSE_ENUM(config_parse_service_restart, service_restart, ServiceRestart, "Failed to parse service restart specifier"); diff --git a/src/core/namespace.c b/src/core/namespace.c index db15ed85380..8e771b3d883 100644 --- a/src/core/namespace.c +++ b/src/core/namespace.c @@ -1672,19 +1672,7 @@ static const char *const protect_home_table[_PROTECT_HOME_MAX] = { [PROTECT_HOME_TMPFS] = "tmpfs", }; -DEFINE_STRING_TABLE_LOOKUP(protect_home, ProtectHome); - -ProtectHome protect_home_or_bool_from_string(const char *s) { - int r; - - r = parse_boolean(s); - if (r > 0) - return PROTECT_HOME_YES; - if (r == 0) - return PROTECT_HOME_NO; - - return protect_home_from_string(s); -} +DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(protect_home, ProtectHome, PROTECT_HOME_YES); static const char *const protect_system_table[_PROTECT_SYSTEM_MAX] = { [PROTECT_SYSTEM_NO] = "no", @@ -1693,19 +1681,7 @@ static const char *const protect_system_table[_PROTECT_SYSTEM_MAX] = { [PROTECT_SYSTEM_STRICT] = "strict", }; -DEFINE_STRING_TABLE_LOOKUP(protect_system, ProtectSystem); - -ProtectSystem protect_system_or_bool_from_string(const char *s) { - int r; - - r = parse_boolean(s); - if (r > 0) - return PROTECT_SYSTEM_YES; - if (r == 0) - return PROTECT_SYSTEM_NO; - - return protect_system_from_string(s); -} +DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(protect_system, ProtectSystem, PROTECT_SYSTEM_YES); static const char* const namespace_type_table[] = { [NAMESPACE_MOUNT] = "mnt", diff --git a/src/core/namespace.h b/src/core/namespace.h index b45eb57c732..1188c6d5958 100644 --- a/src/core/namespace.h +++ b/src/core/namespace.h @@ -95,11 +95,9 @@ int setup_netns(int netns_storage_socket[2]); const char* protect_home_to_string(ProtectHome p) _const_; ProtectHome protect_home_from_string(const char *s) _pure_; -ProtectHome protect_home_or_bool_from_string(const char *s); const char* protect_system_to_string(ProtectSystem p) _const_; ProtectSystem protect_system_from_string(const char *s) _pure_; -ProtectSystem protect_system_or_bool_from_string(const char *s); void bind_mount_free_many(BindMount *b, size_t n); int bind_mount_add(BindMount **b, size_t *n, const BindMount *item);