core: merge branch 'bg/config-show-default-bgo772144'
https://bugzilla.gnome.org/show_bug.cgi?id=772144
This commit is contained in:
11
configure.ac
11
configure.ac
@@ -134,7 +134,7 @@ test "$enable_ifupdown" = "yes" && distro_plugins="$distro_plugins,ifu
|
||||
test "$enable_ifnet" = "yes" && distro_plugins="$distro_plugins,ifnet"
|
||||
distro_plugins="${distro_plugins#,}"
|
||||
|
||||
AC_DEFINE_UNQUOTED(CONFIG_PLUGINS_DEFAULT, "$config_plugins_default", [Default configuration option for main.plugins setting])
|
||||
AC_DEFINE_UNQUOTED(NM_CONFIG_PLUGINS_DEFAULT, "$config_plugins_default", [Default configuration option for main.plugins setting])
|
||||
if test "${enable_config_plugin_ibft}" = yes; then
|
||||
AC_DEFINE(WITH_SETTINGS_PLUGIN_IBFT, 1, [Whether compilation of ibft setting plugin is enabled])
|
||||
else
|
||||
@@ -579,18 +579,17 @@ AC_ARG_ENABLE(polkit, AS_HELP_STRING([--enable-polkit=yes|no|disabled], [set def
|
||||
[enable_polkit=${enableval}], [enable_polkit=yes])
|
||||
if (test "${enable_polkit}" != "no" -a "${enable_polkit}" != "disabled"); then
|
||||
enable_polkit=yes
|
||||
AC_DEFINE(NM_CONFIG_DEFAULT_AUTH_POLKIT, TRUE, [The default value of the auth-polkit configuration option])
|
||||
NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT='true'
|
||||
AC_DEFINE(NM_CONFIG_DEFAULT_AUTH_POLKIT, "true", [The default value of the auth-polkit configuration option])
|
||||
AC_SUBST(NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT, true)
|
||||
else
|
||||
AC_DEFINE(NM_CONFIG_DEFAULT_AUTH_POLKIT, FALSE, [The default value of the auth-polkit configuration option])
|
||||
NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT='false'
|
||||
AC_DEFINE(NM_CONFIG_DEFAULT_AUTH_POLKIT, "false", [The default value of the auth-polkit configuration option])
|
||||
AC_SUBST(NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT, false)
|
||||
fi
|
||||
if (test "${enable_polkit}" != "disabled"); then
|
||||
AC_DEFINE(WITH_POLKIT, 1, [whether to compile polkit support])
|
||||
else
|
||||
AC_DEFINE(WITH_POLKIT, 0, [whether to compile polkit support])
|
||||
fi
|
||||
AC_SUBST(NM_CONFIG_DEFAULT_AUTH_POLKIT_TEXT)
|
||||
|
||||
PKG_CHECK_MODULES(POLKIT, [polkit-agent-1 >= 0.97], [have_pk_agent=yes],[have_pk_agent=no])
|
||||
AC_ARG_ENABLE(polkit-agent, AS_HELP_STRING([--enable-polkit-agent], [enable polkit agent for clients]),
|
||||
|
@@ -535,6 +535,17 @@ _nm_config_data_log_sort (const char **pa, const char **pb, gpointer dummy)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct {
|
||||
const char *group;
|
||||
const char *key;
|
||||
const char *value;
|
||||
} default_values[] = {
|
||||
{ NM_CONFIG_KEYFILE_GROUP_MAIN, "plugins", NM_CONFIG_PLUGINS_DEFAULT },
|
||||
{ NM_CONFIG_KEYFILE_GROUP_MAIN, "rc-manager", NM_CONFIG_DEFAULT_DNS_RC_MANAGER },
|
||||
{ NM_CONFIG_KEYFILE_GROUP_MAIN, "auth-polkit", NM_CONFIG_DEFAULT_AUTH_POLKIT },
|
||||
{ NM_CONFIG_KEYFILE_GROUP_LOGGING, "backend", NM_CONFIG_LOGGING_BACKEND_DEFAULT },
|
||||
};
|
||||
|
||||
void
|
||||
nm_config_data_log (const NMConfigData *self,
|
||||
const char *prefix,
|
||||
@@ -544,7 +555,7 @@ nm_config_data_log (const NMConfigData *self,
|
||||
const NMConfigDataPrivate *priv;
|
||||
gs_strfreev char **groups = NULL;
|
||||
gsize ngroups;
|
||||
guint g, k;
|
||||
guint g, k, i;
|
||||
FILE *stream = print_stream;
|
||||
|
||||
g_return_if_fail (NM_IS_CONFIG_DATA (self));
|
||||
@@ -591,6 +602,15 @@ nm_config_data_log (const NMConfigData *self,
|
||||
_LOG (stream, prefix, "");
|
||||
_LOG (stream, prefix, "[%s]%s", group, is_atomic && !stream ? " # atomic section" : "");
|
||||
|
||||
/* Print default values as comments */
|
||||
for (i = 0; i < G_N_ELEMENTS (default_values); i++) {
|
||||
if ( nm_streq (default_values[i].group, group)
|
||||
&& !g_key_file_has_key (priv->keyfile, group, default_values[i].key, NULL)) {
|
||||
_LOG (stream, prefix, "%s# %s=%s", key_prefix, default_values[i].key,
|
||||
default_values[i].value);
|
||||
}
|
||||
}
|
||||
|
||||
keys = g_key_file_get_keys (priv->keyfile, group, NULL, NULL);
|
||||
for (k = 0; keys && keys[k]; k++) {
|
||||
const char *key = keys[k];
|
||||
|
@@ -285,7 +285,7 @@ nm_config_get_monitor_connection_files (NMConfig *config)
|
||||
gboolean
|
||||
nm_config_get_auth_polkit (NMConfig *config)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_CONFIG (config), NM_CONFIG_DEFAULT_AUTH_POLKIT);
|
||||
g_return_val_if_fail (NM_IS_CONFIG (config), NM_CONFIG_DEFAULT_AUTH_POLKIT_BOOL);
|
||||
|
||||
return NM_CONFIG_GET_PRIVATE (config)->auth_polkit;
|
||||
}
|
||||
@@ -512,7 +512,7 @@ nm_config_cmd_line_options_add_to_entries (NMConfigCmdLineOptions *cli,
|
||||
{ "intern-config", 0, 0, G_OPTION_ARG_FILENAME, &cli->intern_config_file, N_("Internal config file location"), N_(DEFAULT_INTERN_CONFIG_FILE) },
|
||||
{ "state-file", 0, 0, G_OPTION_ARG_FILENAME, &cli->state_file, N_("State file location"), N_(DEFAULT_STATE_FILE) },
|
||||
{ "no-auto-default", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_FILENAME, &cli->no_auto_default_file, N_("State file for no-auto-default devices"), N_(DEFAULT_NO_AUTO_DEFAULT_FILE) },
|
||||
{ "plugins", 0, 0, G_OPTION_ARG_STRING, &cli->plugins, N_("List of plugins separated by ','"), N_(CONFIG_PLUGINS_DEFAULT) },
|
||||
{ "plugins", 0, 0, G_OPTION_ARG_STRING, &cli->plugins, N_("List of plugins separated by ','"), N_(NM_CONFIG_PLUGINS_DEFAULT) },
|
||||
{ "configure-and-quit", 0, 0, G_OPTION_ARG_NONE, &cli->configure_and_quit, N_("Quit after initial configuration"), NULL },
|
||||
{ "debug", 'd', 0, G_OPTION_ARG_NONE, &cli->is_debug, N_("Don't become a daemon, and log to stderr"), NULL },
|
||||
|
||||
@@ -947,7 +947,6 @@ read_entire_config (const NMConfigCmdLineOptions *cli,
|
||||
guint i;
|
||||
gs_free char *o_config_main_file = NULL;
|
||||
GString *str;
|
||||
char **plugins_default;
|
||||
|
||||
g_return_val_if_fail (config_dir, NULL);
|
||||
g_return_val_if_fail (system_config_dir, NULL);
|
||||
@@ -958,11 +957,6 @@ read_entire_config (const NMConfigCmdLineOptions *cli,
|
||||
/* create a default configuration file. */
|
||||
keyfile = nm_config_create_keyfile ();
|
||||
|
||||
plugins_default = g_strsplit (CONFIG_PLUGINS_DEFAULT, ",", -1);
|
||||
if (plugins_default && plugins_default[0])
|
||||
nm_config_keyfile_set_string_list (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "plugins", (const char *const*) plugins_default, -1);
|
||||
g_strfreev (plugins_default);
|
||||
|
||||
system_confs = _get_config_dir_files (system_config_dir);
|
||||
confs = _get_config_dir_files (config_dir);
|
||||
|
||||
@@ -2305,12 +2299,10 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
|
||||
|
||||
priv->plugins = _nm_utils_strv_cleanup (g_key_file_get_string_list (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "plugins", NULL, NULL),
|
||||
TRUE, TRUE, TRUE);
|
||||
if (!priv->plugins)
|
||||
priv->plugins = g_new0 (char *, 1);
|
||||
|
||||
priv->monitor_connection_files = nm_config_keyfile_get_boolean (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "monitor-connection-files", FALSE);
|
||||
|
||||
priv->auth_polkit = nm_config_keyfile_get_boolean (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "auth-polkit", NM_CONFIG_DEFAULT_AUTH_POLKIT);
|
||||
priv->auth_polkit = nm_config_keyfile_get_boolean (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "auth-polkit", NM_CONFIG_DEFAULT_AUTH_POLKIT_BOOL);
|
||||
|
||||
priv->dhcp_client = nm_strstrip (g_key_file_get_string (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "dhcp", NULL));
|
||||
|
||||
@@ -2351,7 +2343,7 @@ nm_config_init (NMConfig *config)
|
||||
{
|
||||
NMConfigPrivate *priv = NM_CONFIG_GET_PRIVATE (config);
|
||||
|
||||
priv->auth_polkit = NM_CONFIG_DEFAULT_AUTH_POLKIT;
|
||||
priv->auth_polkit = NM_CONFIG_DEFAULT_AUTH_POLKIT_BOOL;
|
||||
}
|
||||
|
||||
NMConfig *
|
||||
|
@@ -182,6 +182,7 @@ extern char *_nm_config_match_env;
|
||||
/*****************************************************************************/
|
||||
|
||||
#define NM_CONFIG_DEVICE_STATE_DIR ""NMRUNDIR"/devices"
|
||||
#define NM_CONFIG_DEFAULT_AUTH_POLKIT_BOOL (nm_streq0 (NM_CONFIG_DEFAULT_AUTH_POLKIT, "true"))
|
||||
|
||||
typedef enum {
|
||||
NM_CONFIG_DEVICE_STATE_MANAGED_TYPE_UNKNOWN = -1,
|
||||
|
@@ -2292,11 +2292,19 @@ nm_settings_start (NMSettings *self, GError **error)
|
||||
GDBusProxy *proxy;
|
||||
GVariant *variant;
|
||||
GError *local_error = NULL;
|
||||
const char **plugins;
|
||||
gs_strfreev char **plugins_default = NULL;
|
||||
|
||||
priv = NM_SETTINGS_GET_PRIVATE (self);
|
||||
|
||||
/* Load the plugins; fail if a plugin is not found. */
|
||||
if (!load_plugins (self, nm_config_get_plugins (priv->config), error)) {
|
||||
plugins = nm_config_get_plugins (priv->config);
|
||||
if (!plugins) {
|
||||
plugins_default = g_strsplit (NM_CONFIG_PLUGINS_DEFAULT, ",", -1);
|
||||
plugins = (const char **) plugins_default;
|
||||
}
|
||||
|
||||
if (!load_plugins (self, plugins, error)) {
|
||||
g_object_unref (self);
|
||||
return FALSE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user