summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2019-12-11 11:40:22 +0100
committerThomas Haller <thaller@redhat.com>2019-12-11 11:52:05 +0100
commit8f96d3cb0c40ef19ab6524a39eeae9b03da1b4f3 (patch)
tree3aa9e1b02dcffc8cfaff86316528bdd566e17f57
parent8d20b9363b4461c7e86f2310a2fbfe88a09d5284 (diff)
downloadNetworkManager-8f96d3cb0c40ef19ab6524a39eeae9b03da1b4f3.tar.gz
config: emit warning about invalid main.auth-polkit setting
-rw-r--r--src/nm-config-data.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/nm-config-data.c b/src/nm-config-data.c
index d8146457a3..c787aa98ac 100644
--- a/src/nm-config-data.c
+++ b/src/nm-config-data.c
@@ -407,8 +407,9 @@ nm_auth_polkit_mode_from_string (const char *str)
return NM_AUTH_POLKIT_MODE_UNKNOWN;
}
-NMAuthPolkitMode
-nm_config_data_get_main_auth_polkit (const NMConfigData *self)
+static NMAuthPolkitMode
+_config_data_get_main_auth_polkit (const NMConfigData *self,
+ gboolean *out_invalid_config)
{
NMAuthPolkitMode auth_polkit_mode;
const char *str;
@@ -420,16 +421,24 @@ nm_config_data_get_main_auth_polkit (const NMConfigData *self)
| NM_CONFIG_GET_VALUE_NO_EMPTY);
auth_polkit_mode = nm_auth_polkit_mode_from_string (str);
if (auth_polkit_mode == NM_AUTH_POLKIT_MODE_UNKNOWN) {
+ NM_SET_OUT (out_invalid_config, (str != NULL));
auth_polkit_mode = nm_auth_polkit_mode_from_string (NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT);
if (auth_polkit_mode == NM_AUTH_POLKIT_MODE_UNKNOWN) {
nm_assert_not_reached ();
auth_polkit_mode = NM_AUTH_POLKIT_MODE_ROOT_ONLY;
}
- }
+ } else
+ NM_SET_OUT (out_invalid_config, FALSE);
return auth_polkit_mode;
}
+NMAuthPolkitMode
+nm_config_data_get_main_auth_polkit (const NMConfigData *self)
+{
+ return _config_data_get_main_auth_polkit (self, NULL);
+}
+
/*****************************************************************************/
/**
@@ -1602,6 +1611,18 @@ void
nm_config_data_get_warnings (const NMConfigData *self,
GPtrArray *warnings)
{
+ gboolean invalid;
+
+ nm_assert (NM_IS_CONFIG_DATA (self));
+ nm_assert (warnings);
+
+ _config_data_get_main_auth_polkit (self, &invalid);
+ if (invalid) {
+ g_ptr_array_add (warnings,
+ g_strdup_printf ("invalid setting for %s.%s (should be one of \"true\", \"false\", \"root-only\")",
+ NM_CONFIG_KEYFILE_GROUP_MAIN,
+ NM_CONFIG_KEYFILE_KEY_MAIN_AUTH_POLKIT));
+ }
}
/*****************************************************************************/