Merge ~alfonsosanchezbeato/snappy-hwe-snaps/+git/network-manager:use-auto-import into ~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager:snap-1.10

Proposed by Alfonso Sanchez-Beato
Status: Merged
Approved by: Alfonso Sanchez-Beato
Approved revision: 08a1cbcec51b16ebdc07f14e91c63230a4c5e4e7
Merged at revision: 0e470f9978020b578fe93962116ef82223d34a3d
Proposed branch: ~alfonsosanchezbeato/snappy-hwe-snaps/+git/network-manager:use-auto-import
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager:snap-1.10
Diff against target: 2609 lines (+1075/-966)
12 files modified
dev/null (+0/-34)
snap-common/bin/networkmanager (+4/-2)
snap-common/bin/snap-config.sh (+6/-2)
snap-patch/networkmanager/0001-Support-for-WoWLAN.patch (+35/-31)
snap-patch/networkmanager/0002-Disable-non-working-test-on-Jenkins-instance.patch (+17/-4)
snap-patch/networkmanager/0003-Disable-non-working-test-on-Jenkins-instance.patch (+26/-0)
snap-patch/networkmanager/0004-Add-snap-support.patch (+820/-790)
snap-patch/networkmanager/0005-Disable-tests-that-fail-on-LP-build.patch (+22/-5)
snap-patch/networkmanager/0006-Add-snap-support-for-ppp.patch (+63/-49)
snap/snapcraft.yaml (+59/-47)
tests/main/can-exec-iptables/task.yaml (+1/-2)
unstage.txt (+22/-0)
Reviewer Review Type Date Requested Status
System Enablement Bot continuous-integration Approve
Review via email: mp+378377@code.launchpad.net

Commit message

Remove patches from the debian folder
We take them from snap-patch now.

Add phony part to stage compiled packages

Remove version-script
version-script is now deprecated.

Add patches specific to the NM snap to snap-patch

Follow applied branches from auto-import repos

tests: run iptables from core snap now

Set rc-manager=symlink for UC18 and later
Otherwise, NM will call resolvconf even though it fails if UC version is
newer than 16. To properly set DNS we need to set both dns and
rc-manager options, but we were doing this only for the former. However,
this did not have adverse effects as, as said, the call to resolvconf
failed, while systemd-resolved was properly updated.

Do not call dhcp-lease-mover anymore
As it was not actually working anymore since we were not staging inotify
anymore since a while.

Specify explicitly copyrights to include
Previously there were copyright files included from non-staged
packages.

Add unstage.txt file
This file contains a list of debian package that we are not actually
staging, although snapcraft adds them to manifest.yaml. CI now
recognizes this file, and manually removes the listed packages from the
manifest when releasing a snap to the store.

Do not stage iptables/xtables
iptables and all needed libraries are now included in the core18 snap,
since revision 1049 (2019-06-27).

Do not stage libs already in core18
The libraries were not really included finally in the snap, but they
were triggering CVE warnings from the review tools that did not actually
apply.

snap: call netplan apply using DBus
Use DBus netplan interface to re-start network services after setting
NetworkManager as the default renderer.

snap: add network-setup-control interface
Add network-setup-control interface so we can call 'netplan apply' from
the snap.

Description of the change

Remove patches from the debian folder
We take them from snap-patch now.

Add phony part to stage compiled packages

Remove version-script
version-script is now deprecated.

Add patches specific to the NM snap to snap-patch

Follow applied branches from auto-import repos

tests: run iptables from core snap now

Set rc-manager=symlink for UC18 and later
Otherwise, NM will call resolvconf even though it fails if UC version is
newer than 16. To properly set DNS we need to set both dns and
rc-manager options, but we were doing this only for the former. However,
this did not have adverse effects as, as said, the call to resolvconf
failed, while systemd-resolved was properly updated.

Do not call dhcp-lease-mover anymore
As it was not actually working anymore since we were not staging inotify
anymore since a while.

Specify explicitly copyrights to include
Previously there were copyright files included from non-staged
packages.

Add unstage.txt file
This file contains a list of debian package that we are not actually
staging, although snapcraft adds them to manifest.yaml. CI now
recognizes this file, and manually removes the listed packages from the
manifest when releasing a snap to the store.

Do not stage iptables/xtables
iptables and all needed libraries are now included in the core18 snap,
since revision 1049 (2019-06-27).

Do not stage libs already in core18
The libraries were not really included finally in the snap, but they
were triggering CVE warnings from the review tools that did not actually
apply.

snap: call netplan apply using DBus
Use DBus netplan interface to re-start network services after setting
NetworkManager as the default renderer.

snap: add network-setup-control interface
Add network-setup-control interface so we can call 'netplan apply' from
the snap.

To post a comment you must log in.
Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/patches/disable-libnm-glib-test-devices-array.patch b/debian/patches/disable-libnm-glib-test-devices-array.patch
2deleted file mode 100644
3index e847fc5..0000000
4--- a/debian/patches/disable-libnm-glib-test-devices-array.patch
5+++ /dev/null
6@@ -1,13 +0,0 @@
7-Index: nm/libnm-glib/tests/test-nm-client.c
8-===================================================================
9---- nm.orig/libnm-glib/tests/test-nm-client.c
10-+++ nm/libnm-glib/tests/test-nm-client.c
11-@@ -1135,7 +1135,7 @@ main (int argc, char **argv)
12- g_test_add_func ("/libnm-glib/device-added", test_device_added);
13- g_test_add_func ("/libnm-glib/wifi-ap-added-removed", test_wifi_ap_added_removed);
14- g_test_add_func ("/libnm-glib/wimax-nsp-added-removed", test_wimax_nsp_added_removed);
15-- g_test_add_func ("/libnm-glib/devices-array", test_devices_array);
16-+ /* g_test_add_func ("/libnm-glib/devices-array", test_devices_array); */
17- g_test_add_func ("/libnm-glib/client-manager-running", test_client_manager_running);
18- g_test_add_func ("/libnm/connection/invalid", test_connection_invalid);
19-
20diff --git a/debian/patches/set-ld-library-path-for-iptables.patch b/debian/patches/set-ld-library-path-for-iptables.patch
21deleted file mode 100644
22index 065816c..0000000
23--- a/debian/patches/set-ld-library-path-for-iptables.patch
24+++ /dev/null
25@@ -1,34 +0,0 @@
26-From: =?UTF-8?q?Alfonso=20S=C3=A1nchez-Beato?= <alfonso.sanchez-beato@canonical.com>
27-Date: Thu, 18 Jul 2019 17:48:39 +0200
28-Subject: [PATCH] snap: pass NM env vars when calling iptables
29-
30-This is necessary so LD_LIBRARY_PATH is passed down to iptables so it is
31-able to find the libraries included in the snap package.
32----
33- src/nm-act-request.c | 3 +--
34- 1 file changed, 1 insertion(+), 2 deletions(-)
35-
36-diff --git a/src/nm-act-request.c b/src/nm-act-request.c
37-index 87070794..bcf3e0bb 100644
38---- a/src/nm-act-request.c
39-+++ b/src/nm-act-request.c
40-@@ -309,7 +309,6 @@ nm_act_request_set_shared (NMActRequest *req, gboolean shared)
41- /* Send the rules to iptables */
42- for (iter = list; iter; iter = g_slist_next (iter)) {
43- ShareRule *rule = (ShareRule *) iter->data;
44-- char *envp[1] = { NULL };
45- gs_strfreev char **argv = NULL;
46- gs_free char *cmd = NULL;
47-
48-@@ -327,7 +326,7 @@ nm_act_request_set_shared (NMActRequest *req, gboolean shared)
49- GError *error = NULL;
50-
51- nm_log_info (LOGD_SHARING, "Executing: %s", cmd);
52-- if (!g_spawn_sync ("/", argv, envp, G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
53-+ if (!g_spawn_sync ("/", argv, NULL, G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL,
54- NULL, NULL, NULL, NULL, &status, &error)) {
55- nm_log_warn (LOGD_SHARING, "Error executing command: %s",
56- error->message);
57---
58-2.17.1
59-
60diff --git a/snap-common/bin/networkmanager b/snap-common/bin/networkmanager
61index bb8131b..7d5315f 100755
62--- a/snap-common/bin/networkmanager
63+++ b/snap-common/bin/networkmanager
64@@ -55,7 +55,8 @@ dns_conf_file="$SNAP_DATA"/conf.d/10-dns.conf
65 if [ "$(get_series_major_version)" = "16" ]; then
66 printf "[main]\ndns=default\nrc-manager=resolvconf\n" > "$dns_conf_file"
67 else
68- printf "[main]\ndns=systemd-resolved\n" > "$dns_conf_file"
69+ printf "[main]\ndns=systemd-resolved\nrc-manager=symlink\n" > \
70+ "$dns_conf_file"
71 fi
72
73 # HACK: Until we've fixed probert to look in $SNAP_DATA/state/dhcp or
74@@ -63,7 +64,8 @@ fi
75 # our lease files and copy all over when something has changed. This
76 # background process gets stopped when our systemd service unit gets
77 # stopped.
78-"$SNAP"/bin/dhcp-lease-mover &
79+# Do not call: dhcp-lease-mover fails as we do not stage inotify anymore
80+#"$SNAP"/bin/dhcp-lease-mover &
81
82 # Identify if we are in debug mode or not
83 LOG_LEVEL=INFO
84diff --git a/snap-common/bin/snap-config.sh b/snap-common/bin/snap-config.sh
85index 7107a2c..647f859 100644
86--- a/snap-common/bin/snap-config.sh
87+++ b/snap-common/bin/snap-config.sh
88@@ -159,11 +159,15 @@ _switch_defaultrenderer() {
89 if [ "$1" = true ] || [ "$1" = yes ]; then
90 if [ ! -f "$path" ]; then
91 printf "network:\n renderer: NetworkManager\n" > "$path"
92- # TODO When implemented by snapd, call netplan apply
93+ dbus-send --system --type=method_call --print-reply \
94+ --dest=io.netplan.Netplan /io/netplan/Netplan \
95+ io.netplan.Netplan.Apply
96 fi
97 elif [ -f "$path" ]; then
98 rm -f "$path"
99- # TODO When implemented by snapd, call netplan apply
100+ dbus-send --system --type=method_call --print-reply \
101+ --dest=io.netplan.Netplan /io/netplan/Netplan \
102+ io.netplan.Netplan.Apply
103 fi
104 }
105
106diff --git a/debian/patches/Support-for-WoWLAN.patch b/snap-patch/networkmanager/0001-Support-for-WoWLAN.patch
107similarity index 90%
108rename from debian/patches/Support-for-WoWLAN.patch
109rename to snap-patch/networkmanager/0001-Support-for-WoWLAN.patch
110index 094f6c8..b1ae2c2 100644
111--- a/debian/patches/Support-for-WoWLAN.patch
112+++ b/snap-patch/networkmanager/0001-Support-for-WoWLAN.patch
113@@ -1,7 +1,8 @@
114-From: =?utf-8?q?Alfonso_S=C3=A1nchez-Beato?=
115+From 705afc81b686388c4f5e5cf1d3e3fb5bd29a7227 Mon Sep 17 00:00:00 2001
116+From: =?UTF-8?q?Alfonso=20S=C3=A1nchez-Beato?=
117 <alfonso.sanchez-beato@canonical.com>
118 Date: Fri, 13 Jul 2018 11:54:30 +0200
119-Subject: Support for WoWLAN
120+Subject: [PATCH 1/6] Support for WoWLAN
121
122 This add supports for WoWLAN by backporting upstream patches:
123
124@@ -17,28 +18,28 @@ c6e40215e devices: restore past WoWLAN when disconnecting wifi
125 a3289400d wifi: ensure wake-on-wlan restore only acts once
126 2c3a14fed platform/wifi: drop *_get_wowlan()
127 ---
128- clients/common/nm-meta-setting-desc.c | 14 ++++
129+ clients/common/nm-meta-setting-desc.c | 14 +++
130 clients/common/settings-docs.c | 1 +
131 clients/common/settings-docs.c.in | 1 +
132- libnm-core/nm-setting-wireless.c | 72 +++++++++++++++++
133- libnm-core/nm-setting-wireless.h | 46 +++++++++++
134+ libnm-core/nm-setting-wireless.c | 72 +++++++++++++
135+ libnm-core/nm-setting-wireless.h | 46 ++++++++
136 libnm/libnm.ver | 2 +
137- src/devices/wifi/nm-device-wifi.c | 102 +++++++++++++++++++++++-
138- src/nm-manager.c | 27 ++++---
139- src/platform/nm-linux-platform.c | 19 ++++-
140- src/platform/nm-platform.c | 20 +++++
141- src/platform/nm-platform.h | 5 ++
142- src/platform/wifi/wifi-utils-nl80211.c | 139 ++++++++++++++++++++++++---------
143+ src/devices/wifi/nm-device-wifi.c | 102 +++++++++++++++++-
144+ src/nm-manager.c | 27 +++--
145+ src/platform/nm-linux-platform.c | 19 +++-
146+ src/platform/nm-platform.c | 20 ++++
147+ src/platform/nm-platform.h | 5 +
148+ src/platform/wifi/wifi-utils-nl80211.c | 139 ++++++++++++++++++-------
149 src/platform/wifi/wifi-utils-private.h | 8 +-
150- src/platform/wifi/wifi-utils.c | 28 ++++---
151+ src/platform/wifi/wifi-utils.c | 28 +++--
152 src/platform/wifi/wifi-utils.h | 7 +-
153 15 files changed, 425 insertions(+), 66 deletions(-)
154
155 diff --git a/clients/common/nm-meta-setting-desc.c b/clients/common/nm-meta-setting-desc.c
156-index 94404e9..21763a8 100644
157+index addcdef71..eeca822c8 100644
158 --- a/clients/common/nm-meta-setting-desc.c
159 +++ b/clients/common/nm-meta-setting-desc.c
160-@@ -7271,6 +7271,20 @@ static const NMMetaPropertyInfo *const property_infos_WIRELESS[] = {
161+@@ -7279,6 +7279,20 @@ static const NMMetaPropertyInfo *const property_infos_WIRELESS[] = {
162 .typ_flags = NM_META_PROPERTY_TYP_FLAG_ENUM_GET_PARSABLE_TEXT,
163 ),
164 ),
165@@ -60,7 +61,7 @@ index 94404e9..21763a8 100644
166 };
167
168 diff --git a/clients/common/settings-docs.c b/clients/common/settings-docs.c
169-index bf5753c..911164a 100644
170+index bf5753c57..911164acc 100644
171 --- a/clients/common/settings-docs.c
172 +++ b/clients/common/settings-docs.c
173 @@ -21,6 +21,7 @@
174@@ -72,7 +73,7 @@ index bf5753c..911164a 100644
175 #define DESCRIBE_DOC_NM_SETTING_WIRELESS_SECURITY_GROUP N_("A list of group/broadcast encryption algorithms which prevents connections to Wi-Fi networks that do not utilize one of the algorithms in the list. For maximum compatibility leave this property empty. Each list element may be one of \"wep40\", \"wep104\", \"tkip\", or \"ccmp\".")
176 #define DESCRIBE_DOC_NM_SETTING_WIRELESS_SECURITY_KEY_MGMT N_("Key management used for the connection. One of \"none\" (WEP), \"ieee8021x\" (Dynamic WEP), \"wpa-none\" (Ad-Hoc WPA-PSK), \"wpa-psk\" (infrastructure WPA-PSK), or \"wpa-eap\" (WPA-Enterprise). This property must be set for any Wi-Fi connection that uses security.")
177 diff --git a/clients/common/settings-docs.c.in b/clients/common/settings-docs.c.in
178-index bf5753c..911164a 100644
179+index b022b2d9e..992d3fa41 100644
180 --- a/clients/common/settings-docs.c.in
181 +++ b/clients/common/settings-docs.c.in
182 @@ -21,6 +21,7 @@
183@@ -84,7 +85,7 @@ index bf5753c..911164a 100644
184 #define DESCRIBE_DOC_NM_SETTING_WIRELESS_SECURITY_GROUP N_("A list of group/broadcast encryption algorithms which prevents connections to Wi-Fi networks that do not utilize one of the algorithms in the list. For maximum compatibility leave this property empty. Each list element may be one of \"wep40\", \"wep104\", \"tkip\", or \"ccmp\".")
185 #define DESCRIBE_DOC_NM_SETTING_WIRELESS_SECURITY_KEY_MGMT N_("Key management used for the connection. One of \"none\" (WEP), \"ieee8021x\" (Dynamic WEP), \"wpa-none\" (Ad-Hoc WPA-PSK), \"wpa-psk\" (infrastructure WPA-PSK), or \"wpa-eap\" (WPA-Enterprise). This property must be set for any Wi-Fi connection that uses security.")
186 diff --git a/libnm-core/nm-setting-wireless.c b/libnm-core/nm-setting-wireless.c
187-index 0a3915b..7500c97 100644
188+index 0a3915bfc..7500c9740 100644
189 --- a/libnm-core/nm-setting-wireless.c
190 +++ b/libnm-core/nm-setting-wireless.c
191 @@ -63,6 +63,7 @@ typedef struct {
192@@ -207,7 +208,7 @@ index 0a3915b..7500c97 100644
193 + G_PARAM_STATIC_STRINGS));
194 }
195 diff --git a/libnm-core/nm-setting-wireless.h b/libnm-core/nm-setting-wireless.h
196-index b0ef475..4c1850f 100644
197+index b0ef47568..4c1850fbb 100644
198 --- a/libnm-core/nm-setting-wireless.h
199 +++ b/libnm-core/nm-setting-wireless.h
200 @@ -41,6 +41,48 @@ G_BEGIN_DECLS
201@@ -278,7 +279,7 @@ index b0ef475..4c1850f 100644
202
203 #endif /* __NM_SETTING_WIRELESS_H__ */
204 diff --git a/libnm/libnm.ver b/libnm/libnm.ver
205-index 7646a93..3376848 100644
206+index 6e0d9277d..e2d3755d9 100644
207 --- a/libnm/libnm.ver
208 +++ b/libnm/libnm.ver
209 @@ -1276,6 +1276,8 @@ global:
210@@ -291,7 +292,7 @@ index 7646a93..3376848 100644
211 nm_tc_action_equal;
212 nm_tc_action_get_attribute;
213 diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c
214-index bf02109..e06aa32 100644
215+index bf021095a..e06aa328a 100644
216 --- a/src/devices/wifi/nm-device-wifi.c
217 +++ b/src/devices/wifi/nm-device-wifi.c
218 @@ -119,6 +119,8 @@ typedef struct {
219@@ -468,10 +469,10 @@ index bf02109..e06aa32 100644
220 parent_class->state_changed = device_state_changed;
221
222 diff --git a/src/nm-manager.c b/src/nm-manager.c
223-index e60b6c6..fc8a97e 100644
224+index 09dc8fa6c..c34401ec1 100644
225 --- a/src/nm-manager.c
226 +++ b/src/nm-manager.c
227-@@ -1315,6 +1315,12 @@ _parent_notify_changed (NMManager *self,
228+@@ -1319,6 +1319,12 @@ _parent_notify_changed (NMManager *self,
229 }
230 }
231
232@@ -484,7 +485,7 @@ index e60b6c6..fc8a97e 100644
233 static void
234 remove_device (NMManager *self,
235 NMDevice *device,
236-@@ -1324,14 +1330,19 @@ remove_device (NMManager *self,
237+@@ -1328,14 +1334,19 @@ remove_device (NMManager *self,
238 NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
239 gboolean unmanage = FALSE;
240
241@@ -509,7 +510,7 @@ index e60b6c6..fc8a97e 100644
242 /* the device is already gone. Unmanage it. */
243 unmanage = TRUE;
244 }
245-@@ -4763,12 +4774,6 @@ done:
246+@@ -4767,12 +4778,6 @@ done:
247 g_clear_object (&subject);
248 }
249
250@@ -523,7 +524,7 @@ index e60b6c6..fc8a97e 100644
251 sleep_devices_add (NMManager *self, NMDevice *device, gboolean suspending)
252 {
253 diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
254-index e5961c7..a061fc3 100644
255+index e5961c7ec..a061fc396 100644
256 --- a/src/platform/nm-linux-platform.c
257 +++ b/src/platform/nm-linux-platform.c
258 @@ -6119,6 +6119,21 @@ wifi_indicate_addressing_running (NMPlatform *platform, int ifindex, gboolean ru
259@@ -567,7 +568,7 @@ index e5961c7..a061fc3 100644
260 platform_class->mesh_get_channel = mesh_get_channel;
261 platform_class->mesh_set_channel = mesh_set_channel;
262 diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c
263-index c7ed90e..7387a1d 100644
264+index c7ed90e3f..7387a1dad 100644
265 --- a/src/platform/nm-platform.c
266 +++ b/src/platform/nm-platform.c
267 @@ -2767,6 +2767,26 @@ nm_platform_wifi_indicate_addressing_running (NMPlatform *self, int ifindex, gbo
268@@ -598,7 +599,7 @@ index c7ed90e..7387a1d 100644
269 nm_platform_mesh_get_channel (NMPlatform *self, int ifindex)
270 {
271 diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h
272-index f6bf02b..0c167ee 100644
273+index f6bf02bf5..0c167ee57 100644
274 --- a/src/platform/nm-platform.h
275 +++ b/src/platform/nm-platform.h
276 @@ -32,6 +32,7 @@
277@@ -628,7 +629,7 @@ index f6bf02b..0c167ee 100644
278 guint32 nm_platform_mesh_get_channel (NMPlatform *self, int ifindex);
279 gboolean nm_platform_mesh_set_channel (NMPlatform *self, int ifindex, guint32 channel);
280 diff --git a/src/platform/wifi/wifi-utils-nl80211.c b/src/platform/wifi/wifi-utils-nl80211.c
281-index a5f25b0..3a09244 100644
282+index a5f25b026..3a092440e 100644
283 --- a/src/platform/wifi/wifi-utils-nl80211.c
284 +++ b/src/platform/wifi/wifi-utils-nl80211.c
285 @@ -495,6 +495,103 @@ nla_put_failure:
286@@ -792,7 +793,7 @@ index a5f25b0..3a09244 100644
287 _LOGI (LOGD_PLATFORM | LOGD_WIFI,
288 "(%s): using nl80211 for WiFi device control",
289 diff --git a/src/platform/wifi/wifi-utils-private.h b/src/platform/wifi/wifi-utils-private.h
290-index 11a0f06..18f6131 100644
291+index 11a0f060d..18f613198 100644
292 --- a/src/platform/wifi/wifi-utils-private.h
293 +++ b/src/platform/wifi/wifi-utils-private.h
294 @@ -35,6 +35,12 @@ struct WifiData {
295@@ -818,7 +819,7 @@ index 11a0f06..18f6131 100644
296
297 guint32 (*get_mesh_channel) (WifiData *data);
298 diff --git a/src/platform/wifi/wifi-utils.c b/src/platform/wifi/wifi-utils.c
299-index d005212..f76bf95 100644
300+index d00521212..f76bf9578 100644
301 --- a/src/platform/wifi/wifi-utils.c
302 +++ b/src/platform/wifi/wifi-utils.c
303 @@ -115,6 +115,25 @@ wifi_utils_set_powersave (WifiData *data, guint32 powersave)
304@@ -864,7 +865,7 @@ index d005212..f76bf95 100644
305 wifi_utils_deinit (WifiData *data)
306 {
307 diff --git a/src/platform/wifi/wifi-utils.h b/src/platform/wifi/wifi-utils.h
308-index 705717b..776b3c9 100644
309+index 705717b07..776b3c90b 100644
310 --- a/src/platform/wifi/wifi-utils.h
311 +++ b/src/platform/wifi/wifi-utils.h
312 @@ -25,6 +25,7 @@
313@@ -890,3 +891,6 @@ index 705717b..776b3c9 100644
314
315 /* OLPC Mesh-only functions */
316 guint32 wifi_utils_get_mesh_channel (WifiData *data);
317+--
318+2.17.1
319+
320diff --git a/debian/patches/disable-libnm-glib-wifi-ap-test.patch b/snap-patch/networkmanager/0002-Disable-non-working-test-on-Jenkins-instance.patch
321similarity index 55%
322rename from debian/patches/disable-libnm-glib-wifi-ap-test.patch
323rename to snap-patch/networkmanager/0002-Disable-non-working-test-on-Jenkins-instance.patch
324index 171b6f1..45d5344 100644
325--- a/debian/patches/disable-libnm-glib-wifi-ap-test.patch
326+++ b/snap-patch/networkmanager/0002-Disable-non-working-test-on-Jenkins-instance.patch
327@@ -1,7 +1,17 @@
328-Index: build/libnm-glib/tests/test-nm-client.c
329-===================================================================
330---- build.orig/libnm-glib/tests/test-nm-client.c
331-+++ build/libnm-glib/tests/test-nm-client.c
332+From 64092ca8d88385e953229f4640de8c159a1f24da Mon Sep 17 00:00:00 2001
333+From: =?UTF-8?q?Alfonso=20S=C3=A1nchez-Beato?=
334+ <alfonso.sanchez-beato@canonical.com>
335+Date: Thu, 30 Jan 2020 13:25:51 +0100
336+Subject: [PATCH 2/6] Disable non-working test on Jenkins instance
337+
338+---
339+ libnm-glib/tests/test-nm-client.c | 2 +-
340+ 1 file changed, 1 insertion(+), 1 deletion(-)
341+
342+diff --git a/libnm-glib/tests/test-nm-client.c b/libnm-glib/tests/test-nm-client.c
343+index b6b5968b3..1fc235b56 100644
344+--- a/libnm-glib/tests/test-nm-client.c
345++++ b/libnm-glib/tests/test-nm-client.c
346 @@ -1133,7 +1133,7 @@ main (int argc, char **argv)
347 loop = g_main_loop_new (NULL, FALSE);
348
349@@ -11,3 +21,6 @@ Index: build/libnm-glib/tests/test-nm-client.c
350 g_test_add_func ("/libnm-glib/wimax-nsp-added-removed", test_wimax_nsp_added_removed);
351 g_test_add_func ("/libnm-glib/devices-array", test_devices_array);
352 g_test_add_func ("/libnm-glib/client-manager-running", test_client_manager_running);
353+--
354+2.17.1
355+
356diff --git a/snap-patch/networkmanager/0003-Disable-non-working-test-on-Jenkins-instance.patch b/snap-patch/networkmanager/0003-Disable-non-working-test-on-Jenkins-instance.patch
357new file mode 100644
358index 0000000..cef27b8
359--- /dev/null
360+++ b/snap-patch/networkmanager/0003-Disable-non-working-test-on-Jenkins-instance.patch
361@@ -0,0 +1,26 @@
362+From 0ebaebbbeeabc45815b2ce65f408a5e6dc07af8c Mon Sep 17 00:00:00 2001
363+From: =?UTF-8?q?Alfonso=20S=C3=A1nchez-Beato?=
364+ <alfonso.sanchez-beato@canonical.com>
365+Date: Thu, 30 Jan 2020 13:27:03 +0100
366+Subject: [PATCH 3/6] Disable non-working test on Jenkins instance
367+
368+---
369+ libnm-glib/tests/test-nm-client.c | 2 +-
370+ 1 file changed, 1 insertion(+), 1 deletion(-)
371+
372+diff --git a/libnm-glib/tests/test-nm-client.c b/libnm-glib/tests/test-nm-client.c
373+index 1fc235b56..36bd4085b 100644
374+--- a/libnm-glib/tests/test-nm-client.c
375++++ b/libnm-glib/tests/test-nm-client.c
376+@@ -1135,7 +1135,7 @@ main (int argc, char **argv)
377+ g_test_add_func ("/libnm-glib/device-added", test_device_added);
378+ /* g_test_add_func ("/libnm-glib/wifi-ap-added-removed", test_wifi_ap_added_removed); */
379+ g_test_add_func ("/libnm-glib/wimax-nsp-added-removed", test_wimax_nsp_added_removed);
380+- g_test_add_func ("/libnm-glib/devices-array", test_devices_array);
381++ /* g_test_add_func ("/libnm-glib/devices-array", test_devices_array); */
382+ g_test_add_func ("/libnm-glib/client-manager-running", test_client_manager_running);
383+ g_test_add_func ("/libnm/connection/invalid", test_connection_invalid);
384+
385+--
386+2.17.1
387+
388diff --git a/debian/patches/add-snap-support.patch b/snap-patch/networkmanager/0004-Add-snap-support.patch
389similarity index 60%
390rename from debian/patches/add-snap-support.patch
391rename to snap-patch/networkmanager/0004-Add-snap-support.patch
392index a661864..a330150 100644
393--- a/debian/patches/add-snap-support.patch
394+++ b/snap-patch/networkmanager/0004-Add-snap-support.patch
395@@ -1,150 +1,46 @@
396-Index: nm/src/nm-core-utils.c
397-===================================================================
398---- nm.orig/src/nm-core-utils.c
399-+++ nm/src/nm-core-utils.c
400-@@ -44,6 +44,7 @@
401- #include "nm-setting-ip6-config.h"
402- #include "nm-setting-wireless.h"
403- #include "nm-setting-wireless-security.h"
404-+#include "nm-core-utils.h"
405-
406- /*
407- * Some toolchains (E.G. uClibc 0.9.33 and earlier) don't export
408-@@ -2978,14 +2979,17 @@ guint8 *
409- nm_utils_secret_key_read (gsize *out_key_len, GError **error)
410- {
411- guint8 *secret_key = NULL;
412-+ char *secret_key_path = NULL;
413- gsize key_len;
414-
415- /* out_key_len is not optional, because without it you cannot safely
416- * access the returned memory. */
417- *out_key_len = 0;
418-
419-+ secret_key_path = g_strdup_printf("%s/secret_key", nm_utils_get_state_dir());
420-+
421- /* Let's try to load a saved secret key first. */
422-- if (g_file_get_contents (NMSTATEDIR "/secret_key", (char **) &secret_key, &key_len, NULL)) {
423-+ if (g_file_get_contents (secret_key_path, (char **) &secret_key, &key_len, NULL)) {
424- if (key_len < 16) {
425- g_set_error_literal (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN,
426- "Key is too short to be usable");
427-@@ -3007,14 +3011,16 @@ nm_utils_secret_key_read (gsize *out_key
428- }
429-
430- key_mask = umask (0077);
431-- if (!g_file_set_contents (NMSTATEDIR "/secret_key", (char *) secret_key, key_len, error)) {
432-- g_prefix_error (error, "Can't write " NMSTATEDIR "/secret_key: ");
433-+
434-+ if (!g_file_set_contents (secret_key_path, (char *) secret_key, key_len, error)) {
435-+ g_prefix_error (error, "Can't write %s/secret_key: ", secret_key_path);
436- key_len = 0;
437- }
438- umask (key_mask);
439- }
440-
441- out:
442-+ g_free (secret_key_path);
443- if (key_len) {
444- *out_key_len = key_len;
445- return secret_key;
446-@@ -3853,6 +3859,74 @@ nm_utils_ip4_address_is_link_local (in_a
447- }
448-
449- /*****************************************************************************/
450-+
451-+const char*
452-+nm_utils_get_state_dir(void)
453-+{
454-+ static const char *state_dir = NULL;
455-+
456-+ if (!state_dir)
457-+ state_dir = g_strdup_printf("%s/state", getenv("SNAP_DATA"));
458-+
459-+ return state_dir;
460-+}
461-+
462-+const char*
463-+nm_utils_get_run_dir(void)
464-+{
465-+ static const char *run_dir = NULL;
466-+
467-+ if (!run_dir)
468-+ run_dir = g_strdup_printf("%s/run", getenv("SNAP_DATA"));
469-+
470-+ return run_dir;
471-+}
472-+
473-+const char*
474-+nm_utils_get_plugin_dir(void)
475-+{
476-+ static const char *plugin_dir = NULL;
477-+
478-+ if (!plugin_dir)
479-+ plugin_dir = g_strdup_printf("%s/%s", getenv("SNAP"), NMPLUGINDIR);
480-+
481-+ return plugin_dir;
482-+}
483-+
484-+const char*
485-+nm_utils_get_conf_dir(void)
486-+{
487-+ static const char *conf_dir = NULL;
488-+
489-+ if (!conf_dir)
490-+ conf_dir = g_strdup_printf("%s/conf", getenv("SNAP_DATA"));
491-+
492-+ return conf_dir;
493-+}
494-+
495-+const char*
496-+nm_utils_get_pppd_plugin_dir (void)
497-+{
498-+ static const char *pppd_plugin_dir = NULL;
499-+
500-+ if (!pppd_plugin_dir)
501-+ pppd_plugin_dir = g_strdup_printf("%s%s", getenv("SNAP"), PPPD_PLUGIN_DIR);
502-+
503-+ return pppd_plugin_dir;
504-+}
505-+
506-+const char*
507-+nm_utils_get_conf_device_state_dir (void)
508-+{
509-+ static const char *conf_device_state_dir = NULL;
510-+
511-+ if (!conf_device_state_dir)
512-+ conf_device_state_dir = g_strdup_printf("%s/devices", nm_utils_get_run_dir());
513-+
514-+ return conf_device_state_dir;
515-+}
516-+
517-+/*****************************************************************************/
518-
519- /**
520- * Takes a pair @timestamp and @duration, and returns the remaining duration based
521-Index: nm/src/nm-core-utils.h
522-===================================================================
523---- nm.orig/src/nm-core-utils.h
524-+++ nm/src/nm-core-utils.h
525-@@ -419,6 +419,13 @@ gboolean nm_utils_lifetime_get (guint32
526-
527- gboolean nm_utils_ip4_address_is_link_local (in_addr_t addr);
528-
529-+const char* nm_utils_get_state_dir (void);
530-+const char* nm_utils_get_run_dir (void);
531-+const char* nm_utils_get_plugin_dir (void);
532-+const char* nm_utils_get_conf_dir (void);
533-+const char* nm_utils_get_pppd_plugin_dir (void);
534-+const char* nm_utils_get_conf_device_state_dir (void);
535-+
536- const char *nm_utils_dnsmasq_status_to_string (int status, char *dest, gsize size);
537-
538- void nm_utils_get_reverse_dns_domains_ip4 (guint32 ip, guint8 plen, GPtrArray *domains);
539-Index: nm/src/devices/nm-device-factory.c
540-===================================================================
541---- nm.orig/src/devices/nm-device-factory.c
542-+++ nm/src/devices/nm-device-factory.c
543+From 6e74f89b21cc736e64ef82d3676d7d5bd4562363 Mon Sep 17 00:00:00 2001
544+From: =?UTF-8?q?Alfonso=20S=C3=A1nchez-Beato?=
545+ <alfonso.sanchez-beato@canonical.com>
546+Date: Thu, 30 Jan 2020 13:28:11 +0100
547+Subject: [PATCH 4/6] Add snap support
548+
549+---
550+ Makefile.am | 1 +
551+ src/devices/nm-device-factory.c | 3 +-
552+ src/dhcp/nm-dhcp-dhclient.c | 7 +-
553+ src/dhcp/nm-dhcp-systemd.c | 3 +-
554+ src/dns/nm-dns-dnsmasq.c | 27 +++++--
555+ src/dns/nm-dns-manager.c | 51 ++++++------
556+ src/dnsmasq/nm-dnsmasq-manager.c | 16 ++--
557+ src/main-utils.c | 18 ++---
558+ src/main.c | 7 +-
559+ src/nm-config.c | 33 +++++---
560+ src/nm-config.h | 2 -
561+ src/nm-core-utils.c | 80 ++++++++++++++++++-
562+ src/nm-core-utils.h | 7 ++
563+ src/nm-iface-helper.c | 4 +-
564+ src/ppp/nm-ppp-manager.c | 9 ++-
565+ src/settings/nm-settings-connection.c | 48 +++++++----
566+ src/settings/nm-settings.c | 3 +-
567+ .../plugins/keyfile/nms-keyfile-utils.c | 5 +-
568+ 18 files changed, 236 insertions(+), 88 deletions(-)
569+
570+diff --git a/Makefile.am b/Makefile.am
571+index 18bc1d1e8..3c54ed560 100644
572+--- a/Makefile.am
573++++ b/Makefile.am
574+@@ -1135,6 +1135,7 @@ src_cppflags = \
575+ -DNMRUNDIR=\"$(nmrundir)\" \
576+ -DNMSTATEDIR=\"$(nmstatedir)\" \
577+ -DNMLIBDIR=\"$(nmlibdir)\" \
578++ -DPPPD_PLUGIN_DIR=\"$(PPPD_PLUGIN_DIR)\" \
579+ \
580+ -DDHCPCANON_PATH=\"$(DHCPCANON_PATH)\" \
581+ -DDHCLIENT_PATH=\"$(DHCLIENT_PATH)\" \
582+diff --git a/src/devices/nm-device-factory.c b/src/devices/nm-device-factory.c
583+index 97f011c5e..94e53ad7d 100644
584+--- a/src/devices/nm-device-factory.c
585++++ b/src/devices/nm-device-factory.c
586 @@ -32,6 +32,7 @@
587 #include "nm-utils.h"
588 #include "nm-core-internal.h"
589@@ -153,7 +49,7 @@ Index: nm/src/devices/nm-device-factory.c
590
591 #define PLUGIN_PREFIX "libnm-device-plugin-"
592
593-@@ -375,7 +376,7 @@ nm_device_factory_manager_load_factories
594+@@ -375,7 +376,7 @@ nm_device_factory_manager_load_factories (NMDeviceFactoryManagerFactoryFunc call
595 _ADD_INTERNAL (nm_vlan_device_factory_get_type);
596 _ADD_INTERNAL (nm_vxlan_device_factory_get_type);
597
598@@ -162,10 +58,10 @@ Index: nm/src/devices/nm-device-factory.c
599 if (!paths)
600 return;
601
602-Index: nm/src/dhcp/nm-dhcp-dhclient.c
603-===================================================================
604---- nm.orig/src/dhcp/nm-dhcp-dhclient.c
605-+++ nm/src/dhcp/nm-dhcp-dhclient.c
606+diff --git a/src/dhcp/nm-dhcp-dhclient.c b/src/dhcp/nm-dhcp-dhclient.c
607+index 74d920a8d..ff3d0ed38 100644
608+--- a/src/dhcp/nm-dhcp-dhclient.c
609++++ b/src/dhcp/nm-dhcp-dhclient.c
610 @@ -46,6 +46,7 @@
611 #include "NetworkManagerUtils.h"
612 #include "nm-dhcp-listener.h"
613@@ -184,7 +80,7 @@ Index: nm/src/dhcp/nm-dhcp-dhclient.c
614 _addr_family_to_path_part (addr_family),
615 uuid,
616 iface);
617-@@ -313,7 +315,8 @@ create_dhclient_config (NMDhcpDhclient *
618+@@ -313,7 +315,8 @@ create_dhclient_config (NMDhcpDhclient *self,
619
620 g_return_val_if_fail (iface != NULL, NULL);
621
622@@ -194,11 +90,11 @@ Index: nm/src/dhcp/nm-dhcp-dhclient.c
623 _LOGD ("creating composite dhclient config %s", new);
624
625 orig = find_existing_config (self, addr_family, iface, uuid);
626-Index: nm/src/dhcp/nm-dhcp-systemd.c
627-===================================================================
628---- nm.orig/src/dhcp/nm-dhcp-systemd.c
629-+++ nm/src/dhcp/nm-dhcp-systemd.c
630-@@ -445,7 +445,8 @@ lease_to_ip4_config (NMDedupMultiIndex *
631+diff --git a/src/dhcp/nm-dhcp-systemd.c b/src/dhcp/nm-dhcp-systemd.c
632+index f79b7cb1e..983c80915 100644
633+--- a/src/dhcp/nm-dhcp-systemd.c
634++++ b/src/dhcp/nm-dhcp-systemd.c
635+@@ -445,7 +445,8 @@ lease_to_ip4_config (NMDedupMultiIndex *multi_idx,
636 static char *
637 get_leasefile_path (int addr_family, const char *iface, const char *uuid)
638 {
639@@ -208,566 +104,492 @@ Index: nm/src/dhcp/nm-dhcp-systemd.c
640 addr_family == AF_INET6 ? "6" : "",
641 uuid,
642 iface);
643-Index: nm/src/main-utils.c
644-===================================================================
645---- nm.orig/src/main-utils.c
646-+++ nm/src/main-utils.c
647-@@ -34,6 +34,7 @@
648-
649- #include "main-utils.h"
650+diff --git a/src/dns/nm-dns-dnsmasq.c b/src/dns/nm-dns-dnsmasq.c
651+index 8c85cc235..360bacd8a 100644
652+--- a/src/dns/nm-dns-dnsmasq.c
653++++ b/src/dns/nm-dns-dnsmasq.c
654+@@ -38,9 +38,6 @@
655+ #include "nm-bus-manager.h"
656 #include "NetworkManagerUtils.h"
657-+#include "nm-core-utils.h"
658- #include "nm-config.h"
659
660- static gboolean
661-@@ -118,7 +119,7 @@ nm_main_utils_ensure_statedir ()
662- gs_free char *parent = NULL;
663- int errsv;
664+-#define PIDFILE NMRUNDIR "/dnsmasq.pid"
665+-#define CONFDIR NMCONFDIR "/dnsmasq.d"
666+-
667+ #define DNSMASQ_DBUS_SERVICE "org.freedesktop.NetworkManager.dnsmasq"
668+ #define DNSMASQ_DBUS_PATH "/uk/org/thekelleys/dnsmasq"
669
670-- parent = g_path_get_dirname (NMSTATEDIR);
671-+ parent = g_path_get_dirname (nm_utils_get_state_dir());
672+@@ -310,6 +307,10 @@ start_dnsmasq (NMDnsDnsmasq *self)
673+ guint idx = 0;
674+ NMBusManager *dbus_mgr;
675+ GDBusConnection *connection;
676++ char *pidfile = NULL;
677++ char *pidfile_arg = NULL;
678++ char *confdir = NULL;
679++ char *confdir_arg = NULL;
680
681- /* Ensure parent state directories exists */
682- if ( parent
683-@@ -126,13 +127,13 @@ nm_main_utils_ensure_statedir ()
684- && parent[1] != '\0'
685- && g_mkdir_with_parents (parent, 0755) != 0) {
686- errsv = errno;
687-- fprintf (stderr, "Cannot create parents for '%s': %s", NMSTATEDIR, g_strerror (errsv));
688-+ fprintf (stderr, "Cannot create parents for '%s': %s", nm_utils_get_state_dir(), g_strerror (errsv));
689- exit (1);
690- }
691- /* Ensure state directory exists */
692-- if (g_mkdir_with_parents (NMSTATEDIR, 0700) != 0) {
693-+ if (g_mkdir_with_parents (nm_utils_get_state_dir(), 0700) != 0) {
694- errsv = errno;
695-- fprintf (stderr, "Cannot create '%s': %s", NMSTATEDIR, g_strerror (errsv));
696-+ fprintf (stderr, "Cannot create '%s': %s", nm_utils_get_state_dir(), g_strerror (errsv));
697- exit (1);
698+ if (priv->running) {
699+ /* the dnsmasq process is running. Nothing to do. */
700+@@ -328,12 +329,15 @@ start_dnsmasq (NMDnsDnsmasq *self)
701+ return;
702 }
703- }
704-@@ -143,20 +144,19 @@ nm_main_utils_ensure_rundir ()
705- int errsv;
706
707- /* Setup runtime directory */
708-- if (g_mkdir_with_parents (NMRUNDIR, 0755) != 0) {
709-+ if (g_mkdir_with_parents (nm_utils_get_run_dir(), 0755) != 0) {
710- errsv = errno;
711-- fprintf (stderr, _("Cannot create '%s': %s"), NMRUNDIR, g_strerror (errsv));
712-+ fprintf (stderr, _("Cannot create '%s': %s"), nm_utils_get_run_dir(), g_strerror (errsv));
713- exit (1);
714- }
715++ pidfile = g_strdup_printf ("%s/dnsmasq.pid", nm_utils_get_run_dir ());
716++ pidfile_arg = g_strdup_printf ("--pid-file=%s", pidfile);
717++
718+ argv[idx++] = dm_binary;
719+ argv[idx++] = "--no-resolv"; /* Use only commandline */
720+ argv[idx++] = "--keep-in-foreground";
721+ argv[idx++] = "--no-hosts"; /* don't use /etc/hosts to resolve */
722+ argv[idx++] = "--bind-interfaces";
723+- argv[idx++] = "--pid-file=" PIDFILE;
724++ argv[idx++] = pidfile_arg;
725+ argv[idx++] = "--listen-address=127.0.1.1"; /* Should work for both 4 and 6 */
726+ argv[idx++] = "--cache-size=0";
727+ argv[idx++] = "--clear-on-reload"; /* clear cache when dns server changes */
728+@@ -341,15 +345,24 @@ start_dnsmasq (NMDnsDnsmasq *self)
729+ argv[idx++] = "--proxy-dnssec"; /* Allow DNSSEC to pass through */
730+ argv[idx++] = "--enable-dbus=" DNSMASQ_DBUS_SERVICE;
731
732- /* NM_CONFIG_DEVICE_STATE_DIR is used to determine whether NM is restarted or not.
733- * It is important to set NMConfigCmdLineOptions.first_start before creating
734- * the directory. */
735-- nm_assert (g_str_has_prefix (NM_CONFIG_DEVICE_STATE_DIR, NMRUNDIR"/"));
736-- if (g_mkdir (NM_CONFIG_DEVICE_STATE_DIR, 0755) != 0) {
737-+ if (g_mkdir (nm_utils_get_conf_device_state_dir(), 0755) != 0) {
738- errsv = errno;
739- if (errsv != EEXIST) {
740-- fprintf (stderr, _("Cannot create '%s': %s"), NM_CONFIG_DEVICE_STATE_DIR, g_strerror (errsv));
741-+ fprintf (stderr, _("Cannot create '%s': %s"), nm_utils_get_conf_device_state_dir(), g_strerror (errsv));
742- exit (1);
743- }
744- }
745-Index: nm/src/main.c
746-===================================================================
747---- nm.orig/src/main.c
748-+++ nm/src/main.c
749-@@ -53,12 +53,15 @@
750- #include "dns/nm-dns-manager.h"
751- #include "systemd/nm-sd.h"
752- #include "nm-netns.h"
753-+#include "nm-core-utils.h"
754++ confdir = g_strdup_printf ("%s/dnsmasq.d", nm_utils_get_conf_dir ());
755++ confdir_arg = g_strdup_printf ("--pid-file=%s", confdir);
756++
757+ /* dnsmasq exits if the conf dir is not present */
758+- if (g_file_test (CONFDIR, G_FILE_TEST_IS_DIR))
759+- argv[idx++] = "--conf-dir=" CONFDIR;
760++ if (g_file_test (confdir, G_FILE_TEST_IS_DIR))
761++ argv[idx++] = confdir_arg;
762
763- #if !defined(NM_DIST_VERSION)
764- # define NM_DIST_VERSION VERSION
765- #endif
766+ argv[idx++] = NULL;
767+ nm_assert (idx <= G_N_ELEMENTS (argv));
768
769- #define NM_DEFAULT_PID_FILE NMRUNDIR "/NetworkManager.pid"
770+ /* And finally spawn dnsmasq */
771+- pid = nm_dns_plugin_child_spawn (NM_DNS_PLUGIN (self), argv, PIDFILE, "bin/dnsmasq");
772++ pid = nm_dns_plugin_child_spawn (NM_DNS_PLUGIN (self), argv, pidfile, "bin/dnsmasq");
773 +
774-+/* TODO[snap]: this doesn't appear to be used anywhere else? */
775- #define NM_DEFAULT_SYSTEM_STATE_FILE NMSTATEDIR "/NetworkManager.state"
776++ g_free (pidfile);
777++ g_free (pidfile_arg);
778++ g_free (confdir);
779++ g_free (confdir_arg);
780++
781+ if (!pid)
782+ return;
783
784- #define CONFIG_ATOMIC_SECTION_PREFIXES ((char **) NULL)
785-@@ -212,7 +215,7 @@ do_early_setup (int *argc, char **argv[]
786- _("NetworkManager monitors all network connections and automatically\nchooses the best connection to use. It also allows the user to\nspecify wireless access points which wireless cards in the computer\nshould associate with.")))
787- exit (1);
788-
789-- global_opt.pidfile = global_opt.pidfile ? global_opt.pidfile : g_strdup (NM_DEFAULT_PID_FILE);
790-+ global_opt.pidfile = global_opt.pidfile ? global_opt.pidfile : g_strdup_printf ("%s/NetworkManager.pid", nm_utils_get_run_dir());
791+diff --git a/src/dns/nm-dns-manager.c b/src/dns/nm-dns-manager.c
792+index 6b397a050..180fa1a6f 100644
793+--- a/src/dns/nm-dns-manager.c
794++++ b/src/dns/nm-dns-manager.c
795+@@ -752,8 +752,6 @@ _read_link_cached (const char *path, gboolean *is_cached, char **cached)
796+ return (*cached = g_file_read_link (path, NULL));
797 }
798
799- /*
800-@@ -244,7 +247,7 @@ main (int argc, char *argv[])
801-
802- /* we determine a first-start (contrary to a restart during the same boot)
803- * based on the existence of NM_CONFIG_DEVICE_STATE_DIR directory. */
804-- config_cli = nm_config_cmd_line_options_new (!g_file_test (NM_CONFIG_DEVICE_STATE_DIR,
805-+ config_cli = nm_config_cmd_line_options_new (!g_file_test (nm_utils_get_conf_device_state_dir(),
806- G_FILE_TEST_IS_DIR));
807-
808- do_early_setup (&argc, &argv, config_cli);
809-Index: nm/src/nm-config.c
810-===================================================================
811---- nm.orig/src/nm-config.c
812-+++ nm/src/nm-config.c
813-@@ -167,6 +167,16 @@ static void _set_config_data (NMConfig *
814-
815- /*****************************************************************************/
816+-#define MY_RESOLV_CONF NMRUNDIR "/resolv.conf"
817+-#define MY_RESOLV_CONF_TMP MY_RESOLV_CONF ".tmp"
818+ #define RESOLV_CONF_TMP "/etc/.resolv.conf.NetworkManager"
819
820-+static const char *get_no_auto_default_file_path()
821-+{
822-+ const char *no_auto_default_file = NULL;
823-+
824-+ if (!no_auto_default_file)
825-+ no_auto_default_file = g_strdup_printf("%s/no-auto-default.state", nm_utils_get_state_dir());
826-+
827-+ return no_auto_default_file;
828-+}
829+ static SpawnResult
830+@@ -773,6 +771,11 @@ update_resolv_conf (NMDnsManager *self,
831+ nm_auto_free char *rc_path_real = NULL;
832+ gboolean resconf_link_cached = FALSE;
833+ gs_free char *resconf_link = NULL;
834++ gs_free char *my_resolv_conf = NULL;
835++ gs_free char *my_resolv_conf_tmp = NULL;
836 +
837- gint
838- nm_config_parse_boolean (const char *str,
839- gint default_value)
840-@@ -2052,13 +2062,14 @@ NMConfigDeviceStateData *
841- nm_config_device_state_load (int ifindex)
842- {
843- NMConfigDeviceStateData *device_state;
844-- char path[NM_STRLEN (NM_CONFIG_DEVICE_STATE_DIR) + 60];
845-+ gsize dev_state_dir_len = strlen (nm_utils_get_conf_device_state_dir ());
846-+ char path[dev_state_dir_len + 60];
847- gs_unref_keyfile GKeyFile *kf = NULL;
848- const char *nm_owned_str;
849++ my_resolv_conf = g_strdup_printf ("%s/resolv.conf", nm_utils_get_run_dir ());
850++ my_resolv_conf_tmp = g_strdup_printf ("%s.tmp", my_resolv_conf);
851
852- g_return_val_if_fail (ifindex > 0, NULL);
853+ /* If we are not managing /etc/resolv.conf and it points to
854+ * MY_RESOLV_CONF, don't write the private DNS configuration to
855+@@ -783,9 +786,9 @@ update_resolv_conf (NMDnsManager *self,
856+ * internal resolv.conf file. */
857+ if (rc_manager == NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED) {
858+ if (nm_streq0 (_read_link_cached (_PATH_RESCONF, &resconf_link_cached, &resconf_link),
859+- MY_RESOLV_CONF)) {
860+- _LOGD ("update-resolv-conf: not updating " _PATH_RESCONF
861+- " since it points to " MY_RESOLV_CONF);
862++ my_resolv_conf)) {
863++ _LOGD ("update-resolv-conf: not updating %s since it points to %s",
864++ _PATH_RESCONF, my_resolv_conf);
865+ return SR_SUCCESS;
866+ }
867+ }
868+@@ -818,16 +821,16 @@ update_resolv_conf (NMDnsManager *self,
869+ }
870+ }
871
872-- nm_sprintf_buf (path, "%s/%d", NM_CONFIG_DEVICE_STATE_DIR, ifindex);
873-+ nm_sprintf_buf (path, "%s/%d", nm_utils_get_conf_device_state_dir(), ifindex);
874+- if ((f = fopen (MY_RESOLV_CONF_TMP, "we")) == NULL) {
875++ if ((f = fopen (my_resolv_conf_tmp, "we")) == NULL) {
876+ errsv = errno;
877+ g_set_error (error,
878+ NM_MANAGER_ERROR,
879+ NM_MANAGER_ERROR_FAILED,
880+ "Could not open %s: %s",
881+- MY_RESOLV_CONF_TMP,
882++ my_resolv_conf_tmp,
883+ g_strerror (errsv));
884+ _LOGT ("update-resolv-conf: open temporary file %s failed (%s)",
885+- MY_RESOLV_CONF_TMP, g_strerror (errsv));
886++ my_resolv_conf_tmp, g_strerror (errsv));
887+ return SR_ERROR;
888+ }
889
890- kf = nm_config_create_keyfile ();
891- if (!g_key_file_load_from_file (kf, path, G_KEY_FILE_NONE, NULL))
892-@@ -2102,7 +2113,7 @@ nm_config_device_state_load_all (void)
893+@@ -835,7 +838,7 @@ update_resolv_conf (NMDnsManager *self,
894+ if (!success) {
895+ errsv = errno;
896+ _LOGT ("update-resolv-conf: write temporary file %s failed (%s)",
897+- MY_RESOLV_CONF_TMP, g_strerror (errsv));
898++ my_resolv_conf_tmp, g_strerror (errsv));
899+ }
900
901- states = g_hash_table_new_full (nm_direct_hash, NULL, NULL, g_free);
902+ if (fclose (f) < 0) {
903+@@ -848,25 +851,25 @@ update_resolv_conf (NMDnsManager *self,
904+ NM_MANAGER_ERROR,
905+ NM_MANAGER_ERROR_FAILED,
906+ "Could not close %s: %s",
907+- MY_RESOLV_CONF_TMP,
908++ my_resolv_conf_tmp,
909+ g_strerror (errsv));
910+ _LOGT ("update-resolv-conf: close temporary file %s failed (%s)",
911+- MY_RESOLV_CONF_TMP, g_strerror (errsv));
912++ my_resolv_conf_tmp, g_strerror (errsv));
913+ }
914+ return SR_ERROR;
915+ } else if (!success)
916+ return SR_ERROR;
917
918-- dir = g_dir_open (NM_CONFIG_DEVICE_STATE_DIR, 0, NULL);
919-+ dir = g_dir_open (nm_utils_get_conf_device_state_dir(), 0, NULL);
920- if (!dir)
921- return states;
922+- if (rename (MY_RESOLV_CONF_TMP, MY_RESOLV_CONF) < 0) {
923++ if (rename (my_resolv_conf_tmp, my_resolv_conf) < 0) {
924+ errsv = errno;
925+ g_set_error (error,
926+ NM_MANAGER_ERROR,
927+ NM_MANAGER_ERROR_FAILED,
928+ "Could not replace %s: %s",
929+- MY_RESOLV_CONF,
930++ my_resolv_conf,
931+ g_strerror (errno));
932+ _LOGT ("update-resolv-conf: failed to rename temporary file %s to %s (%s)",
933+- MY_RESOLV_CONF_TMP, MY_RESOLV_CONF, g_strerror (errsv));
934++ my_resolv_conf_tmp, my_resolv_conf, g_strerror (errsv));
935+ return SR_ERROR;
936+ }
937
938-@@ -2134,7 +2145,8 @@ nm_config_device_state_write (int ifinde
939- guint32 route_metric_default_aspired,
940- guint32 route_metric_default_effective)
941- {
942-- char path[NM_STRLEN (NM_CONFIG_DEVICE_STATE_DIR) + 60];
943-+ gsize dev_state_dir_len = strlen (nm_utils_get_conf_device_state_dir ());
944-+ char path[dev_state_dir_len + 60];
945- GError *local = NULL;
946- gs_unref_keyfile GKeyFile *kf = NULL;
947+@@ -878,14 +881,14 @@ update_resolv_conf (NMDnsManager *self,
948
949-@@ -2144,7 +2156,7 @@ nm_config_device_state_write (int ifinde
950+ if ( rc_manager != NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK
951+ || !_read_link_cached (_PATH_RESCONF, &resconf_link_cached, &resconf_link)) {
952+- _LOGT ("update-resolv-conf: write internal file %s succeeded", MY_RESOLV_CONF);
953++ _LOGT ("update-resolv-conf: write internal file %s succeeded", my_resolv_conf);
954+ return SR_SUCCESS;
955+ }
956
957- nm_assert (!perm_hw_addr_fake || nm_utils_hwaddr_valid (perm_hw_addr_fake, -1));
958+ if (!nm_streq0 (_read_link_cached (_PATH_RESCONF, &resconf_link_cached, &resconf_link),
959+- MY_RESOLV_CONF)) {
960++ my_resolv_conf)) {
961+ _LOGT ("update-resolv-conf: write internal file %s succeeded (don't touch symlink %s linking to %s)",
962+- MY_RESOLV_CONF, _PATH_RESCONF,
963++ my_resolv_conf, _PATH_RESCONF,
964+ _read_link_cached (_PATH_RESCONF, &resconf_link_cached, &resconf_link));
965+ return SR_SUCCESS;
966+ }
967+@@ -904,22 +907,22 @@ update_resolv_conf (NMDnsManager *self,
968+ g_strerror (errsv));
969+ _LOGT ("update-resolv-conf: write internal file %s succeeded "
970+ "but canot delete temporary file %s: %s",
971+- MY_RESOLV_CONF, RESOLV_CONF_TMP, g_strerror (errsv));
972++ my_resolv_conf, RESOLV_CONF_TMP, g_strerror (errsv));
973+ return SR_ERROR;
974+ }
975
976-- nm_sprintf_buf (path, "%s/%d", NM_CONFIG_DEVICE_STATE_DIR, ifindex);
977-+ nm_sprintf_buf (path, "%s/%d", nm_utils_get_conf_device_state_dir(), ifindex);
978+- if (symlink (MY_RESOLV_CONF, RESOLV_CONF_TMP) == -1) {
979++ if (symlink (my_resolv_conf, RESOLV_CONF_TMP) == -1) {
980+ errsv = errno;
981+ g_set_error (error,
982+ NM_MANAGER_ERROR,
983+ NM_MANAGER_ERROR_FAILED,
984+ "Could not create symlink %s pointing to %s: %s",
985+ RESOLV_CONF_TMP,
986+- MY_RESOLV_CONF,
987++ my_resolv_conf,
988+ g_strerror (errsv));
989+ _LOGT ("update-resolv-conf: write internal file %s succeeded "
990+ "but failed to symlink %s: %s",
991+- MY_RESOLV_CONF, RESOLV_CONF_TMP, g_strerror (errsv));
992++ my_resolv_conf, RESOLV_CONF_TMP, g_strerror (errsv));
993+ return SR_ERROR;
994+ }
995
996- kf = nm_config_create_keyfile ();
997- if (NM_IN_SET (managed,
998-@@ -2209,12 +2221,15 @@ nm_config_device_state_prune_unseen (GHa
999- const char *fn;
1000- int ifindex;
1001- gsize fn_len;
1002-- char buf[NM_STRLEN (NM_CONFIG_DEVICE_STATE_DIR"/") + 30 + 3] = NM_CONFIG_DEVICE_STATE_DIR"/";
1003-- char *buf_p = &buf[NM_STRLEN (NM_CONFIG_DEVICE_STATE_DIR"/")];
1004-+ gsize dev_state_dir_len = strlen (nm_utils_get_conf_device_state_dir ()) + 1;
1005-+ char buf[dev_state_dir_len + 30 + 3];
1006-+ char *buf_p = &buf[dev_state_dir_len];
1007-+
1008-+ g_snprintf(buf, dev_state_dir_len, "%s/", nm_utils_get_conf_device_state_dir ());
1009+@@ -934,12 +937,12 @@ update_resolv_conf (NMDnsManager *self,
1010+ g_strerror (errsv));
1011+ _LOGT ("update-resolv-conf: write internal file %s succeeded "
1012+ "but failed to rename temporary symlink %s to %s: %s",
1013+- MY_RESOLV_CONF, RESOLV_CONF_TMP, _PATH_RESCONF, g_strerror (errsv));
1014++ my_resolv_conf, RESOLV_CONF_TMP, _PATH_RESCONF, g_strerror (errsv));
1015+ return SR_ERROR;
1016+ }
1017
1018- g_return_if_fail (seen_ifindexes);
1019+ _LOGT ("update-resolv-conf: write internal file %s succeeded and update symlink %s",
1020+- MY_RESOLV_CONF, _PATH_RESCONF);
1021++ my_resolv_conf, _PATH_RESCONF);
1022+ return SR_SUCCESS;
1023+ }
1024
1025-- dir = g_dir_open (NM_CONFIG_DEVICE_STATE_DIR, 0, NULL);
1026-+ dir = g_dir_open (nm_utils_get_conf_device_state_dir (), 0, NULL);
1027- if (!dir)
1028- return;
1029+@@ -1963,6 +1966,8 @@ again:
1030+ _clear_plugin (self);
1031+ priv->plugin = nm_dns_systemd_resolved_new ();
1032+ plugin_changed = TRUE;
1033++
1034++ _LOGI ("init: plugin_changed: systemd-resolvd");
1035+ }
1036+ mode = "systemd-resolved";
1037+ } else if (nm_streq0 (mode, "dnsmasq")) {
1038+diff --git a/src/dnsmasq/nm-dnsmasq-manager.c b/src/dnsmasq/nm-dnsmasq-manager.c
1039+index 323ef7819..3225314b3 100644
1040+--- a/src/dnsmasq/nm-dnsmasq-manager.c
1041++++ b/src/dnsmasq/nm-dnsmasq-manager.c
1042+@@ -35,8 +35,6 @@
1043+ #include "NetworkManagerUtils.h"
1044+ #include "nm-core-internal.h"
1045
1046-@@ -2525,7 +2540,7 @@ init_sync (GInitable *initable, GCancell
1047- if (priv->cli.no_auto_default_file)
1048- priv->no_auto_default_file = g_strdup (priv->cli.no_auto_default_file);
1049- else
1050-- priv->no_auto_default_file = g_strdup (DEFAULT_NO_AUTO_DEFAULT_FILE);
1051-+ priv->no_auto_default_file = g_strdup (get_no_auto_default_file_path());
1052+-#define CONFDIR NMCONFDIR "/dnsmasq-shared.d"
1053+-
1054+ /*****************************************************************************/
1055
1056- priv->monitor_connection_files = nm_config_keyfile_get_boolean (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "monitor-connection-files", FALSE);
1057+ enum {
1058+@@ -161,6 +159,8 @@ create_dm_cmd_line (const char *iface,
1059+ const char *dm_binary;
1060+ const NMPlatformIP4Address *listen_address;
1061+ guint i, n;
1062++ char *confdir = NULL;
1063++ char *confdir_arg = NULL;
1064
1065-Index: nm/src/ppp/nm-ppp-manager.c
1066-===================================================================
1067---- nm.orig/src/ppp/nm-ppp-manager.c
1068-+++ nm/src/ppp/nm-ppp-manager.c
1069-@@ -57,7 +57,7 @@
1070+ listen_address = nm_ip4_config_get_first_address (ip4_config);
1071+ g_return_val_if_fail (listen_address, NULL);
1072+@@ -254,10 +254,16 @@ create_dm_cmd_line (const char *iface,
1073+ nm_cmd_line_add_string (cmd, s->str);
1074+ g_string_truncate (s, 0);
1075
1076- #include "introspection/org.freedesktop.NetworkManager.PPP.h"
1077++ confdir = g_strdup_printf("%s/dnsmasq-shared.d", nm_utils_get_conf_dir());
1078++
1079+ /* dnsmasq exits if the conf dir is not present */
1080+- if (g_file_test (CONFDIR, G_FILE_TEST_IS_DIR))
1081+- nm_cmd_line_add_string (cmd, "--conf-dir=" CONFDIR);
1082++ if (g_file_test (confdir, G_FILE_TEST_IS_DIR)) {
1083++ confdir_arg = g_strdup_printf("--conf-dir=%s", confdir);
1084++ nm_cmd_line_add_string (cmd, confdir_arg);
1085++ }
1086
1087--#define NM_PPPD_PLUGIN PPPD_PLUGIN_DIR "/nm-pppd-plugin.so"
1088-+#define NM_PPPD_PLUGIN "nm-pppd-plugin.so"
1089++ g_free (confdir);
1090++ g_free (confdir_arg);
1091+ return cmd;
1092+ }
1093
1094- static NM_CACHED_QUARK_FCN ("ppp-manager-secret-tries", ppp_manager_secret_tries_quark)
1095+@@ -381,7 +387,7 @@ nm_dnsmasq_manager_new (const char *iface)
1096
1097-@@ -739,6 +739,7 @@ create_pppd_cmd_line (NMPPPManager *self
1098- const char *pppd_binary = NULL;
1099- NMCmdLine *cmd;
1100- gboolean ppp_debug;
1101-+ char *pppd_plugin_dir;
1102- static int unit;
1103+ priv = NM_DNSMASQ_MANAGER_GET_PRIVATE (manager);
1104+ priv->iface = g_strdup (iface);
1105+- priv->pidfile = g_strdup_printf (RUNSTATEDIR "/nm-dnsmasq-%s.pid", iface);
1106++ priv->pidfile = g_strdup_printf ("%s/nm-dnsmasq-%s.pid", nm_utils_get_run_dir(), iface);
1107
1108- g_return_val_if_fail (setting != NULL, NULL);
1109-@@ -901,8 +902,12 @@ create_pppd_cmd_line (NMPPPManager *self
1110- nm_cmd_line_add_string (cmd, "ipparam");
1111- nm_cmd_line_add_string (cmd, nm_exported_object_get_path (NM_EXPORTED_OBJECT (self)));
1112+ return manager;
1113+ }
1114+diff --git a/src/main-utils.c b/src/main-utils.c
1115+index 0f7905360..93329eef1 100644
1116+--- a/src/main-utils.c
1117++++ b/src/main-utils.c
1118+@@ -34,6 +34,7 @@
1119
1120-+ pppd_plugin_dir = g_strdup_printf ("%s/%s", nm_utils_get_pppd_plugin_dir (), NM_PPPD_PLUGIN);
1121-+
1122- nm_cmd_line_add_string (cmd, "plugin");
1123-- nm_cmd_line_add_string (cmd, NM_PPPD_PLUGIN);
1124-+ nm_cmd_line_add_string (cmd, pppd_plugin_dir);
1125-+
1126-+ g_free (pppd_plugin_dir);
1127+ #include "main-utils.h"
1128+ #include "NetworkManagerUtils.h"
1129++#include "nm-core-utils.h"
1130+ #include "nm-config.h"
1131
1132- if (pppoe && nm_setting_pppoe_get_parent (pppoe)) {
1133- /* The PPP interface is going to be renamed, so pass a
1134-Index: nm/src/nm-iface-helper.c
1135-===================================================================
1136---- nm.orig/src/nm-iface-helper.c
1137-+++ nm/src/nm-iface-helper.c
1138-@@ -48,8 +48,6 @@
1139+ static gboolean
1140+@@ -118,7 +119,7 @@ nm_main_utils_ensure_statedir ()
1141+ gs_free char *parent = NULL;
1142+ int errsv;
1143+
1144+- parent = g_path_get_dirname (NMSTATEDIR);
1145++ parent = g_path_get_dirname (nm_utils_get_state_dir());
1146+
1147+ /* Ensure parent state directories exists */
1148+ if ( parent
1149+@@ -126,13 +127,13 @@ nm_main_utils_ensure_statedir ()
1150+ && parent[1] != '\0'
1151+ && g_mkdir_with_parents (parent, 0755) != 0) {
1152+ errsv = errno;
1153+- fprintf (stderr, "Cannot create parents for '%s': %s", NMSTATEDIR, g_strerror (errsv));
1154++ fprintf (stderr, "Cannot create parents for '%s': %s", nm_utils_get_state_dir(), g_strerror (errsv));
1155+ exit (1);
1156+ }
1157+ /* Ensure state directory exists */
1158+- if (g_mkdir_with_parents (NMSTATEDIR, 0700) != 0) {
1159++ if (g_mkdir_with_parents (nm_utils_get_state_dir(), 0700) != 0) {
1160+ errsv = errno;
1161+- fprintf (stderr, "Cannot create '%s': %s", NMSTATEDIR, g_strerror (errsv));
1162++ fprintf (stderr, "Cannot create '%s': %s", nm_utils_get_state_dir(), g_strerror (errsv));
1163+ exit (1);
1164+ }
1165+ }
1166+@@ -143,20 +144,19 @@ nm_main_utils_ensure_rundir ()
1167+ int errsv;
1168+
1169+ /* Setup runtime directory */
1170+- if (g_mkdir_with_parents (NMRUNDIR, 0755) != 0) {
1171++ if (g_mkdir_with_parents (nm_utils_get_run_dir(), 0755) != 0) {
1172+ errsv = errno;
1173+- fprintf (stderr, _("Cannot create '%s': %s"), NMRUNDIR, g_strerror (errsv));
1174++ fprintf (stderr, _("Cannot create '%s': %s"), nm_utils_get_run_dir(), g_strerror (errsv));
1175+ exit (1);
1176+ }
1177+
1178+ /* NM_CONFIG_DEVICE_STATE_DIR is used to determine whether NM is restarted or not.
1179+ * It is important to set NMConfigCmdLineOptions.first_start before creating
1180+ * the directory. */
1181+- nm_assert (g_str_has_prefix (NM_CONFIG_DEVICE_STATE_DIR, NMRUNDIR"/"));
1182+- if (g_mkdir (NM_CONFIG_DEVICE_STATE_DIR, 0755) != 0) {
1183++ if (g_mkdir (nm_utils_get_conf_device_state_dir(), 0755) != 0) {
1184+ errsv = errno;
1185+ if (errsv != EEXIST) {
1186+- fprintf (stderr, _("Cannot create '%s': %s"), NM_CONFIG_DEVICE_STATE_DIR, g_strerror (errsv));
1187++ fprintf (stderr, _("Cannot create '%s': %s"), nm_utils_get_conf_device_state_dir(), g_strerror (errsv));
1188+ exit (1);
1189+ }
1190+ }
1191+diff --git a/src/main.c b/src/main.c
1192+index d59da0522..33e1708b4 100644
1193+--- a/src/main.c
1194++++ b/src/main.c
1195+@@ -53,12 +53,15 @@
1196+ #include "dns/nm-dns-manager.h"
1197+ #include "systemd/nm-sd.h"
1198+ #include "nm-netns.h"
1199++#include "nm-core-utils.h"
1200+
1201+ #if !defined(NM_DIST_VERSION)
1202 # define NM_DIST_VERSION VERSION
1203 #endif
1204
1205--#define NMIH_PID_FILE_FMT NMRUNDIR "/nm-iface-helper-%d.pid"
1206--
1207- /*****************************************************************************/
1208+ #define NM_DEFAULT_PID_FILE NMRUNDIR "/NetworkManager.pid"
1209++
1210++/* TODO[snap]: this doesn't appear to be used anywhere else? */
1211+ #define NM_DEFAULT_SYSTEM_STATE_FILE NMSTATEDIR "/NetworkManager.state"
1212
1213- static struct {
1214-@@ -385,7 +383,7 @@ main (int argc, char *argv[])
1215- fprintf (stderr, _("Failed to find interface index for %s (%s)\n"), global_opt.ifname, strerror (errno));
1216- return 1;
1217- }
1218-- pidfile = g_strdup_printf (NMIH_PID_FILE_FMT, gl.ifindex);
1219-+ pidfile = g_strdup_printf ("%s/nm-iface-helper-%d.pid", nm_utils_get_run_dir(), gl.ifindex);
1220- nm_main_utils_ensure_not_running_pidfile (pidfile);
1221+ #define CONFIG_ATOMIC_SECTION_PREFIXES ((char **) NULL)
1222+@@ -212,7 +215,7 @@ do_early_setup (int *argc, char **argv[], NMConfigCmdLineOptions *config_cli)
1223+ _("NetworkManager monitors all network connections and automatically\nchooses the best connection to use. It also allows the user to\nspecify wireless access points which wireless cards in the computer\nshould associate with.")))
1224+ exit (1);
1225
1226- nm_main_utils_ensure_rundir ();
1227-Index: nm/src/settings/nm-settings-connection.c
1228-===================================================================
1229---- nm.orig/src/settings/nm-settings-connection.c
1230-+++ nm/src/settings/nm-settings-connection.c
1231-@@ -41,9 +41,6 @@
1232+- global_opt.pidfile = global_opt.pidfile ? global_opt.pidfile : g_strdup (NM_DEFAULT_PID_FILE);
1233++ global_opt.pidfile = global_opt.pidfile ? global_opt.pidfile : g_strdup_printf ("%s/NetworkManager.pid", nm_utils_get_run_dir());
1234+ }
1235
1236- #include "introspection/org.freedesktop.NetworkManager.Settings.Connection.h"
1237+ /*
1238+@@ -244,7 +247,7 @@ main (int argc, char *argv[])
1239
1240--#define SETTINGS_TIMESTAMPS_FILE NMSTATEDIR "/timestamps"
1241--#define SETTINGS_SEEN_BSSIDS_FILE NMSTATEDIR "/seen-bssids"
1242--
1243- #define AUTOCONNECT_RETRIES_UNSET -2
1244- #define AUTOCONNECT_RETRIES_FOREVER -1
1245- #define AUTOCONNECT_RESET_RETRIES_TIMER 300
1246-@@ -146,6 +143,27 @@ G_DEFINE_TYPE_WITH_CODE (NMSettingsConne
1247+ /* we determine a first-start (contrary to a restart during the same boot)
1248+ * based on the existence of NM_CONFIG_DEVICE_STATE_DIR directory. */
1249+- config_cli = nm_config_cmd_line_options_new (!g_file_test (NM_CONFIG_DEVICE_STATE_DIR,
1250++ config_cli = nm_config_cmd_line_options_new (!g_file_test (nm_utils_get_conf_device_state_dir(),
1251+ G_FILE_TEST_IS_DIR));
1252+
1253+ do_early_setup (&argc, &argv, config_cli);
1254+diff --git a/src/nm-config.c b/src/nm-config.c
1255+index 29f0d5177..1624453d2 100644
1256+--- a/src/nm-config.c
1257++++ b/src/nm-config.c
1258+@@ -167,6 +167,16 @@ static void _set_config_data (NMConfig *self, NMConfigData *new_data, NMConfigCh
1259
1260 /*****************************************************************************/
1261
1262-+static const char *get_settings_timestamps_path()
1263++static const char *get_no_auto_default_file_path()
1264 +{
1265-+ static const char *timestamps_path = NULL;
1266-+
1267-+ if (!timestamps_path)
1268-+ timestamps_path = g_strdup_printf("%s/timestamps", nm_utils_get_state_dir());
1269-+
1270-+ return timestamps_path;
1271-+}
1272++ const char *no_auto_default_file = NULL;
1273 +
1274-+static const char *get_settings_seen_bssids_path()
1275-+{
1276-+ static const char *seen_bssids_path = NULL;
1277++ if (!no_auto_default_file)
1278++ no_auto_default_file = g_strdup_printf("%s/no-auto-default.state", nm_utils_get_state_dir());
1279 +
1280-+ if (!seen_bssids_path)
1281-+ seen_bssids_path = g_strdup_printf("%s/seen-bssids", nm_utils_get_state_dir());
1282-+ return seen_bssids_path;
1283++ return no_auto_default_file;
1284 +}
1285 +
1286-+/*****************************************************************************/
1287-+
1288- static void
1289- _emit_updated (NMSettingsConnection *self, gboolean by_user)
1290+ gint
1291+ nm_config_parse_boolean (const char *str,
1292+ gint default_value)
1293+@@ -2052,13 +2062,14 @@ NMConfigDeviceStateData *
1294+ nm_config_device_state_load (int ifindex)
1295 {
1296-@@ -748,9 +766,9 @@ remove_entry_from_db (NMSettingsConnecti
1297- const char *db_file;
1298+ NMConfigDeviceStateData *device_state;
1299+- char path[NM_STRLEN (NM_CONFIG_DEVICE_STATE_DIR) + 60];
1300++ gsize dev_state_dir_len = strlen (nm_utils_get_conf_device_state_dir ());
1301++ char path[dev_state_dir_len + 60];
1302+ gs_unref_keyfile GKeyFile *kf = NULL;
1303+ const char *nm_owned_str;
1304
1305- if (strcmp (db_name, "timestamps") == 0)
1306-- db_file = SETTINGS_TIMESTAMPS_FILE;
1307-+ db_file = get_settings_timestamps_path();
1308- else if (strcmp (db_name, "seen-bssids") == 0)
1309-- db_file = SETTINGS_SEEN_BSSIDS_FILE;
1310-+ db_file = get_settings_seen_bssids_path();
1311- else
1312- return;
1313+ g_return_val_if_fail (ifindex > 0, NULL);
1314
1315-@@ -2432,9 +2450,9 @@ nm_settings_connection_update_timestamp
1316+- nm_sprintf_buf (path, "%s/%d", NM_CONFIG_DEVICE_STATE_DIR, ifindex);
1317++ nm_sprintf_buf (path, "%s/%d", nm_utils_get_conf_device_state_dir(), ifindex);
1318
1319- /* Save timestamp to timestamps database file */
1320- timestamps_file = g_key_file_new ();
1321-- if (!g_key_file_load_from_file (timestamps_file, SETTINGS_TIMESTAMPS_FILE, G_KEY_FILE_KEEP_COMMENTS, &error)) {
1322-+ if (!g_key_file_load_from_file (timestamps_file, get_settings_timestamps_path(), G_KEY_FILE_KEEP_COMMENTS, &error)) {
1323- if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
1324-- _LOGW ("error parsing timestamps file '%s': %s", SETTINGS_TIMESTAMPS_FILE, error->message);
1325-+ _LOGW ("error parsing timestamps file '%s': %s", get_settings_timestamps_path(), error->message);
1326- g_clear_error (&error);
1327- }
1328+ kf = nm_config_create_keyfile ();
1329+ if (!g_key_file_load_from_file (kf, path, G_KEY_FILE_NONE, NULL))
1330+@@ -2102,7 +2113,7 @@ nm_config_device_state_load_all (void)
1331
1332-@@ -2445,11 +2463,11 @@ nm_settings_connection_update_timestamp
1333+ states = g_hash_table_new_full (nm_direct_hash, NULL, NULL, g_free);
1334
1335- data = g_key_file_to_data (timestamps_file, &len, &error);
1336- if (data) {
1337-- g_file_set_contents (SETTINGS_TIMESTAMPS_FILE, data, len, &error);
1338-+ g_file_set_contents (get_settings_timestamps_path(), data, len, &error);
1339- g_free (data);
1340- }
1341- if (error) {
1342-- _LOGW ("error saving timestamp to file '%s': %s", SETTINGS_TIMESTAMPS_FILE, error->message);
1343-+ _LOGW ("error saving timestamp to file '%s': %s", get_settings_timestamps_path(), error->message);
1344- g_error_free (error);
1345- }
1346- g_key_file_free (timestamps_file);
1347-@@ -2475,7 +2493,7 @@ nm_settings_connection_read_and_fill_tim
1348- g_return_if_fail (NM_IS_SETTINGS_CONNECTION (self));
1349+- dir = g_dir_open (NM_CONFIG_DEVICE_STATE_DIR, 0, NULL);
1350++ dir = g_dir_open (nm_utils_get_conf_device_state_dir(), 0, NULL);
1351+ if (!dir)
1352+ return states;
1353
1354- timestamps_file = g_key_file_new ();
1355-- if (!g_key_file_load_from_file (timestamps_file, SETTINGS_TIMESTAMPS_FILE, G_KEY_FILE_KEEP_COMMENTS, &error)) {
1356-+ if (!g_key_file_load_from_file (timestamps_file, get_settings_timestamps_path(), G_KEY_FILE_KEEP_COMMENTS, &error)) {
1357- _LOGD ("failed to read connection timestamp: %s", error->message);
1358- return;
1359- }
1360-@@ -2585,10 +2603,10 @@ nm_settings_connection_add_seen_bssid (N
1361- /* Save BSSID to seen-bssids file */
1362- seen_bssids_file = g_key_file_new ();
1363- g_key_file_set_list_separator (seen_bssids_file, ',');
1364-- if (!g_key_file_load_from_file (seen_bssids_file, SETTINGS_SEEN_BSSIDS_FILE, G_KEY_FILE_KEEP_COMMENTS, &error)) {
1365-+ if (!g_key_file_load_from_file (seen_bssids_file, get_settings_seen_bssids_path(), G_KEY_FILE_KEEP_COMMENTS, &error)) {
1366- if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) {
1367- _LOGW ("error parsing seen-bssids file '%s': %s",
1368-- SETTINGS_SEEN_BSSIDS_FILE, error->message);
1369-+ get_settings_seen_bssids_path(), error->message);
1370- }
1371- g_clear_error (&error);
1372- }
1373-@@ -2599,14 +2617,14 @@ nm_settings_connection_add_seen_bssid (N
1374+@@ -2134,7 +2145,8 @@ nm_config_device_state_write (int ifindex,
1375+ guint32 route_metric_default_aspired,
1376+ guint32 route_metric_default_effective)
1377+ {
1378+- char path[NM_STRLEN (NM_CONFIG_DEVICE_STATE_DIR) + 60];
1379++ gsize dev_state_dir_len = strlen (nm_utils_get_conf_device_state_dir ());
1380++ char path[dev_state_dir_len + 60];
1381+ GError *local = NULL;
1382+ gs_unref_keyfile GKeyFile *kf = NULL;
1383
1384- data = g_key_file_to_data (seen_bssids_file, &len, &error);
1385- if (data) {
1386-- g_file_set_contents (SETTINGS_SEEN_BSSIDS_FILE, data, len, &error);
1387-+ g_file_set_contents (get_settings_seen_bssids_path(), data, len, &error);
1388- g_free (data);
1389- }
1390- g_key_file_free (seen_bssids_file);
1391+@@ -2144,7 +2156,7 @@ nm_config_device_state_write (int ifindex,
1392
1393- if (error) {
1394- _LOGW ("error saving seen-bssids to file '%s': %s",
1395-- SETTINGS_SEEN_BSSIDS_FILE, error->message);
1396-+ get_settings_seen_bssids_path(), error->message);
1397- g_error_free (error);
1398- }
1399- }
1400-@@ -2631,7 +2649,7 @@ nm_settings_connection_read_and_fill_see
1401- /* Get seen BSSIDs from database file */
1402- seen_bssids_file = g_key_file_new ();
1403- g_key_file_set_list_separator (seen_bssids_file, ',');
1404-- if (g_key_file_load_from_file (seen_bssids_file, SETTINGS_SEEN_BSSIDS_FILE, G_KEY_FILE_KEEP_COMMENTS, NULL)) {
1405-+ if (g_key_file_load_from_file (seen_bssids_file, get_settings_seen_bssids_path(), G_KEY_FILE_KEEP_COMMENTS, NULL)) {
1406- connection_uuid = nm_settings_connection_get_uuid (self);
1407- tmp_strv = g_key_file_get_string_list (seen_bssids_file, "seen-bssids", connection_uuid, &len, NULL);
1408- }
1409-Index: nm/Makefile.am
1410-===================================================================
1411---- nm.orig/Makefile.am
1412-+++ nm/Makefile.am
1413-@@ -1135,6 +1135,7 @@ src_cppflags = \
1414- -DNMRUNDIR=\"$(nmrundir)\" \
1415- -DNMSTATEDIR=\"$(nmstatedir)\" \
1416- -DNMLIBDIR=\"$(nmlibdir)\" \
1417-+ -DPPPD_PLUGIN_DIR=\"$(PPPD_PLUGIN_DIR)\" \
1418- \
1419- -DDHCPCANON_PATH=\"$(DHCPCANON_PATH)\" \
1420- -DDHCLIENT_PATH=\"$(DHCLIENT_PATH)\" \
1421-Index: nm/src/settings/nm-settings.c
1422-===================================================================
1423---- nm.orig/src/settings/nm-settings.c
1424-+++ nm/src/settings/nm-settings.c
1425-@@ -76,6 +76,7 @@
1426- #include "NetworkManagerUtils.h"
1427- #include "nm-dispatcher.h"
1428- #include "nm-hostname-manager.h"
1429-+#include "nm-core-utils.h"
1430-
1431- #include "introspection/org.freedesktop.NetworkManager.Settings.h"
1432-
1433-@@ -717,7 +718,7 @@ load_plugin:
1434- int errsv;
1435-
1436- full_name = g_strdup_printf ("nm-settings-plugin-%s", pname);
1437-- path = g_module_build_path (NMPLUGINDIR, full_name);
1438-+ path = g_module_build_path (nm_utils_get_plugin_dir(), full_name);
1439-
1440- if (stat (path, &st) != 0) {
1441- errsv = errno;
1442-Index: nm/src/settings/plugins/keyfile/nms-keyfile-utils.c
1443-===================================================================
1444---- nm.orig/src/settings/plugins/keyfile/nms-keyfile-utils.c
1445-+++ nm/src/settings/plugins/keyfile/nms-keyfile-utils.c
1446-@@ -30,8 +30,6 @@
1447- #include "nm-setting-wireless-security.h"
1448- #include "nm-config.h"
1449-
1450--#define NM_CONFIG_KEYFILE_PATH_DEFAULT NMCONFDIR "/system-connections"
1451--
1452- /*****************************************************************************/
1453-
1454- static const char temp_letters[] =
1455-@@ -163,7 +161,8 @@ nms_keyfile_utils_get_path (void)
1456- NM_CONFIG_KEYFILE_KEY_KEYFILE_PATH,
1457- NM_CONFIG_GET_VALUE_STRIP | NM_CONFIG_GET_VALUE_NO_EMPTY);
1458- if (!path)
1459-- path = g_strdup (""NM_CONFIG_KEYFILE_PATH_DEFAULT"");
1460-+ path = g_strdup_printf ("%s/system-connections", nm_utils_get_conf_dir());
1461-+
1462- }
1463- return path;
1464- }
1465-Index: nm/src/dns/nm-dns-dnsmasq.c
1466-===================================================================
1467---- nm.orig/src/dns/nm-dns-dnsmasq.c
1468-+++ nm/src/dns/nm-dns-dnsmasq.c
1469-@@ -38,9 +38,6 @@
1470- #include "nm-bus-manager.h"
1471- #include "NetworkManagerUtils.h"
1472-
1473--#define PIDFILE NMRUNDIR "/dnsmasq.pid"
1474--#define CONFDIR NMCONFDIR "/dnsmasq.d"
1475--
1476- #define DNSMASQ_DBUS_SERVICE "org.freedesktop.NetworkManager.dnsmasq"
1477- #define DNSMASQ_DBUS_PATH "/uk/org/thekelleys/dnsmasq"
1478-
1479-@@ -480,6 +477,10 @@ start_dnsmasq (NMDnsDnsmasq *self)
1480- guint idx = 0;
1481- NMBusManager *dbus_mgr;
1482- GDBusConnection *connection;
1483-+ char *pidfile = NULL;
1484-+ char *pidfile_arg = NULL;
1485-+ char *confdir = NULL;
1486-+ char *confdir_arg = NULL;
1487-
1488- if (priv->running) {
1489- /* the dnsmasq process is running. Nothing to do. */
1490-@@ -498,12 +499,15 @@ start_dnsmasq (NMDnsDnsmasq *self)
1491- return;
1492- }
1493+ nm_assert (!perm_hw_addr_fake || nm_utils_hwaddr_valid (perm_hw_addr_fake, -1));
1494
1495-+ pidfile = g_strdup_printf ("%s/dnsmasq.pid", nm_utils_get_run_dir ());
1496-+ pidfile_arg = g_strdup_printf ("--pid-file=%s", pidfile);
1497-+
1498- argv[idx++] = dm_binary;
1499- argv[idx++] = "--no-resolv"; /* Use only commandline */
1500- argv[idx++] = "--keep-in-foreground";
1501- argv[idx++] = "--no-hosts"; /* don't use /etc/hosts to resolve */
1502- argv[idx++] = "--bind-interfaces";
1503-- argv[idx++] = "--pid-file=" PIDFILE;
1504-+ argv[idx++] = pidfile_arg;
1505- argv[idx++] = "--listen-address=127.0.1.1"; /* Should work for both 4 and 6 */
1506- argv[idx++] = "--cache-size=0";
1507- argv[idx++] = "--clear-on-reload"; /* clear cache when dns server changes */
1508-@@ -511,15 +515,24 @@ start_dnsmasq (NMDnsDnsmasq *self)
1509- argv[idx++] = "--proxy-dnssec"; /* Allow DNSSEC to pass through */
1510- argv[idx++] = "--enable-dbus=" DNSMASQ_DBUS_SERVICE;
1511+- nm_sprintf_buf (path, "%s/%d", NM_CONFIG_DEVICE_STATE_DIR, ifindex);
1512++ nm_sprintf_buf (path, "%s/%d", nm_utils_get_conf_device_state_dir(), ifindex);
1513
1514-+ confdir = g_strdup_printf ("%s/dnsmasq.d", nm_utils_get_conf_dir ());
1515-+ confdir_arg = g_strdup_printf ("--pid-file=%s", confdir);
1516+ kf = nm_config_create_keyfile ();
1517+ if (NM_IN_SET (managed,
1518+@@ -2209,12 +2221,15 @@ nm_config_device_state_prune_unseen (GHashTable *seen_ifindexes)
1519+ const char *fn;
1520+ int ifindex;
1521+ gsize fn_len;
1522+- char buf[NM_STRLEN (NM_CONFIG_DEVICE_STATE_DIR"/") + 30 + 3] = NM_CONFIG_DEVICE_STATE_DIR"/";
1523+- char *buf_p = &buf[NM_STRLEN (NM_CONFIG_DEVICE_STATE_DIR"/")];
1524++ gsize dev_state_dir_len = strlen (nm_utils_get_conf_device_state_dir ()) + 1;
1525++ char buf[dev_state_dir_len + 30 + 3];
1526++ char *buf_p = &buf[dev_state_dir_len];
1527 +
1528- /* dnsmasq exits if the conf dir is not present */
1529-- if (g_file_test (CONFDIR, G_FILE_TEST_IS_DIR))
1530-- argv[idx++] = "--conf-dir=" CONFDIR;
1531-+ if (g_file_test (confdir, G_FILE_TEST_IS_DIR))
1532-+ argv[idx++] = confdir_arg;
1533++ g_snprintf(buf, dev_state_dir_len, "%s/", nm_utils_get_conf_device_state_dir ());
1534
1535- argv[idx++] = NULL;
1536- nm_assert (idx <= G_N_ELEMENTS (argv));
1537+ g_return_if_fail (seen_ifindexes);
1538
1539- /* And finally spawn dnsmasq */
1540-- pid = nm_dns_plugin_child_spawn (NM_DNS_PLUGIN (self), argv, PIDFILE, "bin/dnsmasq");
1541-+ pid = nm_dns_plugin_child_spawn (NM_DNS_PLUGIN (self), argv, pidfile, "bin/dnsmasq");
1542-+
1543-+ g_free (pidfile);
1544-+ g_free (pidfile_arg);
1545-+ g_free (confdir);
1546-+ g_free (confdir_arg);
1547-+
1548- if (!pid)
1549+- dir = g_dir_open (NM_CONFIG_DEVICE_STATE_DIR, 0, NULL);
1550++ dir = g_dir_open (nm_utils_get_conf_device_state_dir (), 0, NULL);
1551+ if (!dir)
1552 return;
1553
1554-Index: nm/src/dnsmasq/nm-dnsmasq-manager.c
1555-===================================================================
1556---- nm.orig/src/dnsmasq/nm-dnsmasq-manager.c
1557-+++ nm/src/dnsmasq/nm-dnsmasq-manager.c
1558-@@ -35,8 +35,6 @@
1559- #include "NetworkManagerUtils.h"
1560- #include "nm-core-internal.h"
1561-
1562--#define CONFDIR NMCONFDIR "/dnsmasq-shared.d"
1563--
1564- /*****************************************************************************/
1565-
1566- enum {
1567-@@ -161,6 +159,8 @@ create_dm_cmd_line (const char *iface,
1568- const char *dm_binary;
1569- const NMPlatformIP4Address *listen_address;
1570- guint i, n;
1571-+ char *confdir = NULL;
1572-+ char *confdir_arg = NULL;
1573-
1574- listen_address = nm_ip4_config_get_first_address (ip4_config);
1575- g_return_val_if_fail (listen_address, NULL);
1576-@@ -254,10 +254,16 @@ create_dm_cmd_line (const char *iface,
1577- nm_cmd_line_add_string (cmd, s->str);
1578- g_string_truncate (s, 0);
1579-
1580-+ confdir = g_strdup_printf("%s/dnsmasq-shared.d", nm_utils_get_conf_dir());
1581-+
1582- /* dnsmasq exits if the conf dir is not present */
1583-- if (g_file_test (CONFDIR, G_FILE_TEST_IS_DIR))
1584-- nm_cmd_line_add_string (cmd, "--conf-dir=" CONFDIR);
1585-+ if (g_file_test (confdir, G_FILE_TEST_IS_DIR)) {
1586-+ confdir_arg = g_strdup_printf("--conf-dir=%s", confdir);
1587-+ nm_cmd_line_add_string (cmd, confdir_arg);
1588-+ }
1589-
1590-+ g_free (confdir);
1591-+ g_free (confdir_arg);
1592- return cmd;
1593- }
1594-
1595-@@ -381,7 +387,7 @@ nm_dnsmasq_manager_new (const char *ifac
1596+@@ -2525,7 +2540,7 @@ init_sync (GInitable *initable, GCancellable *cancellable, GError **error)
1597+ if (priv->cli.no_auto_default_file)
1598+ priv->no_auto_default_file = g_strdup (priv->cli.no_auto_default_file);
1599+ else
1600+- priv->no_auto_default_file = g_strdup (DEFAULT_NO_AUTO_DEFAULT_FILE);
1601++ priv->no_auto_default_file = g_strdup (get_no_auto_default_file_path());
1602
1603- priv = NM_DNSMASQ_MANAGER_GET_PRIVATE (manager);
1604- priv->iface = g_strdup (iface);
1605-- priv->pidfile = g_strdup_printf (RUNSTATEDIR "/nm-dnsmasq-%s.pid", iface);
1606-+ priv->pidfile = g_strdup_printf ("%s/nm-dnsmasq-%s.pid", nm_utils_get_run_dir(), iface);
1607+ priv->monitor_connection_files = nm_config_keyfile_get_boolean (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "monitor-connection-files", FALSE);
1608
1609- return manager;
1610- }
1611-Index: nm/src/nm-config.h
1612-===================================================================
1613---- nm.orig/src/nm-config.h
1614-+++ nm/src/nm-config.h
1615+diff --git a/src/nm-config.h b/src/nm-config.h
1616+index 42ab4682d..317357fa2 100644
1617+--- a/src/nm-config.h
1618++++ b/src/nm-config.h
1619 @@ -197,8 +197,6 @@ extern char *_nm_config_match_env;
1620
1621 /*****************************************************************************/
1622@@ -777,170 +599,378 @@ Index: nm/src/nm-config.h
1623 #define NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT_BOOL (nm_streq (""NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT, "true"))
1624 #define NM_CONFIG_DEFAULT_LOGGING_AUDIT_BOOL (nm_streq (""NM_CONFIG_DEFAULT_LOGGING_AUDIT, "true"))
1625
1626-Index: nm/src/dns/nm-dns-manager.c
1627-===================================================================
1628---- nm.orig/src/dns/nm-dns-manager.c
1629-+++ nm/src/dns/nm-dns-manager.c
1630-@@ -623,8 +623,6 @@ _read_link_cached (const char *path, gbo
1631- return (*cached = g_file_read_link (path, NULL));
1632- }
1633+diff --git a/src/nm-core-utils.c b/src/nm-core-utils.c
1634+index a8c593eca..b33203681 100644
1635+--- a/src/nm-core-utils.c
1636++++ b/src/nm-core-utils.c
1637+@@ -44,6 +44,7 @@
1638+ #include "nm-setting-ip6-config.h"
1639+ #include "nm-setting-wireless.h"
1640+ #include "nm-setting-wireless-security.h"
1641++#include "nm-core-utils.h"
1642
1643--#define MY_RESOLV_CONF NMRUNDIR "/resolv.conf"
1644--#define MY_RESOLV_CONF_TMP MY_RESOLV_CONF ".tmp"
1645- #define RESOLV_CONF_TMP "/etc/.resolv.conf.NetworkManager"
1646+ /*
1647+ * Some toolchains (E.G. uClibc 0.9.33 and earlier) don't export
1648+@@ -2978,14 +2979,17 @@ guint8 *
1649+ nm_utils_secret_key_read (gsize *out_key_len, GError **error)
1650+ {
1651+ guint8 *secret_key = NULL;
1652++ char *secret_key_path = NULL;
1653+ gsize key_len;
1654
1655- static SpawnResult
1656-@@ -644,6 +642,11 @@ update_resolv_conf (NMDnsManager *self,
1657- nm_auto_free char *rc_path_real = NULL;
1658- gboolean resconf_link_cached = FALSE;
1659- gs_free char *resconf_link = NULL;
1660-+ gs_free char *my_resolv_conf = NULL;
1661-+ gs_free char *my_resolv_conf_tmp = NULL;
1662-+
1663-+ my_resolv_conf = g_strdup_printf ("%s/resolv.conf", nm_utils_get_run_dir ());
1664-+ my_resolv_conf_tmp = g_strdup_printf ("%s.tmp", my_resolv_conf);
1665+ /* out_key_len is not optional, because without it you cannot safely
1666+ * access the returned memory. */
1667+ *out_key_len = 0;
1668
1669- /* If we are not managing /etc/resolv.conf and it points to
1670- * MY_RESOLV_CONF, don't write the private DNS configuration to
1671-@@ -654,9 +657,9 @@ update_resolv_conf (NMDnsManager *self,
1672- * internal resolv.conf file. */
1673- if (rc_manager == NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED) {
1674- if (nm_streq0 (_read_link_cached (_PATH_RESCONF, &resconf_link_cached, &resconf_link),
1675-- MY_RESOLV_CONF)) {
1676-- _LOGD ("update-resolv-conf: not updating " _PATH_RESCONF
1677-- " since it points to " MY_RESOLV_CONF);
1678-+ my_resolv_conf)) {
1679-+ _LOGD ("update-resolv-conf: not updating %s since it points to %s",
1680-+ _PATH_RESCONF, my_resolv_conf);
1681- return SR_SUCCESS;
1682++ secret_key_path = g_strdup_printf("%s/secret_key", nm_utils_get_state_dir());
1683++
1684+ /* Let's try to load a saved secret key first. */
1685+- if (g_file_get_contents (NMSTATEDIR "/secret_key", (char **) &secret_key, &key_len, NULL)) {
1686++ if (g_file_get_contents (secret_key_path, (char **) &secret_key, &key_len, NULL)) {
1687+ if (key_len < 16) {
1688+ g_set_error_literal (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN,
1689+ "Key is too short to be usable");
1690+@@ -3007,14 +3011,16 @@ nm_utils_secret_key_read (gsize *out_key_len, GError **error)
1691 }
1692- }
1693-@@ -689,16 +692,16 @@ update_resolv_conf (NMDnsManager *self,
1694+
1695+ key_mask = umask (0077);
1696+- if (!g_file_set_contents (NMSTATEDIR "/secret_key", (char *) secret_key, key_len, error)) {
1697+- g_prefix_error (error, "Can't write " NMSTATEDIR "/secret_key: ");
1698++
1699++ if (!g_file_set_contents (secret_key_path, (char *) secret_key, key_len, error)) {
1700++ g_prefix_error (error, "Can't write %s/secret_key: ", secret_key_path);
1701+ key_len = 0;
1702 }
1703+ umask (key_mask);
1704 }
1705
1706-- if ((f = fopen (MY_RESOLV_CONF_TMP, "we")) == NULL) {
1707-+ if ((f = fopen (my_resolv_conf_tmp, "we")) == NULL) {
1708- errsv = errno;
1709- g_set_error (error,
1710- NM_MANAGER_ERROR,
1711- NM_MANAGER_ERROR_FAILED,
1712- "Could not open %s: %s",
1713-- MY_RESOLV_CONF_TMP,
1714-+ my_resolv_conf_tmp,
1715- g_strerror (errsv));
1716- _LOGT ("update-resolv-conf: open temporary file %s failed (%s)",
1717-- MY_RESOLV_CONF_TMP, g_strerror (errsv));
1718-+ my_resolv_conf_tmp, g_strerror (errsv));
1719- return SR_ERROR;
1720- }
1721+ out:
1722++ g_free (secret_key_path);
1723+ if (key_len) {
1724+ *out_key_len = key_len;
1725+ return secret_key;
1726+@@ -3854,6 +3860,74 @@ nm_utils_ip4_address_is_link_local (in_addr_t addr)
1727
1728-@@ -706,7 +709,7 @@ update_resolv_conf (NMDnsManager *self,
1729- if (!success) {
1730- errsv = errno;
1731- _LOGT ("update-resolv-conf: write temporary file %s failed (%s)",
1732-- MY_RESOLV_CONF_TMP, g_strerror (errsv));
1733-+ my_resolv_conf_tmp, g_strerror (errsv));
1734- }
1735+ /*****************************************************************************/
1736
1737- if (fclose (f) < 0) {
1738-@@ -719,25 +722,25 @@ update_resolv_conf (NMDnsManager *self,
1739- NM_MANAGER_ERROR,
1740- NM_MANAGER_ERROR_FAILED,
1741- "Could not close %s: %s",
1742-- MY_RESOLV_CONF_TMP,
1743-+ my_resolv_conf_tmp,
1744- g_strerror (errsv));
1745- _LOGT ("update-resolv-conf: close temporary file %s failed (%s)",
1746-- MY_RESOLV_CONF_TMP, g_strerror (errsv));
1747-+ my_resolv_conf_tmp, g_strerror (errsv));
1748- }
1749- return SR_ERROR;
1750- } else if (!success)
1751- return SR_ERROR;
1752++const char*
1753++nm_utils_get_state_dir(void)
1754++{
1755++ static const char *state_dir = NULL;
1756++
1757++ if (!state_dir)
1758++ state_dir = g_strdup_printf("%s/state", getenv("SNAP_DATA"));
1759++
1760++ return state_dir;
1761++}
1762++
1763++const char*
1764++nm_utils_get_run_dir(void)
1765++{
1766++ static const char *run_dir = NULL;
1767++
1768++ if (!run_dir)
1769++ run_dir = g_strdup_printf("%s/run", getenv("SNAP_DATA"));
1770++
1771++ return run_dir;
1772++}
1773++
1774++const char*
1775++nm_utils_get_plugin_dir(void)
1776++{
1777++ static const char *plugin_dir = NULL;
1778++
1779++ if (!plugin_dir)
1780++ plugin_dir = g_strdup_printf("%s/%s", getenv("SNAP"), NMPLUGINDIR);
1781++
1782++ return plugin_dir;
1783++}
1784++
1785++const char*
1786++nm_utils_get_conf_dir(void)
1787++{
1788++ static const char *conf_dir = NULL;
1789++
1790++ if (!conf_dir)
1791++ conf_dir = g_strdup_printf("%s/conf", getenv("SNAP_DATA"));
1792++
1793++ return conf_dir;
1794++}
1795++
1796++const char*
1797++nm_utils_get_pppd_plugin_dir (void)
1798++{
1799++ static const char *pppd_plugin_dir = NULL;
1800++
1801++ if (!pppd_plugin_dir)
1802++ pppd_plugin_dir = g_strdup_printf("%s%s", getenv("SNAP"), PPPD_PLUGIN_DIR);
1803++
1804++ return pppd_plugin_dir;
1805++}
1806++
1807++const char*
1808++nm_utils_get_conf_device_state_dir (void)
1809++{
1810++ static const char *conf_device_state_dir = NULL;
1811++
1812++ if (!conf_device_state_dir)
1813++ conf_device_state_dir = g_strdup_printf("%s/devices", nm_utils_get_run_dir());
1814++
1815++ return conf_device_state_dir;
1816++}
1817++
1818++/*****************************************************************************/
1819++
1820+ /**
1821+ * Takes a pair @timestamp and @duration, and returns the remaining duration based
1822+ * on the new timestamp @now.
1823+diff --git a/src/nm-core-utils.h b/src/nm-core-utils.h
1824+index f43648c1b..249c0d87e 100644
1825+--- a/src/nm-core-utils.h
1826++++ b/src/nm-core-utils.h
1827+@@ -419,6 +419,13 @@ gboolean nm_utils_lifetime_get (guint32 timestamp,
1828
1829-- if (rename (MY_RESOLV_CONF_TMP, MY_RESOLV_CONF) < 0) {
1830-+ if (rename (my_resolv_conf_tmp, my_resolv_conf) < 0) {
1831- errsv = errno;
1832- g_set_error (error,
1833- NM_MANAGER_ERROR,
1834- NM_MANAGER_ERROR_FAILED,
1835- "Could not replace %s: %s",
1836-- MY_RESOLV_CONF,
1837-+ my_resolv_conf,
1838- g_strerror (errno));
1839- _LOGT ("update-resolv-conf: failed to rename temporary file %s to %s (%s)",
1840-- MY_RESOLV_CONF_TMP, MY_RESOLV_CONF, g_strerror (errsv));
1841-+ my_resolv_conf_tmp, my_resolv_conf, g_strerror (errsv));
1842- return SR_ERROR;
1843+ gboolean nm_utils_ip4_address_is_link_local (in_addr_t addr);
1844+
1845++const char* nm_utils_get_state_dir (void);
1846++const char* nm_utils_get_run_dir (void);
1847++const char* nm_utils_get_plugin_dir (void);
1848++const char* nm_utils_get_conf_dir (void);
1849++const char* nm_utils_get_pppd_plugin_dir (void);
1850++const char* nm_utils_get_conf_device_state_dir (void);
1851++
1852+ const char *nm_utils_dnsmasq_status_to_string (int status, char *dest, gsize size);
1853+
1854+ void nm_utils_get_reverse_dns_domains_ip4 (guint32 ip, guint8 plen, GPtrArray *domains);
1855+diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c
1856+index 1493ef197..0b1712da1 100644
1857+--- a/src/nm-iface-helper.c
1858++++ b/src/nm-iface-helper.c
1859+@@ -48,8 +48,6 @@
1860+ # define NM_DIST_VERSION VERSION
1861+ #endif
1862+
1863+-#define NMIH_PID_FILE_FMT NMRUNDIR "/nm-iface-helper-%d.pid"
1864+-
1865+ /*****************************************************************************/
1866+
1867+ static struct {
1868+@@ -385,7 +383,7 @@ main (int argc, char *argv[])
1869+ fprintf (stderr, _("Failed to find interface index for %s (%s)\n"), global_opt.ifname, strerror (errno));
1870+ return 1;
1871 }
1872+- pidfile = g_strdup_printf (NMIH_PID_FILE_FMT, gl.ifindex);
1873++ pidfile = g_strdup_printf ("%s/nm-iface-helper-%d.pid", nm_utils_get_run_dir(), gl.ifindex);
1874+ nm_main_utils_ensure_not_running_pidfile (pidfile);
1875
1876-@@ -749,14 +752,14 @@ update_resolv_conf (NMDnsManager *self,
1877+ nm_main_utils_ensure_rundir ();
1878+diff --git a/src/ppp/nm-ppp-manager.c b/src/ppp/nm-ppp-manager.c
1879+index 743f80a2b..cc0c38241 100644
1880+--- a/src/ppp/nm-ppp-manager.c
1881++++ b/src/ppp/nm-ppp-manager.c
1882+@@ -57,7 +57,7 @@
1883
1884- if ( rc_manager != NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK
1885- || !_read_link_cached (_PATH_RESCONF, &resconf_link_cached, &resconf_link)) {
1886-- _LOGT ("update-resolv-conf: write internal file %s succeeded", MY_RESOLV_CONF);
1887-+ _LOGT ("update-resolv-conf: write internal file %s succeeded", my_resolv_conf);
1888- return SR_SUCCESS;
1889+ #include "introspection/org.freedesktop.NetworkManager.PPP.h"
1890+
1891+-#define NM_PPPD_PLUGIN PPPD_PLUGIN_DIR "/nm-pppd-plugin.so"
1892++#define NM_PPPD_PLUGIN "nm-pppd-plugin.so"
1893+
1894+ static NM_CACHED_QUARK_FCN ("ppp-manager-secret-tries", ppp_manager_secret_tries_quark)
1895+
1896+@@ -739,6 +739,7 @@ create_pppd_cmd_line (NMPPPManager *self,
1897+ const char *pppd_binary = NULL;
1898+ NMCmdLine *cmd;
1899+ gboolean ppp_debug;
1900++ char *pppd_plugin_dir;
1901+ static int unit;
1902+
1903+ g_return_val_if_fail (setting != NULL, NULL);
1904+@@ -901,8 +902,12 @@ create_pppd_cmd_line (NMPPPManager *self,
1905+ nm_cmd_line_add_string (cmd, "ipparam");
1906+ nm_cmd_line_add_string (cmd, nm_exported_object_get_path (NM_EXPORTED_OBJECT (self)));
1907+
1908++ pppd_plugin_dir = g_strdup_printf ("%s/%s", nm_utils_get_pppd_plugin_dir (), NM_PPPD_PLUGIN);
1909++
1910+ nm_cmd_line_add_string (cmd, "plugin");
1911+- nm_cmd_line_add_string (cmd, NM_PPPD_PLUGIN);
1912++ nm_cmd_line_add_string (cmd, pppd_plugin_dir);
1913++
1914++ g_free (pppd_plugin_dir);
1915+
1916+ if (pppoe && nm_setting_pppoe_get_parent (pppoe)) {
1917+ /* The PPP interface is going to be renamed, so pass a
1918+diff --git a/src/settings/nm-settings-connection.c b/src/settings/nm-settings-connection.c
1919+index 586263721..709ee6710 100644
1920+--- a/src/settings/nm-settings-connection.c
1921++++ b/src/settings/nm-settings-connection.c
1922+@@ -41,9 +41,6 @@
1923+
1924+ #include "introspection/org.freedesktop.NetworkManager.Settings.Connection.h"
1925+
1926+-#define SETTINGS_TIMESTAMPS_FILE NMSTATEDIR "/timestamps"
1927+-#define SETTINGS_SEEN_BSSIDS_FILE NMSTATEDIR "/seen-bssids"
1928+-
1929+ #define AUTOCONNECT_RETRIES_UNSET -2
1930+ #define AUTOCONNECT_RETRIES_FOREVER -1
1931+ #define AUTOCONNECT_RESET_RETRIES_TIMER 300
1932+@@ -146,6 +143,27 @@ G_DEFINE_TYPE_WITH_CODE (NMSettingsConnection, nm_settings_connection, NM_TYPE_E
1933+
1934+ /*****************************************************************************/
1935+
1936++static const char *get_settings_timestamps_path()
1937++{
1938++ static const char *timestamps_path = NULL;
1939++
1940++ if (!timestamps_path)
1941++ timestamps_path = g_strdup_printf("%s/timestamps", nm_utils_get_state_dir());
1942++
1943++ return timestamps_path;
1944++}
1945++
1946++static const char *get_settings_seen_bssids_path()
1947++{
1948++ static const char *seen_bssids_path = NULL;
1949++
1950++ if (!seen_bssids_path)
1951++ seen_bssids_path = g_strdup_printf("%s/seen-bssids", nm_utils_get_state_dir());
1952++ return seen_bssids_path;
1953++}
1954++
1955++/*****************************************************************************/
1956++
1957+ static void
1958+ _emit_updated (NMSettingsConnection *self, gboolean by_user)
1959+ {
1960+@@ -748,9 +766,9 @@ remove_entry_from_db (NMSettingsConnection *self, const char* db_name)
1961+ const char *db_file;
1962+
1963+ if (strcmp (db_name, "timestamps") == 0)
1964+- db_file = SETTINGS_TIMESTAMPS_FILE;
1965++ db_file = get_settings_timestamps_path();
1966+ else if (strcmp (db_name, "seen-bssids") == 0)
1967+- db_file = SETTINGS_SEEN_BSSIDS_FILE;
1968++ db_file = get_settings_seen_bssids_path();
1969+ else
1970+ return;
1971+
1972+@@ -2432,9 +2450,9 @@ nm_settings_connection_update_timestamp (NMSettingsConnection *self,
1973+
1974+ /* Save timestamp to timestamps database file */
1975+ timestamps_file = g_key_file_new ();
1976+- if (!g_key_file_load_from_file (timestamps_file, SETTINGS_TIMESTAMPS_FILE, G_KEY_FILE_KEEP_COMMENTS, &error)) {
1977++ if (!g_key_file_load_from_file (timestamps_file, get_settings_timestamps_path(), G_KEY_FILE_KEEP_COMMENTS, &error)) {
1978+ if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
1979+- _LOGW ("error parsing timestamps file '%s': %s", SETTINGS_TIMESTAMPS_FILE, error->message);
1980++ _LOGW ("error parsing timestamps file '%s': %s", get_settings_timestamps_path(), error->message);
1981+ g_clear_error (&error);
1982 }
1983
1984- if (!nm_streq0 (_read_link_cached (_PATH_RESCONF, &resconf_link_cached, &resconf_link),
1985-- MY_RESOLV_CONF)) {
1986-+ my_resolv_conf)) {
1987- _LOGT ("update-resolv-conf: write internal file %s succeeded (don't touch symlink %s linking to %s)",
1988-- MY_RESOLV_CONF, _PATH_RESCONF,
1989-+ my_resolv_conf, _PATH_RESCONF,
1990- _read_link_cached (_PATH_RESCONF, &resconf_link_cached, &resconf_link));
1991- return SR_SUCCESS;
1992+@@ -2445,11 +2463,11 @@ nm_settings_connection_update_timestamp (NMSettingsConnection *self,
1993+
1994+ data = g_key_file_to_data (timestamps_file, &len, &error);
1995+ if (data) {
1996+- g_file_set_contents (SETTINGS_TIMESTAMPS_FILE, data, len, &error);
1997++ g_file_set_contents (get_settings_timestamps_path(), data, len, &error);
1998+ g_free (data);
1999 }
2000-@@ -775,22 +778,22 @@ update_resolv_conf (NMDnsManager *self,
2001- g_strerror (errsv));
2002- _LOGT ("update-resolv-conf: write internal file %s succeeded "
2003- "but canot delete temporary file %s: %s",
2004-- MY_RESOLV_CONF, RESOLV_CONF_TMP, g_strerror (errsv));
2005-+ my_resolv_conf, RESOLV_CONF_TMP, g_strerror (errsv));
2006- return SR_ERROR;
2007+ if (error) {
2008+- _LOGW ("error saving timestamp to file '%s': %s", SETTINGS_TIMESTAMPS_FILE, error->message);
2009++ _LOGW ("error saving timestamp to file '%s': %s", get_settings_timestamps_path(), error->message);
2010+ g_error_free (error);
2011 }
2012+ g_key_file_free (timestamps_file);
2013+@@ -2475,7 +2493,7 @@ nm_settings_connection_read_and_fill_timestamp (NMSettingsConnection *self)
2014+ g_return_if_fail (NM_IS_SETTINGS_CONNECTION (self));
2015
2016-- if (symlink (MY_RESOLV_CONF, RESOLV_CONF_TMP) == -1) {
2017-+ if (symlink (my_resolv_conf, RESOLV_CONF_TMP) == -1) {
2018- errsv = errno;
2019- g_set_error (error,
2020- NM_MANAGER_ERROR,
2021- NM_MANAGER_ERROR_FAILED,
2022- "Could not create symlink %s pointing to %s: %s",
2023- RESOLV_CONF_TMP,
2024-- MY_RESOLV_CONF,
2025-+ my_resolv_conf,
2026- g_strerror (errsv));
2027- _LOGT ("update-resolv-conf: write internal file %s succeeded "
2028- "but failed to symlink %s: %s",
2029-- MY_RESOLV_CONF, RESOLV_CONF_TMP, g_strerror (errsv));
2030-+ my_resolv_conf, RESOLV_CONF_TMP, g_strerror (errsv));
2031- return SR_ERROR;
2032+ timestamps_file = g_key_file_new ();
2033+- if (!g_key_file_load_from_file (timestamps_file, SETTINGS_TIMESTAMPS_FILE, G_KEY_FILE_KEEP_COMMENTS, &error)) {
2034++ if (!g_key_file_load_from_file (timestamps_file, get_settings_timestamps_path(), G_KEY_FILE_KEEP_COMMENTS, &error)) {
2035+ _LOGD ("failed to read connection timestamp: %s", error->message);
2036+ return;
2037 }
2038+@@ -2585,10 +2603,10 @@ nm_settings_connection_add_seen_bssid (NMSettingsConnection *self,
2039+ /* Save BSSID to seen-bssids file */
2040+ seen_bssids_file = g_key_file_new ();
2041+ g_key_file_set_list_separator (seen_bssids_file, ',');
2042+- if (!g_key_file_load_from_file (seen_bssids_file, SETTINGS_SEEN_BSSIDS_FILE, G_KEY_FILE_KEEP_COMMENTS, &error)) {
2043++ if (!g_key_file_load_from_file (seen_bssids_file, get_settings_seen_bssids_path(), G_KEY_FILE_KEEP_COMMENTS, &error)) {
2044+ if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) {
2045+ _LOGW ("error parsing seen-bssids file '%s': %s",
2046+- SETTINGS_SEEN_BSSIDS_FILE, error->message);
2047++ get_settings_seen_bssids_path(), error->message);
2048+ }
2049+ g_clear_error (&error);
2050+ }
2051+@@ -2599,14 +2617,14 @@ nm_settings_connection_add_seen_bssid (NMSettingsConnection *self,
2052
2053-@@ -805,12 +808,12 @@ update_resolv_conf (NMDnsManager *self,
2054- g_strerror (errsv));
2055- _LOGT ("update-resolv-conf: write internal file %s succeeded "
2056- "but failed to rename temporary symlink %s to %s: %s",
2057-- MY_RESOLV_CONF, RESOLV_CONF_TMP, _PATH_RESCONF, g_strerror (errsv));
2058-+ my_resolv_conf, RESOLV_CONF_TMP, _PATH_RESCONF, g_strerror (errsv));
2059- return SR_ERROR;
2060+ data = g_key_file_to_data (seen_bssids_file, &len, &error);
2061+ if (data) {
2062+- g_file_set_contents (SETTINGS_SEEN_BSSIDS_FILE, data, len, &error);
2063++ g_file_set_contents (get_settings_seen_bssids_path(), data, len, &error);
2064+ g_free (data);
2065 }
2066+ g_key_file_free (seen_bssids_file);
2067
2068- _LOGT ("update-resolv-conf: write internal file %s succeeded and update symlink %s",
2069-- MY_RESOLV_CONF, _PATH_RESCONF);
2070-+ my_resolv_conf, _PATH_RESCONF);
2071- return SR_SUCCESS;
2072+ if (error) {
2073+ _LOGW ("error saving seen-bssids to file '%s': %s",
2074+- SETTINGS_SEEN_BSSIDS_FILE, error->message);
2075++ get_settings_seen_bssids_path(), error->message);
2076+ g_error_free (error);
2077+ }
2078 }
2079+@@ -2631,7 +2649,7 @@ nm_settings_connection_read_and_fill_seen_bssids (NMSettingsConnection *self)
2080+ /* Get seen BSSIDs from database file */
2081+ seen_bssids_file = g_key_file_new ();
2082+ g_key_file_set_list_separator (seen_bssids_file, ',');
2083+- if (g_key_file_load_from_file (seen_bssids_file, SETTINGS_SEEN_BSSIDS_FILE, G_KEY_FILE_KEEP_COMMENTS, NULL)) {
2084++ if (g_key_file_load_from_file (seen_bssids_file, get_settings_seen_bssids_path(), G_KEY_FILE_KEEP_COMMENTS, NULL)) {
2085+ connection_uuid = nm_settings_connection_get_uuid (self);
2086+ tmp_strv = g_key_file_get_string_list (seen_bssids_file, "seen-bssids", connection_uuid, &len, NULL);
2087+ }
2088+diff --git a/src/settings/nm-settings.c b/src/settings/nm-settings.c
2089+index 8e3fc582e..6ccccd250 100644
2090+--- a/src/settings/nm-settings.c
2091++++ b/src/settings/nm-settings.c
2092+@@ -76,6 +76,7 @@
2093+ #include "NetworkManagerUtils.h"
2094+ #include "nm-dispatcher.h"
2095+ #include "nm-hostname-manager.h"
2096++#include "nm-core-utils.h"
2097
2098-@@ -1660,6 +1663,8 @@ again:
2099- _clear_plugin (self);
2100- priv->plugin = nm_dns_systemd_resolved_new ();
2101- plugin_changed = TRUE;
2102+ #include "introspection/org.freedesktop.NetworkManager.Settings.h"
2103+
2104+@@ -717,7 +718,7 @@ load_plugin:
2105+ int errsv;
2106+
2107+ full_name = g_strdup_printf ("nm-settings-plugin-%s", pname);
2108+- path = g_module_build_path (NMPLUGINDIR, full_name);
2109++ path = g_module_build_path (nm_utils_get_plugin_dir(), full_name);
2110+
2111+ if (stat (path, &st) != 0) {
2112+ errsv = errno;
2113+diff --git a/src/settings/plugins/keyfile/nms-keyfile-utils.c b/src/settings/plugins/keyfile/nms-keyfile-utils.c
2114+index 03f06670f..999495acc 100644
2115+--- a/src/settings/plugins/keyfile/nms-keyfile-utils.c
2116++++ b/src/settings/plugins/keyfile/nms-keyfile-utils.c
2117+@@ -30,8 +30,6 @@
2118+ #include "nm-setting-wireless-security.h"
2119+ #include "nm-config.h"
2120+
2121+-#define NM_CONFIG_KEYFILE_PATH_DEFAULT NMCONFDIR "/system-connections"
2122+-
2123+ /*****************************************************************************/
2124+
2125+ static const char temp_letters[] =
2126+@@ -163,7 +161,8 @@ nms_keyfile_utils_get_path (void)
2127+ NM_CONFIG_KEYFILE_KEY_KEYFILE_PATH,
2128+ NM_CONFIG_GET_VALUE_STRIP | NM_CONFIG_GET_VALUE_NO_EMPTY);
2129+ if (!path)
2130+- path = g_strdup (""NM_CONFIG_KEYFILE_PATH_DEFAULT"");
2131++ path = g_strdup_printf ("%s/system-connections", nm_utils_get_conf_dir());
2132 +
2133-+ _LOGI ("init: plugin_changed: systemd-resolvd");
2134- }
2135- mode = "systemd-resolved";
2136- } else if (nm_streq0 (mode, "dnsmasq")) {
2137+ }
2138+ return path;
2139+ }
2140+--
2141+2.17.1
2142+
2143diff --git a/debian/patches/disable-tests-that-fail-under-launchpad-builds.patch b/snap-patch/networkmanager/0005-Disable-tests-that-fail-on-LP-build.patch
2144similarity index 87%
2145rename from debian/patches/disable-tests-that-fail-under-launchpad-builds.patch
2146rename to snap-patch/networkmanager/0005-Disable-tests-that-fail-on-LP-build.patch
2147index f77ac03..8660aba 100644
2148--- a/debian/patches/disable-tests-that-fail-under-launchpad-builds.patch
2149+++ b/snap-patch/networkmanager/0005-Disable-tests-that-fail-on-LP-build.patch
2150@@ -1,5 +1,19 @@
2151+From e613ccfb5358c867c7d77b7d0e1d9f30e9f63e05 Mon Sep 17 00:00:00 2001
2152+From: =?UTF-8?q?Alfonso=20S=C3=A1nchez-Beato?=
2153+ <alfonso.sanchez-beato@canonical.com>
2154+Date: Thu, 30 Jan 2020 13:28:52 +0100
2155+Subject: [PATCH 5/6] Disable tests that fail on LP build
2156+
2157+---
2158+ src/devices/tests/test-arping.c | 3 +++
2159+ src/platform/tests/test-address.c | 3 +++
2160+ src/platform/tests/test-link.c | 9 +++++++--
2161+ src/platform/tests/test-nmp-object.c | 2 +-
2162+ src/platform/tests/test-route.c | 3 +++
2163+ 5 files changed, 17 insertions(+), 3 deletions(-)
2164+
2165 diff --git a/src/devices/tests/test-arping.c b/src/devices/tests/test-arping.c
2166-index bcbc1140..2de53b2b 100644
2167+index bcbc1140d..2de53b2b0 100644
2168 --- a/src/devices/tests/test-arping.c
2169 +++ b/src/devices/tests/test-arping.c
2170 @@ -135,6 +135,9 @@ _nmtstp_init_tests (int *argc, char ***argv)
2171@@ -13,7 +27,7 @@ index bcbc1140..2de53b2b 100644
2172 g_test_add ("/arping/2", test_fixture, NULL, fixture_setup, test_arping_2, fixture_teardown);
2173 }
2174 diff --git a/src/platform/tests/test-address.c b/src/platform/tests/test-address.c
2175-index 93851ff7..a6e53c83 100644
2176+index 93851ff7e..a6e53c833 100644
2177 --- a/src/platform/tests/test-address.c
2178 +++ b/src/platform/tests/test-address.c
2179 @@ -368,6 +368,9 @@ _nmtstp_init_tests (int *argc, char ***argv)
2180@@ -27,7 +41,7 @@ index 93851ff7..a6e53c83 100644
2181 add_test_func ("/address/ipv4/general", test_ip4_address_general);
2182 add_test_func ("/address/ipv6/general", test_ip6_address_general);
2183 diff --git a/src/platform/tests/test-link.c b/src/platform/tests/test-link.c
2184-index ef78cc24..37189d9f 100644
2185+index ef78cc244..37189d9f4 100644
2186 --- a/src/platform/tests/test-link.c
2187 +++ b/src/platform/tests/test-link.c
2188 @@ -475,13 +475,15 @@ test_bond (void)
2189@@ -59,7 +73,7 @@ index ef78cc24..37189d9f 100644
2190 g_test_add_func ("/link/loopback", test_loopback);
2191 g_test_add_func ("/link/internal", test_internal);
2192 diff --git a/src/platform/tests/test-nmp-object.c b/src/platform/tests/test-nmp-object.c
2193-index 3228de83..7f7174f5 100644
2194+index 3228de834..7f7174f51 100644
2195 --- a/src/platform/tests/test-nmp-object.c
2196 +++ b/src/platform/tests/test-nmp-object.c
2197 @@ -587,7 +587,7 @@ main (int argc, char **argv)
2198@@ -72,7 +86,7 @@ index 3228de83..7f7174f5 100644
2199
2200 result = g_test_run ();
2201 diff --git a/src/platform/tests/test-route.c b/src/platform/tests/test-route.c
2202-index 13648f16..665a5937 100644
2203+index 13648f16e..665a59370 100644
2204 --- a/src/platform/tests/test-route.c
2205 +++ b/src/platform/tests/test-route.c
2206 @@ -885,6 +885,9 @@ _nmtstp_init_tests (int *argc, char ***argv)
2207@@ -85,3 +99,6 @@ index 13648f16..665a5937 100644
2208 #define add_test_func(testpath, test_func) nmtstp_env1_add_test_func(testpath, test_func, TRUE)
2209 #define add_test_func_data(testpath, test_func, arg) nmtstp_env1_add_test_func_data(testpath, test_func, arg, TRUE)
2210 add_test_func ("/route/ip4", test_ip4_route);
2211+--
2212+2.17.1
2213+
2214diff --git a/debian/patches/snap-support-ppp.patch b/snap-patch/networkmanager/0006-Add-snap-support-for-ppp.patch
2215similarity index 85%
2216rename from debian/patches/snap-support-ppp.patch
2217rename to snap-patch/networkmanager/0006-Add-snap-support-for-ppp.patch
2218index 5b13a63..9d1faf6 100644
2219--- a/debian/patches/snap-support-ppp.patch
2220+++ b/snap-patch/networkmanager/0006-Add-snap-support-for-ppp.patch
2221@@ -1,7 +1,62 @@
2222-Index: build/src/ppp/nm-ppp-manager-call.c
2223-===================================================================
2224---- build.orig/src/ppp/nm-ppp-manager-call.c
2225-+++ build/src/ppp/nm-ppp-manager-call.c
2226+From 72b96e130664e28b73d9f9b34d4c6d829e840e27 Mon Sep 17 00:00:00 2001
2227+From: =?UTF-8?q?Alfonso=20S=C3=A1nchez-Beato?=
2228+ <alfonso.sanchez-beato@canonical.com>
2229+Date: Thu, 30 Jan 2020 13:29:46 +0100
2230+Subject: [PATCH 6/6] Add snap support for ppp
2231+
2232+---
2233+ src/nm-core-utils.c | 30 +++++++++++++++++++++++++-
2234+ src/ppp/nm-ppp-manager-call.c | 40 ++++++++++++++++++++---------------
2235+ 2 files changed, 52 insertions(+), 18 deletions(-)
2236+
2237+diff --git a/src/nm-core-utils.c b/src/nm-core-utils.c
2238+index b33203681..775291edd 100644
2239+--- a/src/nm-core-utils.c
2240++++ b/src/nm-core-utils.c
2241+@@ -1171,10 +1171,38 @@ const char *const NM_PATHS_DEFAULT[] = {
2242+ NULL,
2243+ };
2244+
2245++const char *const *
2246++utils_get_search_paths(void)
2247++{
2248++ static char **paths;
2249++
2250++ const char *snap_path;
2251++
2252++ if (paths)
2253++ return (const char *const *) paths;
2254++
2255++ snap_path = getenv("SNAP");
2256++ if (snap_path) {
2257++ unsigned np, i;
2258++
2259++ np = g_strv_length((char **) NM_PATHS_DEFAULT);
2260++ paths = malloc(sizeof(char *)*(np*2 + 1));
2261++ for (i = 0; i < np; ++i) {
2262++ paths[i] = g_strdup_printf("%s%s", snap_path, NM_PATHS_DEFAULT[i]);
2263++ paths[np + i] = g_strdup(NM_PATHS_DEFAULT[i]);
2264++ }
2265++ paths[2*np] = NULL;
2266++ } else {
2267++ paths = g_strdupv((char **) NM_PATHS_DEFAULT);;
2268++ }
2269++
2270++ return (const char *const *) paths;
2271++}
2272++
2273+ const char *
2274+ nm_utils_find_helper(const char *progname, const char *try_first, GError **error)
2275+ {
2276+- return nm_utils_file_search_in_paths (progname, try_first, NM_PATHS_DEFAULT, G_FILE_TEST_IS_EXECUTABLE, NULL, NULL, error);
2277++ return nm_utils_file_search_in_paths (progname, try_first, utils_get_search_paths (), G_FILE_TEST_IS_EXECUTABLE, NULL, NULL, error);
2278+ }
2279+
2280+ /*****************************************************************************/
2281+diff --git a/src/ppp/nm-ppp-manager-call.c b/src/ppp/nm-ppp-manager-call.c
2282+index ad3307a9d..12fe18338 100644
2283+--- a/src/ppp/nm-ppp-manager-call.c
2284++++ b/src/ppp/nm-ppp-manager-call.c
2285 @@ -30,7 +30,7 @@
2286 #include "nm-core-utils.h"
2287 #include "nm-ppp-plugin-api.h"
2288@@ -72,7 +127,7 @@ Index: build/src/ppp/nm-ppp-manager-call.c
2289 }
2290
2291 /* after loading glib types from the plugin, we cannot unload the library anymore.
2292-@@ -90,11 +93,14 @@ nm_ppp_manager_create (const char *iface
2293+@@ -90,11 +93,14 @@ nm_ppp_manager_create (const char *iface, GError **error)
2294
2295 ppp_ops = ops;
2296
2297@@ -88,47 +143,6 @@ Index: build/src/ppp/nm-ppp-manager-call.c
2298 return ret;
2299 }
2300
2301-Index: build/src/nm-core-utils.c
2302-===================================================================
2303---- build.orig/src/nm-core-utils.c
2304-+++ build/src/nm-core-utils.c
2305-@@ -1171,10 +1171,38 @@ const char *const NM_PATHS_DEFAULT[] = {
2306- NULL,
2307- };
2308-
2309-+const char *const *
2310-+utils_get_search_paths(void)
2311-+{
2312-+ static char **paths;
2313-+
2314-+ const char *snap_path;
2315-+
2316-+ if (paths)
2317-+ return (const char *const *) paths;
2318-+
2319-+ snap_path = getenv("SNAP");
2320-+ if (snap_path) {
2321-+ unsigned np, i;
2322-+
2323-+ np = g_strv_length((char **) NM_PATHS_DEFAULT);
2324-+ paths = malloc(sizeof(char *)*(np*2 + 1));
2325-+ for (i = 0; i < np; ++i) {
2326-+ paths[i] = g_strdup_printf("%s%s", snap_path, NM_PATHS_DEFAULT[i]);
2327-+ paths[np + i] = g_strdup(NM_PATHS_DEFAULT[i]);
2328-+ }
2329-+ paths[2*np] = NULL;
2330-+ } else {
2331-+ paths = g_strdupv((char **) NM_PATHS_DEFAULT);;
2332-+ }
2333-+
2334-+ return (const char *const *) paths;
2335-+}
2336-+
2337- const char *
2338- nm_utils_find_helper(const char *progname, const char *try_first, GError **error)
2339- {
2340-- return nm_utils_file_search_in_paths (progname, try_first, NM_PATHS_DEFAULT, G_FILE_TEST_IS_EXECUTABLE, NULL, NULL, error);
2341-+ return nm_utils_file_search_in_paths (progname, try_first, utils_get_search_paths (), G_FILE_TEST_IS_EXECUTABLE, NULL, NULL, error);
2342- }
2343-
2344- /*****************************************************************************/
2345+--
2346+2.17.1
2347+
2348diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
2349index dfa30b8..77bbb1a 100644
2350--- a/snap/snapcraft.yaml
2351+++ b/snap/snapcraft.yaml
2352@@ -1,7 +1,5 @@
2353 name: network-manager
2354-version: 1.10.6-2
2355-version-script: |
2356- echo $SNAPCRAFT_PROJECT_VERSION-$(date +%Y%m%d)+$(git rev-parse --short HEAD)
2357+version: 1.10.6-3-dev
2358 summary: Network Manager
2359 description: |
2360 NetworkManager is a system network service that manages your network
2361@@ -9,7 +7,7 @@ description: |
2362 when available. It manages ethernet, WiFi, mobile broadband (WWAN) and
2363 PPPoE devices, provides VPN integration with a variety of different
2364 VPN serivces.
2365- Please find the source code at: https://code.launchpad.net/~network-manager/network-manager/+git/ubuntu/+ref/snap-1.10
2366+ Please find the source code at: https://code.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager/+ref/snap-1.10
2367 base: core18
2368 confinement: strict
2369 grade: stable
2370@@ -50,11 +48,8 @@ apps:
2371 command: bin/networkmanager
2372 daemon: simple
2373 slots: [service]
2374- plugs: [modem-manager, ppp, network-setup-observe, wpa, firewall-control, hardware-observe]
2375-
2376-layout:
2377- /usr/lib/x86_64-linux-gnu/xtables:
2378- bind: $SNAP/usr/lib/x86_64-linux-gnu/xtables
2379+ plugs: [modem-manager, ppp, network-setup-observe, wpa, firewall-control,
2380+ hardware-observe, network-setup-control]
2381
2382 parts:
2383 networkmanager-common:
2384@@ -72,13 +67,13 @@ parts:
2385 plugin: make
2386 source: https://git.launchpad.net/ubuntu/+source/dnsmasq
2387 source-type: git
2388- source-branch: applied/ubuntu/bionic
2389+ source-branch: applied/2.79-1
2390 build-packages:
2391 - build-essential
2392 make-parameters:
2393 - PREFIX=/
2394 override-build: |
2395- git apply ../../../snap-patch/dnsmasq.patch
2396+ git apply "$SNAPCRAFT_PROJECT_DIR"/snap-patch/dnsmasq.patch
2397 snapcraftctl build
2398 filesets:
2399 binaries:
2400@@ -110,7 +105,9 @@ parts:
2401 # - $wanted
2402 networkmanager:
2403 plugin: autotools
2404- source: .
2405+ source: https://git.launchpad.net/ubuntu/+source/network-manager
2406+ source-type: git
2407+ source-branch: applied/1.10.6-2ubuntu1.2
2408 build-packages:
2409 - intltool
2410 - libdbus-glib-1-dev
2411@@ -154,7 +151,7 @@ parts:
2412 - --with-dhcpcd=no
2413 - --with-dhclient=no
2414 - --with-dnsmasq=no
2415- - --with-iptables=/snap/$SNAPCRAFT_PROJECT_NAME/current/sbin/iptables
2416+ - --with-iptables=/sbin/iptables
2417 - --with-systemd-journal=yes
2418 - --libexecdir=/snap/$SNAPCRAFT_PROJECT_NAME/current/usr/lib/NetworkManager
2419 - --with-pppd=/snap/$SNAPCRAFT_PROJECT_NAME/current/usr/sbin/pppd
2420@@ -194,9 +191,9 @@ parts:
2421 # Set explicitly CFLAGS until lp: #1791946 is solved
2422 - CFLAGS=-O2
2423 override-build: |
2424- echo "networkmanager override-build called <patches go here>"
2425- export QUILT_PATCHES=debian/patches
2426- quilt push -a
2427+ git config user.email "snapcraft@canonical.com"
2428+ git config user.name "snapcraft"
2429+ git am "$SNAPCRAFT_PROJECT_DIR"/snap-patch/networkmanager/*.patch
2430
2431 # remove configure to trigger autotools
2432 rm ./configure
2433@@ -205,24 +202,17 @@ parts:
2434 # Run all tests NetworkManager ships by default
2435 make check
2436 stage-packages:
2437- - iptables
2438 - iputils-arping
2439 - libasn1-8-heimdal
2440 - libdbus-glib-1-2
2441 - libcurl3-gnutls
2442 - libgssapi3-heimdal
2443- - libgssapi-krb5-2
2444 - libhcrypto4-heimdal
2445 - libheimbase1-heimdal
2446 - libheimntlm0-heimdal
2447 - libhx509-5-heimdal
2448- - libidn2-0
2449 - libjansson4
2450- - libkeyutils1
2451- - libkrb5-3
2452 - libkrb5-26-heimdal
2453- - libkrb5support0
2454- - libk5crypto3
2455 - libldap-2.4-2
2456 - libmm-glib0
2457 - libnewt0.52
2458@@ -230,36 +220,17 @@ parts:
2459 - libroken18-heimdal
2460 - libndp0
2461 - libpsl5
2462- - libreadline7
2463 - librtmp1
2464 - libsasl2-2
2465 - libteamdctl0
2466- - libunistring2
2467- - libblkid1
2468- - libgcrypt20
2469- - libgpg-error0
2470- - liblzma5
2471- - libmount1
2472- - libnl-3-200
2473- - libpcre3
2474- - libselinux1
2475- - libuuid1
2476- - zlib1g
2477- - libgmp10
2478- - libgnutls30
2479- - libhogweed4
2480- - liblz4-1
2481- - libnettle6
2482- - libp11-kit0
2483 - libslang2
2484- - libtasn1-6
2485 - libwind0-heimdal
2486 - ppp
2487 - resolvconf
2488
2489 override-stage: |
2490 snapcraftctl stage
2491- patch -p1 < "$SNAPCRAFT_PART_SRC"/snap-patch/resolvconf.patch
2492+ patch -p1 < "$SNAPCRAFT_PROJECT_DIR"/snap-patch/resolvconf.patch
2493
2494 # Filter files pulled in by stage-packages so they aren't
2495 # included in the final snap. We only need them to build
2496@@ -268,7 +239,6 @@ parts:
2497 # here are the results of the network manager build.
2498 filesets:
2499 binaries:
2500- - sbin/*tables*
2501 - sbin/resolvconf
2502 - usr/bin/arping
2503 - usr/bin/nmcli
2504@@ -285,7 +255,34 @@ parts:
2505 - etc/NetworkManager/*
2506 - etc/resolvconf/update.d/libc
2507 docs:
2508- - usr/share/doc/*/copyright
2509+ - usr/share/doc/dnsmasq/copyright
2510+ - usr/share/doc/iputils-arping/copyright
2511+ - usr/share/doc/libasn1-8-heimdal/copyright
2512+ - usr/share/doc/libcurl3-gnutls/copyright
2513+ - usr/share/doc/libdbus-glib-1-2/copyright
2514+ - usr/share/doc/libgssapi3-heimdal/copyright
2515+ - usr/share/doc/libhcrypto4-heimdal/copyright
2516+ - usr/share/doc/libheimbase1-heimdal/copyright
2517+ - usr/share/doc/libheimntlm0-heimdal/copyright
2518+ - usr/share/doc/libhx509-5-heimdal/copyright
2519+ - usr/share/doc/libjansson4/copyright
2520+ - usr/share/doc/libkrb5-26-heimdal/copyright
2521+ - usr/share/doc/libldap-2.4-2/copyright
2522+ - usr/share/doc/libmm-glib0/copyright
2523+ - usr/share/doc/libndp0/copyright
2524+ - usr/share/doc/libnewt0.52/copyright
2525+ - usr/share/doc/libnghttp2-14/copyright
2526+ - usr/share/doc/libpcap0.8/copyright
2527+ - usr/share/doc/libpsl5/copyright
2528+ - usr/share/doc/libroken18-heimdal/copyright
2529+ - usr/share/doc/librtmp1/copyright
2530+ - usr/share/doc/libsasl2-2/copyright
2531+ - usr/share/doc/libslang2/copyright
2532+ - usr/share/doc/libteamdctl0/copyright
2533+ - usr/share/doc/libwind0-heimdal/copyright
2534+ - usr/share/doc/network-manager/copyright
2535+ - usr/share/doc/ppp/copyright
2536+ - usr/share/doc/resolvconf/copyright
2537 libs:
2538 - lib/resolvconf/list-records
2539 - lib/*/libnewt*
2540@@ -318,8 +315,6 @@ parts:
2541 - usr/lib/*/libsasl2*
2542 - usr/lib/*/libteamdctl*
2543 - usr/lib/*/libwind*
2544- - usr/lib/*/libxtables*
2545- - usr/lib/*/xtables/*
2546 unwanted:
2547 # We don't use dhclient so we don't need this helper
2548 - -usr/lib/NetworkManager/nm-dhcp-helper
2549@@ -335,3 +330,20 @@ parts:
2550 - $docs
2551 - $libs
2552 - $unwanted
2553+
2554+ # This part is to make sure we get notifications from the review tools
2555+ networkmanager-phony:
2556+ plugin: nil
2557+ source: https://git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/stack-snaps-tools
2558+ source-type: git
2559+ build-packages:
2560+ - python3-minimal
2561+ - python3-yaml
2562+ stage-packages:
2563+ - network-manager
2564+ - dnsmasq-base
2565+ # Check versions and make sure nothing from the staged packages is installed
2566+ override-build: |
2567+ ./build-tools/cmp-stage-build.py \
2568+ networkmanager network-manager dnsmasq dnsmasq-base
2569+ rm -rf ../install/*
2570diff --git a/tests/main/can-exec-iptables/task.yaml b/tests/main/can-exec-iptables/task.yaml
2571index eeffe75..c210bbe 100644
2572--- a/tests/main/can-exec-iptables/task.yaml
2573+++ b/tests/main/can-exec-iptables/task.yaml
2574@@ -6,6 +6,5 @@ execute: |
2575 # from the core snap or not.
2576 snap run --shell network-manager.networkmanager <<EOF
2577 set -ex
2578- export LD_LIBRARY_PATH=/snap/network-manager/current/lib:/snap/network-manager/current/usr/lib:/snap/network-manager/current/lib/$(arch)-linux-gnu:/snap/network-manager/current/usr/lib/$(arch)-linux-gnu:/snap/network-manager/current/usr/lib/NetworkManager
2579- /snap/network-manager/current/sbin/iptables -L
2580+ iptables -L
2581 EOF
2582diff --git a/unstage.txt b/unstage.txt
2583new file mode 100644
2584index 0000000..e8997c1
2585--- /dev/null
2586+++ b/unstage.txt
2587@@ -0,0 +1,22 @@
2588+init-system-helpers
2589+libcom-err2
2590+libdbus-1-3
2591+libffi6
2592+libglib2.0-0
2593+libgmp10
2594+libgnutls30
2595+libgssapi-krb5-2
2596+libhogweed4
2597+libidn2-0
2598+libk5crypto3
2599+libkeyutils1
2600+libkrb5-3
2601+libkrb5support0
2602+libldap-common
2603+libnettle6
2604+libp11-kit0
2605+libsasl2-modules-db
2606+libsqlite3-0
2607+libssl1.1
2608+libtasn1-6
2609+libunistring2

Subscribers

People subscribed via source and target branches