From 6b0f84bddaae8d315aaa28997b0ab7e71d3be091 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 17 Apr 2015 13:24:32 +0200 Subject: [PATCH] config: fix filename order for config-description The configuration snippets are loaded in alphabetical order. Fix the printed description to reflect that order. Otherwise, NM logs at startup: Read config: /etc/NetworkManager/NetworkManager.conf and conf.d: 20-connectivity-fedora.conf, 10-ibft-plugin.conf --- src/nm-config.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/nm-config.c b/src/nm-config.c index eabb378664..3dbe58fb90 100644 --- a/src/nm-config.c +++ b/src/nm-config.c @@ -571,6 +571,7 @@ _get_config_dir_files (const char *config_main_file, GPtrArray *confs; GString *config_description; const char *name; + guint i; g_return_val_if_fail (config_main_file, NULL); g_return_val_if_fail (config_dir, NULL); @@ -583,21 +584,27 @@ _get_config_dir_files (const char *config_main_file, if (direnum) { while ((info = g_file_enumerator_next_file (direnum, NULL, NULL))) { name = g_file_info_get_name (info); - if (g_str_has_suffix (name, ".conf")) { - g_ptr_array_add (confs, g_build_filename (config_dir, name, NULL)); - if (confs->len == 1) - g_string_append (config_description, " and conf.d: "); - else - g_string_append (config_description, ", "); - g_string_append (config_description, name); - } + if (g_str_has_suffix (name, ".conf")) + g_ptr_array_add (confs, g_strdup (name)); g_object_unref (info); } g_object_unref (direnum); } g_object_unref (dir); - g_ptr_array_sort (confs, sort_asciibetically); + if (confs->len > 0) { + g_ptr_array_sort (confs, sort_asciibetically); + g_string_append (config_description, " and conf.d: "); + for (i = 0; i < confs->len; i++) { + char *n = confs->pdata[i]; + + if (i > 0) + g_string_append (config_description, ", "); + g_string_append (config_description, n); + confs->pdata[i] = g_build_filename (config_dir, n, NULL); + g_free (n); + } + } *out_config_description = g_string_free (config_description, FALSE); return confs;