config: read /run/NetworkManager/conf.d files

This is useful for configuration that gets auto-generated from another source.
These are then not primary configuration files and thus should not be put into
/etc.

This mirrors the structure of udev rules or systemd units, which can also be in
/usr, /run/, or /etc/.

Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com>

https://bugzilla.gnome.org/show_bug.cgi?id=773069
This commit is contained in:
Mathieu Trudel-Lapierre 2016-06-14 15:01:20 +03:00 committed by Thomas Haller
parent 4b965d0cf6
commit feff60ef3e

View file

@ -36,6 +36,7 @@
#define DEFAULT_CONFIG_DIR NMCONFDIR "/conf.d"
#define DEFAULT_CONFIG_MAIN_FILE_OLD NMCONFDIR "/nm-system-settings.conf"
#define DEFAULT_SYSTEM_CONFIG_DIR NMLIBDIR "/conf.d"
#define RUN_CONFIG_DIR NMRUNDIR "/conf.d"
#define DEFAULT_NO_AUTO_DEFAULT_FILE NMSTATEDIR "/no-auto-default.state"
#define DEFAULT_INTERN_CONFIG_FILE NMSTATEDIR "/NetworkManager-intern.conf"
#define DEFAULT_STATE_FILE NMSTATEDIR "/NetworkManager.state"
@ -937,6 +938,7 @@ read_entire_config (const NMConfigCmdLineOptions *cli,
GKeyFile *keyfile;
gs_unref_ptrarray GPtrArray *system_confs = NULL;
gs_unref_ptrarray GPtrArray *confs = NULL;
gs_unref_ptrarray GPtrArray *run_confs = NULL;
guint i;
gs_free char *o_config_main_file = NULL;
GString *str;
@ -952,6 +954,7 @@ read_entire_config (const NMConfigCmdLineOptions *cli,
system_confs = _get_config_dir_files (system_config_dir);
confs = _get_config_dir_files (config_dir);
run_confs = _get_config_dir_files (RUN_CONFIG_DIR);
for (i = 0; i < system_confs->len; ) {
const char *filename = system_confs->pdata[i];
@ -969,6 +972,22 @@ read_entire_config (const NMConfigCmdLineOptions *cli,
i++;
}
for (i = 0; i < run_confs->len; ) {
const char *filename = run_confs->pdata[i];
/* if a same named file exists in config_dir, skip it. */
if (_nm_utils_strv_find_first ((char **) confs->pdata, confs->len, filename) >= 0) {
g_ptr_array_remove_index (run_confs, i);
continue;
}
if (!read_config (keyfile, FALSE, RUN_CONFIG_DIR, filename, error)) {
g_key_file_free (keyfile);
return NULL;
}
i++;
}
/* First read the base config file */
if (!read_base_config (keyfile, cli ? cli->config_main_file : NULL, &o_config_main_file, error)) {
g_key_file_free (keyfile);