diff options
| author | Martin Pitt <martin.pitt@ubuntu.com> | 2016-09-26 11:03:38 +0200 |
|---|---|---|
| committer | Martin Pitt <martin.pitt@ubuntu.com> | 2016-09-26 11:03:38 +0200 |
| commit | 6dcdb85902c500fa079a85a3e9cecb72da1a7e84 (patch) | |
| tree | 28bcef07184a2291913db43c90432d4005604b59 | |
| parent | b99004a63a43848a1ae5b158d4da38a9a16ade8b (diff) | |
Read config and system connections from /run/NetworkManager/ to support netplan
Add Read-config-from-run.patch and Read-system-connections-from-run.patch.
Backported from yakkety.
LP: #1627641
| -rw-r--r-- | debian/patches/Read-config-from-run.patch | 61 | ||||
| -rw-r--r-- | debian/patches/Read-system-connections-from-run.patch | 62 | ||||
| -rw-r--r-- | debian/patches/series | 2 |
3 files changed, 125 insertions, 0 deletions
diff --git a/debian/patches/Read-config-from-run.patch b/debian/patches/Read-config-from-run.patch new file mode 100644 index 000000000..f4579a804 --- /dev/null +++ b/debian/patches/Read-config-from-run.patch @@ -0,0 +1,61 @@ +From: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com> +Date: Tue, 14 Jun 2016 15:01:20 +0300 +Subject: Read config from /run + +Signed-off-by: Mathieu Trudel-Lapierre <mathieu.trudel-lapierre@canonical.com> +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1591898 +--- + src/nm-config.c | 19 +++++++++++++++++++ + 1 file changed, 19 insertions(+) + +diff --git a/src/nm-config.c b/src/nm-config.c +index 247b9a8..b72bb43 100644 +--- a/src/nm-config.c ++++ b/src/nm-config.c +@@ -39,6 +39,7 @@ + #define DEFAULT_SYSTEM_CONFIG_DIR NMLIBDIR "/conf.d" + #define DEFAULT_NO_AUTO_DEFAULT_FILE NMSTATEDIR "/no-auto-default.state" + #define DEFAULT_INTERN_CONFIG_FILE NMSTATEDIR "/NetworkManager-intern.conf" ++#define RUN_CONFIG_DIR NMRUNDIR "/conf.d" + + struct NMConfigCmdLineOptions { + char *config_main_file; +@@ -897,6 +898,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; +@@ -918,6 +920,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]; +@@ -935,6 +938,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); diff --git a/debian/patches/Read-system-connections-from-run.patch b/debian/patches/Read-system-connections-from-run.patch new file mode 100644 index 000000000..21276a3db --- /dev/null +++ b/debian/patches/Read-system-connections-from-run.patch @@ -0,0 +1,62 @@ +From: Martin Pitt <martin.pitt@ubuntu.com> +Date: Tue, 21 Jun 2016 17:22:12 +0200 +Subject: Read system-connections from /run + +Bug-Ubuntu: https://launchpad.net/bugs/1594551 +--- + src/nm-config.c | 5 +++-- + src/settings/plugins/keyfile/plugin.c | 18 ++++++++++++++++++ + 2 files changed, 21 insertions(+), 2 deletions(-) + +diff --git a/src/nm-config.c b/src/nm-config.c +index b72bb43..1d5e97a 100644 +--- a/src/nm-config.c ++++ b/src/nm-config.c +@@ -925,8 +925,9 @@ read_entire_config (const NMConfigCmdLineOptions *cli, + for (i = 0; i < system_confs->len; ) { + const char *filename = system_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) { ++ /* if a same named file exists in config_dir or RUN_CONFIG_DIR, skip it. */ ++ if (_nm_utils_strv_find_first ((char **) confs->pdata, confs->len, filename) >= 0 || ++ _nm_utils_strv_find_first ((char **) run_confs->pdata, run_confs->len, filename) >= 0) { + g_ptr_array_remove_index (system_confs, i); + continue; + } +diff --git a/src/settings/plugins/keyfile/plugin.c b/src/settings/plugins/keyfile/plugin.c +index 6003c74..8a968c1 100644 +--- a/src/settings/plugins/keyfile/plugin.c ++++ b/src/settings/plugins/keyfile/plugin.c +@@ -386,6 +386,8 @@ _sort_paths (const char **f1, const char **f2, GHashTable *paths) + return strcmp (*f1, *f2); + } + ++#define NM_CONFIG_KEYFILE_PATH_RUNTIME "/run/NetworkManager/system-connections" ++ + static void + read_connections (NMSettingsPlugin *config) + { +@@ -421,6 +423,22 @@ read_connections (NMSettingsPlugin *config) + } + g_dir_close (dir); + ++ /* Now add files from /run too, unless they have a file in /etc */ ++ dir = g_dir_open (NM_CONFIG_KEYFILE_PATH_RUNTIME, 0, &error); ++ if (dir) { ++ while ((item = g_dir_read_name (dir))) { ++ g_autofree char *etc_file = g_build_filename (nm_keyfile_plugin_get_path (), item, NULL); ++ if (nm_keyfile_plugin_utils_should_ignore_file (item) || g_access (etc_file, F_OK) == 0) ++ continue; ++ g_ptr_array_add (filenames, g_build_filename (NM_CONFIG_KEYFILE_PATH_RUNTIME, item, NULL)); ++ } ++ g_dir_close (dir); ++ } else { ++ nm_log_dbg (LOGD_SETTINGS, "keyfile: cannot read directory " NM_CONFIG_KEYFILE_PATH_RUNTIME ": %s", ++ error->message); ++ g_clear_error (&error); ++ } ++ + /* While reloading, we don't replace connections that we already loaded while + * iterating over the files. + * diff --git a/debian/patches/series b/debian/patches/series index c83de59f5..ed0d59692 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -10,6 +10,8 @@ Check-at-runtime-whether-to-start-ModemManager.patch Don-t-make-NetworkManager-D-Bus-activatable.patch Don-t-block-network.target-on-NetworkManager-wait-on.patch Fix-iscsiadm-path.patch +Read-config-from-run.patch +Read-system-connections-from-run.patch # ubuntu-specific whoopsie-daisy-dbus-support.patch |
