Merge ~awe/network-manager/+git/ubuntu:snap-1.10 into network-manager:snap-1.10

Proposed by Tony Espy
Status: Merged
Approved by: Tony Espy
Approved revision: 660001b6f126195ddba7773d8cec5e56c3256aa7
Merge reported by: Tony Espy
Merged at revision: 660001b6f126195ddba7773d8cec5e56c3256aa7
Proposed branch: ~awe/network-manager/+git/ubuntu:snap-1.10
Merge into: network-manager:snap-1.10
Diff against target: 2856 lines (+2737/-1)
19 files modified
debian/10-globally-managed-devices.conf (+1/-1)
debian/changelog (+13/-0)
debian/patches/Support-for-WoWLAN.patch (+892/-0)
debian/patches/add-snap-support.patch (+946/-0)
debian/patches/disable-libnm-glib-test-devices-array.patch (+13/-0)
debian/patches/disable-libnm-glib-wifi-ap-test.patch (+13/-0)
debian/patches/disable-link-bond-test.patch (+14/-0)
debian/patches/disable-link-team-test.patch (+14/-0)
debian/patches/series (+6/-0)
hooks/configure (+62/-0)
snap-common/bin/dhcp-lease-mover (+26/-0)
snap-common/bin/networkmanager (+110/-0)
snap-common/bin/nmcli-internal (+7/-0)
snap-common/bin/snap-config.sh (+159/-0)
snap-common/bin/snap-prop.sh (+60/-0)
snap-common/etc/NetworkManager/NetworkManager.conf (+14/-0)
snap-common/startup-hooks/99-wol-by-default.sh (+13/-0)
snap-common/usr/share/doc/network-manager/copyright (+74/-0)
snap/snapcraft.yaml (+300/-0)
Reviewer Review Type Date Requested Status
Alfonso Sanchez-Beato (community) Approve
Review via email: mp+352119@code.launchpad.net

Commit message

Initial snap packaging for network-manager 1.10

Description of the change

This commit provides the initial snap packaging for network-manager 1.10 for Ubuntu Core, to be published in the public snap store by Canonical. Prior versions of the network-manager snaps were built against upstream version of network-manager, and maintained by an defunct team at Canonical:

https://code.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager

This new version of the snap is built on top of the bionic version of network-manager using quilt patches, including most (if not all) of the patches released to-date for bionic. As nm 1.10 has some dependencies that are only available from 18.04, this snap is built against the core18 base snap. This snap also includes a pending PR for WoWLAN.

To post a comment you must log in.
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

@Tony why have you removed the configure file? is it creating a conflict with snapcraft? It makes impossible to review the MP easily...

Revision history for this message
Tony Espy (awe) wrote :

Yes, I realized afterwards that the easy diff gets clobbered by the removal of configure [1]. That said, this was done in our snappy-hwe-team snap packaging as well [2].

[1] https://git.launchpad.net/~awe/network-manager/+git/ubuntu/commit/?h=snap-1.10&id=939728d06d32aabb70db2cb6595f4da2d88a2f7d

[2] https://git.launchpad.net/~snappy-hwe-team/snappy-hwe-snaps/+git/network-manager/commit/?h=network-manager/xenial/1.2.2&id=6250399de3380dce6d0db15ce0825c18438fd60d

If there's another way to do this, I'm all ears...

Revision history for this message
Tony Espy (awe) wrote :

I just updated the PR to get rid of the configure removal commit. Instead, I updated the networkmanager part to remove the configure file in the override-build section.

Revision history for this message
Tony Espy (awe) wrote :

I'd also like to discuss removing the 'ethernet.enable' config option, as I think we'd proven that mixing and matching networkd and NetworkManager isn't a good idea.

Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

Great work! I have some comments, but no mayor issues though.

review: Needs Fixing
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

Approving as this has already been released - fixes for the comments will come in another MP.

review: Approve
Revision history for this message
Tony Espy (awe) wrote :

There was indeed a missing patch, so we'll need to get working on some kind of interim plan for CI for this branch.

I amended the 'add snap support' commit, and force-pushed it.

I'll address the remaining comments in separate PRs.

Revision history for this message
Tony Espy (awe) wrote :

Merged and tagged as "snap/1.10.6-20180813_286".

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/10-globally-managed-devices.conf b/debian/10-globally-managed-devices.conf
2index 350d3d8..01728f1 100644
3--- a/debian/10-globally-managed-devices.conf
4+++ b/debian/10-globally-managed-devices.conf
5@@ -1,2 +1,2 @@
6 [keyfile]
7-unmanaged-devices=*,except:type:wifi,except:type:wwan
8+unmanaged-devices=*,except:type:wifi,except:type:gsm,except:type:cdma
9diff --git a/debian/changelog b/debian/changelog
10index e118d0a..5fd3f5e 100644
11--- a/debian/changelog
12+++ b/debian/changelog
13@@ -1,3 +1,16 @@
14+network-manager (1.10.6-2ubuntu1.2) UNRELEASED; urgency=medium
15+
16+ [ Mathieu Trudel-Lapierre ]
17+ * debian/10-globally-managed-devices.conf: adjust exception for wwan to
18+ specify cdma and gsm, since those are the actual types handled by NM/MM.
19+ (LP: #1780606)
20+
21+ [ Alfonso Sanchez-Beato (email Canonical) ]
22+ * debian/patches/Support-for-WoWLAN.patch: backport WoWLAN support from NM
23+ upstream 1.12 (LP: #1781597)
24+
25+ -- Alfonso Sanchez-Beato (email Canonical) <alfonso.sanchez-beato@canonical.com> Fri, 13 Jul 2018 13:21:15 +0200
26+
27 network-manager (1.10.6-2ubuntu1) bionic; urgency=medium
28
29 * Merge with Debian (LP: #1758331). Remaining changes:
30diff --git a/debian/patches/Support-for-WoWLAN.patch b/debian/patches/Support-for-WoWLAN.patch
31new file mode 100644
32index 0000000..094f6c8
33--- /dev/null
34+++ b/debian/patches/Support-for-WoWLAN.patch
35@@ -0,0 +1,892 @@
36+From: =?utf-8?q?Alfonso_S=C3=A1nchez-Beato?=
37+ <alfonso.sanchez-beato@canonical.com>
38+Date: Fri, 13 Jul 2018 11:54:30 +0200
39+Subject: Support for WoWLAN
40+
41+This add supports for WoWLAN by backporting upstream patches:
42+
43+58cdc7b55 libnm-core: add wake-on-wlan configuration items
44+1621c79e7 platform: add support for wake-on-wlan
45+ea10016d2 devices: enable wake-on-wlan when device is enabled
46+ca3bbede7 core: don't shutdown interfaces if they have wowlan enabled
47+cb8003c40 cli: add support for wake-on-wlan properties
48+8cba4d95d device/wifi: use _LOGD() macros in wake_on_wlan_enable()
49+36e9ec055 wifi: fix check for valid NMSettingWirelessWakeOnWLan flag
50+ac1302793 platform: add methods to retrieve current WoWLAN state
51+c6e40215e devices: restore past WoWLAN when disconnecting wifi
52+a3289400d wifi: ensure wake-on-wlan restore only acts once
53+2c3a14fed platform/wifi: drop *_get_wowlan()
54+---
55+ clients/common/nm-meta-setting-desc.c | 14 ++++
56+ clients/common/settings-docs.c | 1 +
57+ clients/common/settings-docs.c.in | 1 +
58+ libnm-core/nm-setting-wireless.c | 72 +++++++++++++++++
59+ libnm-core/nm-setting-wireless.h | 46 +++++++++++
60+ libnm/libnm.ver | 2 +
61+ src/devices/wifi/nm-device-wifi.c | 102 +++++++++++++++++++++++-
62+ src/nm-manager.c | 27 ++++---
63+ src/platform/nm-linux-platform.c | 19 ++++-
64+ src/platform/nm-platform.c | 20 +++++
65+ src/platform/nm-platform.h | 5 ++
66+ src/platform/wifi/wifi-utils-nl80211.c | 139 ++++++++++++++++++++++++---------
67+ src/platform/wifi/wifi-utils-private.h | 8 +-
68+ src/platform/wifi/wifi-utils.c | 28 ++++---
69+ src/platform/wifi/wifi-utils.h | 7 +-
70+ 15 files changed, 425 insertions(+), 66 deletions(-)
71+
72+diff --git a/clients/common/nm-meta-setting-desc.c b/clients/common/nm-meta-setting-desc.c
73+index 94404e9..21763a8 100644
74+--- a/clients/common/nm-meta-setting-desc.c
75++++ b/clients/common/nm-meta-setting-desc.c
76+@@ -7271,6 +7271,20 @@ static const NMMetaPropertyInfo *const property_infos_WIRELESS[] = {
77+ .typ_flags = NM_META_PROPERTY_TYP_FLAG_ENUM_GET_PARSABLE_TEXT,
78+ ),
79+ ),
80++ PROPERTY_INFO_WITH_DESC (NM_SETTING_WIRELESS_WAKE_ON_WLAN,
81++ .property_type = &_pt_gobject_enum,
82++ .property_typ_data = DEFINE_PROPERTY_TYP_DATA (
83++ PROPERTY_TYP_DATA_SUBTYPE (gobject_enum,
84++ .get_gtype = nm_setting_wireless_wake_on_wlan_get_type,
85++ .value_infos = ENUM_VALUE_INFOS (
86++ {
87++ .value = NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE,
88++ .nick = "disabled",
89++ }
90++ ),
91++ ),
92++ ),
93++ ),
94+ NULL
95+ };
96+
97+diff --git a/clients/common/settings-docs.c b/clients/common/settings-docs.c
98+index bf5753c..911164a 100644
99+--- a/clients/common/settings-docs.c
100++++ b/clients/common/settings-docs.c
101+@@ -21,6 +21,7 @@
102+ #define DESCRIBE_DOC_NM_SETTING_WIRELESS_SEEN_BSSIDS N_("A list of BSSIDs (each BSSID formatted as a MAC address like \"00:11:22:33:44:55\") that have been detected as part of the Wi-Fi network. NetworkManager internally tracks previously seen BSSIDs. The property is only meant for reading and reflects the BSSID list of NetworkManager. The changes you make to this property will not be preserved.")
103+ #define DESCRIBE_DOC_NM_SETTING_WIRELESS_SSID N_("SSID of the Wi-Fi network. Must be specified.")
104+ #define DESCRIBE_DOC_NM_SETTING_WIRELESS_TX_POWER N_("If non-zero, directs the device to use the specified transmit power. Units are dBm. This property is highly driver dependent and not all devices support setting a static transmit power.")
105++#define DESCRIBE_DOC_NM_SETTING_WIRELESS_WAKE_ON_WLAN N_("The NMSettingWirelessWakeOnWLan options to enable. Not all devices support all options. May be any combination of NM_SETTING_WIRELESS_WAKE_ON_WLAN_ANY (0x2), NM_SETTING_WIRELESS_WAKE_ON_WLAN_DISCONNECT (0x4), NM_SETTING_WIRELESS_WAKE_ON_WLAN_MAGIC (0x8), NM_SETTING_WIRELESS_WAKE_ON_WLAN_GTK_REKEY_FAILURE (0x10), NM_SETTING_WIRELESS_WAKE_ON_WLAN_EAP_IDENTITY_REQUEST (0x20), NM_SETTING_WIRELESS_WAKE_ON_WLAN_4WAY_HANDSHAKE (0x40), NM_SETTING_WIRELESS_WAKE_ON_WLAN_RFKILL_RELEASE (0x80), NM_SETTING_WIRELESS_WAKE_ON_WLAN_TCP (0x100) or the special values NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT (0x1) (to use global settings) and NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE (0x8000) (to disable management of Wake-on-LAN in NetworkManager).")
106+ #define DESCRIBE_DOC_NM_SETTING_WIRELESS_SECURITY_AUTH_ALG N_("When WEP is used (ie, key-mgmt = \"none\" or \"ieee8021x\") indicate the 802.11 authentication algorithm required by the AP here. One of \"open\" for Open System, \"shared\" for Shared Key, or \"leap\" for Cisco LEAP. When using Cisco LEAP (ie, key-mgmt = \"ieee8021x\" and auth-alg = \"leap\") the \"leap-username\" and \"leap-password\" properties must be specified.")
107+ #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\".")
108+ #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.")
109+diff --git a/clients/common/settings-docs.c.in b/clients/common/settings-docs.c.in
110+index bf5753c..911164a 100644
111+--- a/clients/common/settings-docs.c.in
112++++ b/clients/common/settings-docs.c.in
113+@@ -21,6 +21,7 @@
114+ #define DESCRIBE_DOC_NM_SETTING_WIRELESS_SEEN_BSSIDS N_("A list of BSSIDs (each BSSID formatted as a MAC address like \"00:11:22:33:44:55\") that have been detected as part of the Wi-Fi network. NetworkManager internally tracks previously seen BSSIDs. The property is only meant for reading and reflects the BSSID list of NetworkManager. The changes you make to this property will not be preserved.")
115+ #define DESCRIBE_DOC_NM_SETTING_WIRELESS_SSID N_("SSID of the Wi-Fi network. Must be specified.")
116+ #define DESCRIBE_DOC_NM_SETTING_WIRELESS_TX_POWER N_("If non-zero, directs the device to use the specified transmit power. Units are dBm. This property is highly driver dependent and not all devices support setting a static transmit power.")
117++#define DESCRIBE_DOC_NM_SETTING_WIRELESS_WAKE_ON_WLAN N_("The NMSettingWirelessWakeOnWLan options to enable. Not all devices support all options. May be any combination of NM_SETTING_WIRELESS_WAKE_ON_WLAN_ANY (0x2), NM_SETTING_WIRELESS_WAKE_ON_WLAN_DISCONNECT (0x4), NM_SETTING_WIRELESS_WAKE_ON_WLAN_MAGIC (0x8), NM_SETTING_WIRELESS_WAKE_ON_WLAN_GTK_REKEY_FAILURE (0x10), NM_SETTING_WIRELESS_WAKE_ON_WLAN_EAP_IDENTITY_REQUEST (0x20), NM_SETTING_WIRELESS_WAKE_ON_WLAN_4WAY_HANDSHAKE (0x40), NM_SETTING_WIRELESS_WAKE_ON_WLAN_RFKILL_RELEASE (0x80), NM_SETTING_WIRELESS_WAKE_ON_WLAN_TCP (0x100) or the special values NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT (0x1) (to use global settings) and NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE (0x8000) (to disable management of Wake-on-LAN in NetworkManager).")
118+ #define DESCRIBE_DOC_NM_SETTING_WIRELESS_SECURITY_AUTH_ALG N_("When WEP is used (ie, key-mgmt = \"none\" or \"ieee8021x\") indicate the 802.11 authentication algorithm required by the AP here. One of \"open\" for Open System, \"shared\" for Shared Key, or \"leap\" for Cisco LEAP. When using Cisco LEAP (ie, key-mgmt = \"ieee8021x\" and auth-alg = \"leap\") the \"leap-username\" and \"leap-password\" properties must be specified.")
119+ #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\".")
120+ #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.")
121+diff --git a/libnm-core/nm-setting-wireless.c b/libnm-core/nm-setting-wireless.c
122+index 0a3915b..7500c97 100644
123+--- a/libnm-core/nm-setting-wireless.c
124++++ b/libnm-core/nm-setting-wireless.c
125+@@ -63,6 +63,7 @@ typedef struct {
126+ gboolean hidden;
127+ guint32 powersave;
128+ NMSettingMacRandomization mac_address_randomization;
129++ guint32 wowl;
130+ } NMSettingWirelessPrivate;
131+
132+ enum {
133+@@ -83,6 +84,7 @@ enum {
134+ PROP_HIDDEN,
135+ PROP_POWERSAVE,
136+ PROP_MAC_ADDRESS_RANDOMIZATION,
137++ PROP_WAKE_ON_WLAN,
138+
139+ LAST_PROP
140+ };
141+@@ -885,6 +887,26 @@ verify (NMSetting *setting, NMConnection *connection, GError **error)
142+ return FALSE;
143+ }
144+
145++ if (NM_FLAGS_ANY (priv->wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_EXCLUSIVE_FLAGS)) {
146++ if (!nm_utils_is_power_of_two (priv->wowl)) {
147++ g_set_error_literal (error,
148++ NM_CONNECTION_ERROR,
149++ NM_CONNECTION_ERROR_INVALID_PROPERTY,
150++ _("Wake-on-WLAN mode 'default' and 'ignore' are exclusive flags"));
151++ g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME,
152++ NM_SETTING_WIRELESS_WAKE_ON_WLAN);
153++ return FALSE;
154++ }
155++ } else if (NM_FLAGS_ANY (priv->wowl, ~NM_SETTING_WIRELESS_WAKE_ON_WLAN_ALL)) {
156++ g_set_error_literal (error,
157++ NM_CONNECTION_ERROR,
158++ NM_CONNECTION_ERROR_INVALID_PROPERTY,
159++ _("Wake-on-WLAN trying to set unknown flag"));
160++ g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRELESS_SETTING_NAME,
161++ NM_SETTING_WIRELESS_WAKE_ON_WLAN);
162++ return FALSE;
163++ }
164++
165+ /* from here on, check for NM_SETTING_VERIFY_NORMALIZABLE conditions. */
166+
167+ if (priv->cloned_mac_address) {
168+@@ -939,6 +961,24 @@ nm_setting_wireless_get_security (NMSetting *setting,
169+ return NULL;
170+ }
171+
172++/**
173++ * nm_setting_wireless_get_wake_on_wlan:
174++ * @setting: the #NMSettingWireless
175++ *
176++ * Returns the Wake-on-WLAN options enabled for the connection
177++ *
178++ * Returns: the Wake-on-WLAN options
179++ *
180++ * Since: 1.12
181++ */
182++NMSettingWirelessWakeOnWLan
183++nm_setting_wireless_get_wake_on_wlan (NMSettingWireless *setting)
184++{
185++ g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE);
186++
187++ return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->wowl;
188++}
189++
190+ static void
191+ clear_blacklist_item (char **item_p)
192+ {
193+@@ -1061,6 +1101,9 @@ set_property (GObject *object, guint prop_id,
194+ case PROP_MAC_ADDRESS_RANDOMIZATION:
195+ priv->mac_address_randomization = g_value_get_uint (value);
196+ break;
197++ case PROP_WAKE_ON_WLAN:
198++ priv->wowl = g_value_get_uint (value);
199++ break;
200+ default:
201+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
202+ break;
203+@@ -1123,6 +1166,9 @@ get_property (GObject *object, guint prop_id,
204+ case PROP_MAC_ADDRESS_RANDOMIZATION:
205+ g_value_set_uint (value, nm_setting_wireless_get_mac_address_randomization (setting));
206+ break;
207++ case PROP_WAKE_ON_WLAN:
208++ g_value_set_uint (value, nm_setting_wireless_get_wake_on_wlan (setting));
209++ break;
210+ default:
211+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
212+ break;
213+@@ -1633,4 +1679,30 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_wireless_class)
214+ _nm_setting_class_add_dbus_only_property (setting_class, "security",
215+ G_VARIANT_TYPE_STRING,
216+ nm_setting_wireless_get_security, NULL);
217++
218++ /**
219++ * NMSettingWireless:wake-on-wlan:
220++ *
221++ * The #NMSettingWirelessWakeOnWLan options to enable. Not all devices support all options.
222++ * May be any combination of %NM_SETTING_WIRELESS_WAKE_ON_WLAN_ANY,
223++ * %NM_SETTING_WIRELESS_WAKE_ON_WLAN_DISCONNECT,
224++ * %NM_SETTING_WIRELESS_WAKE_ON_WLAN_MAGIC,
225++ * %NM_SETTING_WIRELESS_WAKE_ON_WLAN_GTK_REKEY_FAILURE,
226++ * %NM_SETTING_WIRELESS_WAKE_ON_WLAN_EAP_IDENTITY_REQUEST,
227++ * %NM_SETTING_WIRELESS_WAKE_ON_WLAN_4WAY_HANDSHAKE,
228++ * %NM_SETTING_WIRELESS_WAKE_ON_WLAN_RFKILL_RELEASE,
229++ * %NM_SETTING_WIRELESS_WAKE_ON_WLAN_TCP or the special values
230++ * %NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT (to use global settings) and
231++ * %NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE (to disable management of Wake-on-LAN in
232++ * NetworkManager).
233++ *
234++ * Since: 1.12
235++ **/
236++ g_object_class_install_property
237++ (object_class, PROP_WAKE_ON_WLAN,
238++ g_param_spec_uint (NM_SETTING_WIRELESS_WAKE_ON_WLAN, "", "",
239++ 0, G_MAXUINT32, NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT,
240++ G_PARAM_CONSTRUCT |
241++ G_PARAM_READWRITE |
242++ G_PARAM_STATIC_STRINGS));
243+ }
244+diff --git a/libnm-core/nm-setting-wireless.h b/libnm-core/nm-setting-wireless.h
245+index b0ef475..4c1850f 100644
246+--- a/libnm-core/nm-setting-wireless.h
247++++ b/libnm-core/nm-setting-wireless.h
248+@@ -41,6 +41,48 @@ G_BEGIN_DECLS
249+
250+ #define NM_SETTING_WIRELESS_SETTING_NAME "802-11-wireless"
251+
252++/**
253++ * NMSettingWirelessWakeOnWLan:
254++ * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE: Wake-on-WLAN disabled
255++ * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_ANY: Wake on any activity
256++ * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_DISCONNECT: Wake on disconnect
257++ * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_MAGIC: Wake on magic packet
258++ * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_GTK_REKEY_FAILURE: Wake on GTK rekey failure
259++ * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_EAP_IDENTITY_REQUEST: Wake on EAP identity request
260++ * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_4WAY_HANDSHAKE: Wake on 4way hanshake
261++ * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_RFKILL_RELEASE: Wake on rfkill release
262++ * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_ALL: Wake on all events. This does not
263++ * include the exclusive flags @NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT or
264++ * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE.
265++ * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT: Use the default value
266++ * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE: Don't change configured settings
267++ * @NM_SETTING_WIRELESS_WAKE_ON_WLAN_EXCLUSIVE_FLAGS: Mask of flags that are
268++ * incompatible with other flags
269++ *
270++ * Options for #NMSettingWireless:wake-on-wlan. Note that not all options
271++ * are supported by all devices.
272++ *
273++ * Since: 1.12
274++ */
275++typedef enum { /*< flags >*/
276++ NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE = 0, /*< skip >*/
277++ NM_SETTING_WIRELESS_WAKE_ON_WLAN_ANY = (1 << 1),
278++ NM_SETTING_WIRELESS_WAKE_ON_WLAN_DISCONNECT = (1 << 2),
279++ NM_SETTING_WIRELESS_WAKE_ON_WLAN_MAGIC = (1 << 3),
280++ NM_SETTING_WIRELESS_WAKE_ON_WLAN_GTK_REKEY_FAILURE = (1 << 4),
281++ NM_SETTING_WIRELESS_WAKE_ON_WLAN_EAP_IDENTITY_REQUEST = (1 << 5),
282++ NM_SETTING_WIRELESS_WAKE_ON_WLAN_4WAY_HANDSHAKE = (1 << 6),
283++ NM_SETTING_WIRELESS_WAKE_ON_WLAN_RFKILL_RELEASE = (1 << 7),
284++ NM_SETTING_WIRELESS_WAKE_ON_WLAN_TCP = (1 << 8),
285++ _NM_SETTING_WIRELESS_WAKE_ON_WLAN_NUM, /*< skip >*/
286++ NM_SETTING_WIRELESS_WAKE_ON_WLAN_LAST = _NM_SETTING_WIRELESS_WAKE_ON_WLAN_NUM - 1, /*< skip >*/
287++ NM_SETTING_WIRELESS_WAKE_ON_WLAN_ALL = ((NM_SETTING_WIRELESS_WAKE_ON_WLAN_LAST << 1) - 1) - (1 << 0 /*DEFAULT*/), /*< skip >*/
288++
289++ NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT = (1 << 0),
290++ NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE = (1 << 15),
291++ NM_SETTING_WIRELESS_WAKE_ON_WLAN_EXCLUSIVE_FLAGS = NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT | NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE, /*< skip >*/
292++} NMSettingWirelessWakeOnWLan;
293++
294+ #define NM_SETTING_WIRELESS_SSID "ssid"
295+ #define NM_SETTING_WIRELESS_MODE "mode"
296+ #define NM_SETTING_WIRELESS_BAND "band"
297+@@ -57,6 +99,7 @@ G_BEGIN_DECLS
298+ #define NM_SETTING_WIRELESS_HIDDEN "hidden"
299+ #define NM_SETTING_WIRELESS_POWERSAVE "powersave"
300+ #define NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION "mac-address-randomization"
301++#define NM_SETTING_WIRELESS_WAKE_ON_WLAN "wake-on-wlan"
302+
303+ /**
304+ * NM_SETTING_WIRELESS_MODE_ADHOC:
305+@@ -166,6 +209,9 @@ gboolean nm_setting_wireless_ap_security_compatible (NMSettingWireless
306+ NM80211ApSecurityFlags ap_rsn,
307+ NM80211Mode ap_mode);
308+
309++NM_AVAILABLE_IN_1_10
310++NMSettingWirelessWakeOnWLan nm_setting_wireless_get_wake_on_wlan (NMSettingWireless *setting);
311++
312+ G_END_DECLS
313+
314+ #endif /* __NM_SETTING_WIRELESS_H__ */
315+diff --git a/libnm/libnm.ver b/libnm/libnm.ver
316+index 7646a93..3376848 100644
317+--- a/libnm/libnm.ver
318++++ b/libnm/libnm.ver
319+@@ -1276,6 +1276,8 @@ global:
320+ nm_setting_team_remove_link_watcher_by_value;
321+ nm_setting_team_remove_runner_tx_hash;
322+ nm_setting_team_remove_runner_tx_hash_by_value;
323++ nm_setting_wireless_get_wake_on_wlan;
324++ nm_setting_wireless_wake_on_wlan_get_type;
325+ nm_tc_action_dup;
326+ nm_tc_action_equal;
327+ nm_tc_action_get_attribute;
328+diff --git a/src/devices/wifi/nm-device-wifi.c b/src/devices/wifi/nm-device-wifi.c
329+index bf02109..e06aa32 100644
330+--- a/src/devices/wifi/nm-device-wifi.c
331++++ b/src/devices/wifi/nm-device-wifi.c
332+@@ -119,6 +119,8 @@ typedef struct {
333+ gint32 hw_addr_scan_expire;
334+
335+ guint wps_timeout_id;
336++
337++ NMSettingWirelessWakeOnWLan wowlan_restore;
338+ } NMDeviceWifiPrivate;
339+
340+ struct _NMDeviceWifi
341+@@ -535,6 +537,22 @@ again:
342+ nm_device_recheck_available_connections (NM_DEVICE (self));
343+ }
344+
345++static gboolean
346++wake_on_wlan_restore (NMDeviceWifi *self)
347++{
348++ NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
349++ NMSettingWirelessWakeOnWLan w;
350++
351++ w = priv->wowlan_restore;
352++ if (w == NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE)
353++ return TRUE;
354++
355++ priv->wowlan_restore = NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE;
356++ return nm_platform_wifi_set_wake_on_wlan (NM_PLATFORM_GET,
357++ nm_device_get_ifindex (NM_DEVICE (self)),
358++ w);
359++}
360++
361+ static void
362+ deactivate (NMDevice *device)
363+ {
364+@@ -551,6 +569,9 @@ deactivate (NMDevice *device)
365+
366+ set_current_ap (self, NULL, TRUE);
367+
368++ if (!wake_on_wlan_restore (self))
369++ _LOGW (LOGD_DEVICE | LOGD_WIFI, "Cannot unconfigure WoWLAN.");
370++
371+ /* Clear any critical protocol notification in the Wi-Fi stack */
372+ nm_platform_wifi_indicate_addressing_running (nm_device_get_platform (device), ifindex, FALSE);
373+
374+@@ -2593,6 +2614,60 @@ error:
375+
376+ /*****************************************************************************/
377+
378++static gboolean
379++wake_on_wlan_enable (NMDeviceWifi *self)
380++{
381++ NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
382++ NMSettingWirelessWakeOnWLan wowl;
383++ NMSettingWireless *s_wireless;
384++ gs_free char *value = NULL;
385++
386++ s_wireless = (NMSettingWireless *) nm_device_get_applied_setting (NM_DEVICE (self), NM_TYPE_SETTING_WIRELESS);
387++ if (s_wireless) {
388++ wowl = nm_setting_wireless_get_wake_on_wlan (s_wireless);
389++ if (wowl != NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT)
390++ goto found;
391++ }
392++
393++ value = nm_config_data_get_connection_default (NM_CONFIG_GET_DATA,
394++ "wifi.wake-on-wlan",
395++ NM_DEVICE (self));
396++
397++ if (value) {
398++ wowl = _nm_utils_ascii_str_to_int64 (value, 10,
399++ NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE,
400++ G_MAXINT32,
401++ NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT);
402++
403++ if (NM_FLAGS_ANY (wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_EXCLUSIVE_FLAGS)) {
404++ if (!nm_utils_is_power_of_two (wowl)) {
405++ _LOGD (LOGD_WIFI, "invalid default value %u for wake-on-wlan: "
406++ "'default' and 'ignore' are exclusive flags", (guint) wowl);
407++ wowl = NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT;
408++ }
409++ } else if (NM_FLAGS_ANY (wowl, ~NM_SETTING_WIRELESS_WAKE_ON_WLAN_ALL)) {
410++ _LOGD (LOGD_WIFI, "invalid default value %u for wake-on-wlan", (guint) wowl);
411++ wowl = NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT;
412++ }
413++ if (wowl != NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT)
414++ goto found;
415++ }
416++ wowl = NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE;
417++
418++found:
419++ if (wowl == NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE) {
420++ priv->wowlan_restore = wowl;
421++ return TRUE;
422++ }
423++
424++ priv->wowlan_restore = nm_platform_wifi_get_wake_on_wlan (NM_PLATFORM_GET,
425++ nm_device_get_ifindex (NM_DEVICE (self)));
426++
427++ return nm_platform_wifi_set_wake_on_wlan (NM_PLATFORM_GET,
428++ nm_device_get_ifindex (NM_DEVICE (self)),
429++ wowl);
430++}
431++
432+ static NMActStageReturn
433+ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *out_failure_reason)
434+ {
435+@@ -2802,6 +2877,9 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
436+ goto out;
437+ }
438+
439++ if (!wake_on_wlan_enable (self))
440++ _LOGW (LOGD_DEVICE | LOGD_WIFI, "Cannot configure WoWLAN.");
441++
442+ /* have secrets, or no secrets required */
443+ if (nm_connection_get_setting_wireless_security (connection)) {
444+ _LOGI (LOGD_DEVICE | LOGD_WIFI,
445+@@ -2852,8 +2930,10 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *out_failure_reason)
446+ ret = NM_ACT_STAGE_RETURN_POSTPONE;
447+
448+ out:
449+- if (ret == NM_ACT_STAGE_RETURN_FAILURE)
450++ if (ret == NM_ACT_STAGE_RETURN_FAILURE) {
451+ cleanup_association_attempt (self, TRUE);
452++ wake_on_wlan_restore (self);
453++ }
454+
455+ if (config) {
456+ /* Supplicant interface object refs the config; we no longer care about
457+@@ -3257,7 +3337,8 @@ can_reapply_change (NMDevice *device,
458+ return nm_device_hash_check_invalid_keys (diffs,
459+ NM_SETTING_WIRELESS_SETTING_NAME,
460+ error,
461+- NM_SETTING_WIRELESS_MTU); /* reapplied with IP config */
462++ NM_SETTING_WIRELESS_MTU, /* reapplied with IP config */
463++ NM_SETTING_WIRELESS_WAKE_ON_WLAN);
464+ }
465+
466+ device_class = NM_DEVICE_CLASS (nm_device_wifi_parent_class);
467+@@ -3269,6 +3350,21 @@ can_reapply_change (NMDevice *device,
468+ error);
469+ }
470+
471++static void
472++reapply_connection (NMDevice *device, NMConnection *con_old, NMConnection *con_new)
473++{
474++ NMDeviceWifi *self = NM_DEVICE_WIFI (device);
475++
476++ NM_DEVICE_CLASS (nm_device_wifi_parent_class)->reapply_connection (device,
477++ con_old,
478++ con_new);
479++
480++ _LOGD (LOGD_DEVICE, "reapplying wireless settings");
481++
482++ if (!wake_on_wlan_enable (self))
483++ _LOGW (LOGD_DEVICE | LOGD_WIFI, "Cannot configure WoWLAN.");
484++}
485++
486+ /*****************************************************************************/
487+
488+ static void
489+@@ -3335,6 +3431,7 @@ nm_device_wifi_init (NMDeviceWifi *self)
490+
491+ priv->mode = NM_802_11_MODE_INFRA;
492+ priv->aps = g_hash_table_new (nm_str_hash, g_str_equal);
493++ priv->wowlan_restore = NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE;
494+ }
495+
496+ static void
497+@@ -3433,6 +3530,7 @@ nm_device_wifi_class_init (NMDeviceWifiClass *klass)
498+ parent_class->deactivate_reset_hw_addr = deactivate_reset_hw_addr;
499+ parent_class->unmanaged_on_quit = unmanaged_on_quit;
500+ parent_class->can_reapply_change = can_reapply_change;
501++ parent_class->reapply_connection = reapply_connection;
502+
503+ parent_class->state_changed = device_state_changed;
504+
505+diff --git a/src/nm-manager.c b/src/nm-manager.c
506+index e60b6c6..fc8a97e 100644
507+--- a/src/nm-manager.c
508++++ b/src/nm-manager.c
509+@@ -1315,6 +1315,12 @@ _parent_notify_changed (NMManager *self,
510+ }
511+ }
512+
513++static gboolean
514++device_is_wake_on_lan (NMPlatform *platform, NMDevice *device)
515++{
516++ return nm_platform_link_get_wake_on_lan (platform, nm_device_get_ip_ifindex (device));
517++}
518++
519+ static void
520+ remove_device (NMManager *self,
521+ NMDevice *device,
522+@@ -1324,14 +1330,19 @@ remove_device (NMManager *self,
523+ NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
524+ gboolean unmanage = FALSE;
525+
526+- _LOG2D (LOGD_DEVICE, device, "removing device (allow_unmanage %d, managed %d)",
527+- allow_unmanage, nm_device_get_managed (device, FALSE));
528++ _LOG2D (LOGD_DEVICE, device, "removing device (allow_unmanage %d, managed %d, wol %d)",
529++ allow_unmanage, nm_device_get_managed (device, FALSE),
530++ device_is_wake_on_lan (priv->platform, device));
531+
532+ if (allow_unmanage && nm_device_get_managed (device, FALSE)) {
533+
534+- if (quitting)
535+- unmanage = nm_device_unmanage_on_quit (device);
536+- else {
537++ if (quitting) {
538++ /* Leave configured if wo(w)lan and quitting */
539++ if (device_is_wake_on_lan (priv->platform, device))
540++ unmanage = FALSE;
541++ else
542++ unmanage = nm_device_unmanage_on_quit (device);
543++ } else {
544+ /* the device is already gone. Unmanage it. */
545+ unmanage = TRUE;
546+ }
547+@@ -4763,12 +4774,6 @@ done:
548+ g_clear_object (&subject);
549+ }
550+
551+-static gboolean
552+-device_is_wake_on_lan (NMPlatform *platform, NMDevice *device)
553+-{
554+- return nm_platform_link_get_wake_on_lan (platform, nm_device_get_ip_ifindex (device));
555+-}
556+-
557+ static gboolean
558+ sleep_devices_add (NMManager *self, NMDevice *device, gboolean suspending)
559+ {
560+diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c
561+index e5961c7..a061fc3 100644
562+--- a/src/platform/nm-linux-platform.c
563++++ b/src/platform/nm-linux-platform.c
564+@@ -6119,6 +6119,21 @@ wifi_indicate_addressing_running (NMPlatform *platform, int ifindex, gboolean ru
565+ wifi_utils_indicate_addressing_running (wifi_data, running);
566+ }
567+
568++static NMSettingWirelessWakeOnWLan
569++wifi_get_wake_on_wlan (NMPlatform *platform, int ifindex)
570++{
571++ WIFI_GET_WIFI_DATA_NETNS (wifi_data, platform, ifindex, FALSE);
572++ return wifi_utils_get_wake_on_wlan (wifi_data);
573++}
574++
575++static gboolean
576++wifi_set_wake_on_wlan (NMPlatform *platform, int ifindex,
577++ NMSettingWirelessWakeOnWLan wowl)
578++{
579++ WIFI_GET_WIFI_DATA_NETNS (wifi_data, platform, ifindex, FALSE);
580++ return wifi_utils_set_wake_on_wlan (wifi_data, wowl);
581++}
582++
583+ /*****************************************************************************/
584+
585+ static gboolean
586+@@ -6203,7 +6218,7 @@ link_get_wake_on_lan (NMPlatform *platform, int ifindex)
587+ if (!wifi_data)
588+ return FALSE;
589+
590+- return wifi_utils_get_wowlan (wifi_data);
591++ return wifi_utils_get_wake_on_wlan (wifi_data) != NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE;
592+ } else
593+ return FALSE;
594+ }
595+@@ -7279,6 +7294,8 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass)
596+ platform_class->wifi_set_powersave = wifi_set_powersave;
597+ platform_class->wifi_find_frequency = wifi_find_frequency;
598+ platform_class->wifi_indicate_addressing_running = wifi_indicate_addressing_running;
599++ platform_class->wifi_get_wake_on_wlan = wifi_get_wake_on_wlan;
600++ platform_class->wifi_set_wake_on_wlan = wifi_set_wake_on_wlan;
601+
602+ platform_class->mesh_get_channel = mesh_get_channel;
603+ platform_class->mesh_set_channel = mesh_set_channel;
604+diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c
605+index c7ed90e..7387a1d 100644
606+--- a/src/platform/nm-platform.c
607++++ b/src/platform/nm-platform.c
608+@@ -2767,6 +2767,26 @@ nm_platform_wifi_indicate_addressing_running (NMPlatform *self, int ifindex, gbo
609+ klass->wifi_indicate_addressing_running (self, ifindex, running);
610+ }
611+
612++NMSettingWirelessWakeOnWLan
613++nm_platform_wifi_get_wake_on_wlan (NMPlatform *self, int ifindex)
614++{
615++ _CHECK_SELF (self, klass, FALSE);
616++
617++ g_return_val_if_fail (ifindex > 0, FALSE);
618++
619++ return klass->wifi_get_wake_on_wlan (self, ifindex);
620++}
621++
622++gboolean
623++nm_platform_wifi_set_wake_on_wlan (NMPlatform *self, int ifindex, NMSettingWirelessWakeOnWLan wowl)
624++{
625++ _CHECK_SELF (self, klass, FALSE);
626++
627++ g_return_val_if_fail (ifindex > 0, FALSE);
628++
629++ return klass->wifi_set_wake_on_wlan (self, ifindex, wowl);
630++}
631++
632+ guint32
633+ nm_platform_mesh_get_channel (NMPlatform *self, int ifindex)
634+ {
635+diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h
636+index f6bf02b..0c167ee 100644
637+--- a/src/platform/nm-platform.h
638++++ b/src/platform/nm-platform.h
639+@@ -32,6 +32,7 @@
640+ #include "nm-core-utils.h"
641+ #include "nm-setting-vlan.h"
642+ #include "nm-setting-wired.h"
643++#include "nm-setting-wireless.h"
644+
645+ #define NM_TYPE_PLATFORM (nm_platform_get_type ())
646+ #define NM_PLATFORM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_PLATFORM, NMPlatform))
647+@@ -826,6 +827,8 @@ typedef struct {
648+ void (*wifi_set_powersave) (NMPlatform *, int ifindex, guint32 powersave);
649+ guint32 (*wifi_find_frequency) (NMPlatform *, int ifindex, const guint32 *freqs);
650+ void (*wifi_indicate_addressing_running) (NMPlatform *, int ifindex, gboolean running);
651++ NMSettingWirelessWakeOnWLan (*wifi_get_wake_on_wlan) (NMPlatform *, int ifindex);
652++ gboolean (*wifi_set_wake_on_wlan) (NMPlatform *, int ifindex, NMSettingWirelessWakeOnWLan wowl);
653+
654+ guint32 (*mesh_get_channel) (NMPlatform *, int ifindex);
655+ gboolean (*mesh_set_channel) (NMPlatform *, int ifindex, guint32 channel);
656+@@ -1191,6 +1194,8 @@ void nm_platform_wifi_set_mode (NMPlatform *self, int ifindex, NM
657+ void nm_platform_wifi_set_powersave (NMPlatform *self, int ifindex, guint32 powersave);
658+ guint32 nm_platform_wifi_find_frequency (NMPlatform *self, int ifindex, const guint32 *freqs);
659+ void nm_platform_wifi_indicate_addressing_running (NMPlatform *self, int ifindex, gboolean running);
660++NMSettingWirelessWakeOnWLan nm_platform_wifi_get_wake_on_wlan (NMPlatform *self, int ifindex);
661++gboolean nm_platform_wifi_set_wake_on_wlan (NMPlatform *self, int ifindex, NMSettingWirelessWakeOnWLan wowl);
662+
663+ guint32 nm_platform_mesh_get_channel (NMPlatform *self, int ifindex);
664+ gboolean nm_platform_mesh_set_channel (NMPlatform *self, int ifindex, guint32 channel);
665+diff --git a/src/platform/wifi/wifi-utils-nl80211.c b/src/platform/wifi/wifi-utils-nl80211.c
666+index a5f25b0..3a09244 100644
667+--- a/src/platform/wifi/wifi-utils-nl80211.c
668++++ b/src/platform/wifi/wifi-utils-nl80211.c
669+@@ -495,6 +495,103 @@ nla_put_failure:
670+ return FALSE;
671+ }
672+
673++static int
674++nl80211_get_wake_on_wlan_handler (struct nl_msg *msg, void *arg)
675++{
676++ NMSettingWirelessWakeOnWLan *wowl = arg;
677++ struct nlattr *attrs[NL80211_ATTR_MAX + 1];
678++ struct nlattr *trig[NUM_NL80211_WOWLAN_TRIG];
679++ struct genlmsghdr *gnlh = nlmsg_data (nlmsg_hdr (msg));
680++
681++ nla_parse (attrs, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0),
682++ genlmsg_attrlen(gnlh, 0), NULL);
683++
684++ if (!attrs[NL80211_ATTR_WOWLAN_TRIGGERS])
685++ return NL_SKIP;
686++
687++ nla_parse (trig, MAX_NL80211_WOWLAN_TRIG,
688++ nla_data (attrs[NL80211_ATTR_WOWLAN_TRIGGERS]),
689++ nla_len (attrs[NL80211_ATTR_WOWLAN_TRIGGERS]),
690++ NULL);
691++
692++ *wowl = NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE;
693++ if (trig[NL80211_WOWLAN_TRIG_ANY])
694++ *wowl |= NM_SETTING_WIRELESS_WAKE_ON_WLAN_ANY;
695++ if (trig[NL80211_WOWLAN_TRIG_DISCONNECT])
696++ *wowl |= NM_SETTING_WIRELESS_WAKE_ON_WLAN_DISCONNECT;
697++ if (trig[NL80211_WOWLAN_TRIG_MAGIC_PKT])
698++ *wowl |= NM_SETTING_WIRELESS_WAKE_ON_WLAN_MAGIC;
699++ if (trig[NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE])
700++ *wowl |= NM_SETTING_WIRELESS_WAKE_ON_WLAN_GTK_REKEY_FAILURE;
701++ if (trig[NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST])
702++ *wowl |= NM_SETTING_WIRELESS_WAKE_ON_WLAN_EAP_IDENTITY_REQUEST;
703++ if (trig[NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE])
704++ *wowl |= NM_SETTING_WIRELESS_WAKE_ON_WLAN_4WAY_HANDSHAKE;
705++ if (trig[NL80211_WOWLAN_TRIG_RFKILL_RELEASE])
706++ *wowl |= NM_SETTING_WIRELESS_WAKE_ON_WLAN_RFKILL_RELEASE;
707++ if (trig[NL80211_WOWLAN_TRIG_TCP_CONNECTION])
708++ *wowl |= NM_SETTING_WIRELESS_WAKE_ON_WLAN_TCP;
709++
710++ return NL_SKIP;
711++}
712++
713++static NMSettingWirelessWakeOnWLan
714++wifi_nl80211_get_wake_on_wlan (WifiData *data)
715++{
716++ WifiDataNl80211 *nl80211 = (WifiDataNl80211 *) data;
717++ NMSettingWirelessWakeOnWLan wowl = NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE;
718++ struct nl_msg *msg = NULL;
719++
720++ msg = nl80211_alloc_msg (nl80211, NL80211_CMD_GET_WOWLAN, 0);
721++
722++ nl80211_send_and_recv (nl80211, msg, nl80211_get_wake_on_wlan_handler, &wowl);
723++
724++ return wowl;
725++}
726++
727++static gboolean
728++wifi_nl80211_set_wake_on_wlan (WifiData *data, NMSettingWirelessWakeOnWLan wowl)
729++{
730++ WifiDataNl80211 *nl80211 = (WifiDataNl80211 *) data;
731++ struct nl_msg *msg = NULL;
732++ struct nlattr *triggers;
733++ int err;
734++
735++ if (wowl == NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE)
736++ return TRUE;
737++
738++ msg = nl80211_alloc_msg (nl80211, NL80211_CMD_SET_WOWLAN, 0);
739++ if (!msg)
740++ return FALSE;
741++
742++ triggers = nla_nest_start (msg, NL80211_ATTR_WOWLAN_TRIGGERS);
743++
744++ if (NM_FLAGS_HAS (wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_ANY))
745++ NLA_PUT_FLAG (msg, NL80211_WOWLAN_TRIG_ANY);
746++ if (NM_FLAGS_HAS (wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_DISCONNECT))
747++ NLA_PUT_FLAG (msg, NL80211_WOWLAN_TRIG_DISCONNECT);
748++ if (NM_FLAGS_HAS (wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_MAGIC))
749++ NLA_PUT_FLAG (msg, NL80211_WOWLAN_TRIG_MAGIC_PKT);
750++ if (NM_FLAGS_HAS (wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_GTK_REKEY_FAILURE))
751++ NLA_PUT_FLAG (msg, NL80211_WOWLAN_TRIG_GTK_REKEY_FAILURE);
752++ if (NM_FLAGS_HAS (wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_EAP_IDENTITY_REQUEST))
753++ NLA_PUT_FLAG (msg, NL80211_WOWLAN_TRIG_EAP_IDENT_REQUEST);
754++ if (NM_FLAGS_HAS (wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_4WAY_HANDSHAKE))
755++ NLA_PUT_FLAG (msg, NL80211_WOWLAN_TRIG_4WAY_HANDSHAKE);
756++ if (NM_FLAGS_HAS (wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_RFKILL_RELEASE))
757++ NLA_PUT_FLAG (msg, NL80211_WOWLAN_TRIG_RFKILL_RELEASE);
758++
759++ nla_nest_end(msg, triggers);
760++
761++ err = nl80211_send_and_recv (nl80211, msg, NULL, NULL);
762++
763++ return err >= 0;
764++
765++nla_put_failure:
766++ nlmsg_free (msg);
767++ return FALSE;
768++}
769++
770+ /* @divisor: pass what value @xbm should be divided by to get dBm */
771+ static guint32
772+ nl80211_xbm_to_percent (gint32 xbm, guint32 divisor)
773+@@ -820,42 +917,6 @@ nla_put_failure:
774+ }
775+ #endif
776+
777+-struct nl80211_wowlan_info {
778+- gboolean enabled;
779+-};
780+-
781+-static int
782+-nl80211_wowlan_handler (struct nl_msg *msg, void *arg)
783+-{
784+- struct nlattr *tb[NL80211_ATTR_MAX + 1];
785+- struct genlmsghdr *gnlh = nlmsg_data (nlmsg_hdr (msg));
786+- struct nl80211_wowlan_info *info = arg;
787+-
788+- info->enabled = FALSE;
789+-
790+- if (nla_parse (tb, NL80211_ATTR_MAX, genlmsg_attrdata (gnlh, 0),
791+- genlmsg_attrlen (gnlh, 0), NULL) < 0)
792+- return NL_SKIP;
793+-
794+- if (tb[NL80211_ATTR_WOWLAN_TRIGGERS])
795+- info->enabled = TRUE;
796+-
797+- return NL_SKIP;
798+-}
799+-
800+-static gboolean
801+-wifi_nl80211_get_wowlan (WifiData *data)
802+-{
803+- WifiDataNl80211 *nl80211 = (WifiDataNl80211 *) data;
804+- struct nl_msg *msg;
805+- struct nl80211_wowlan_info info;
806+-
807+- msg = nl80211_alloc_msg (nl80211, NL80211_CMD_GET_WOWLAN, 0);
808+- nl80211_send_and_recv (nl80211, msg, nl80211_wowlan_handler, &info);
809+-
810+- return info.enabled;
811+-}
812+-
813+ struct nl80211_device_info {
814+ int phy;
815+ guint32 *freqs;
816+@@ -1154,8 +1215,10 @@ wifi_nl80211_init (int ifindex)
817+ nl80211->num_freqs = device_info.num_freqs;
818+ nl80211->parent.caps = device_info.caps;
819+
820+- if (device_info.can_wowlan)
821+- nl80211->parent.get_wowlan = wifi_nl80211_get_wowlan;
822++ if (device_info.can_wowlan) {
823++ nl80211->parent.get_wake_on_wlan = wifi_nl80211_get_wake_on_wlan;
824++ nl80211->parent.set_wake_on_wlan = wifi_nl80211_set_wake_on_wlan;
825++ }
826+
827+ _LOGI (LOGD_PLATFORM | LOGD_WIFI,
828+ "(%s): using nl80211 for WiFi device control",
829+diff --git a/src/platform/wifi/wifi-utils-private.h b/src/platform/wifi/wifi-utils-private.h
830+index 11a0f06..18f6131 100644
831+--- a/src/platform/wifi/wifi-utils-private.h
832++++ b/src/platform/wifi/wifi-utils-private.h
833+@@ -35,6 +35,12 @@ struct WifiData {
834+ /* Set power saving mode on an interface */
835+ gboolean (*set_powersave) (WifiData *data, guint32 powersave);
836+
837++ /* Get WakeOnWLAN configuration on an interface */
838++ NMSettingWirelessWakeOnWLan (*get_wake_on_wlan) (WifiData *data);
839++
840++ /* Set WakeOnWLAN mode on an interface */
841++ gboolean (*set_wake_on_wlan) (WifiData *data, NMSettingWirelessWakeOnWLan wowl);
842++
843+ /* Return current frequency in MHz (really associated BSS frequency) */
844+ guint32 (*get_freq) (WifiData *data);
845+
846+@@ -53,8 +59,6 @@ struct WifiData {
847+
848+ void (*deinit) (WifiData *data);
849+
850+- gboolean (*get_wowlan) (WifiData *data);
851+-
852+ /* OLPC Mesh-only functions */
853+
854+ guint32 (*get_mesh_channel) (WifiData *data);
855+diff --git a/src/platform/wifi/wifi-utils.c b/src/platform/wifi/wifi-utils.c
856+index d005212..f76bf95 100644
857+--- a/src/platform/wifi/wifi-utils.c
858++++ b/src/platform/wifi/wifi-utils.c
859+@@ -115,6 +115,25 @@ wifi_utils_set_powersave (WifiData *data, guint32 powersave)
860+ return data->set_powersave ? data->set_powersave (data, powersave) : TRUE;
861+ }
862+
863++NMSettingWirelessWakeOnWLan
864++wifi_utils_get_wake_on_wlan (WifiData *data)
865++{
866++ g_return_val_if_fail (data != NULL, FALSE);
867++
868++ return data->get_wake_on_wlan
869++ ? data->get_wake_on_wlan (data)
870++ : NM_SETTING_WIRELESS_WAKE_ON_WLAN_IGNORE;
871++}
872++
873++gboolean
874++wifi_utils_set_wake_on_wlan (WifiData *data, NMSettingWirelessWakeOnWLan wowl)
875++{
876++ g_return_val_if_fail (data != NULL, FALSE);
877++
878++ return data->set_wake_on_wlan ?
879++ data->set_wake_on_wlan (data, wowl) : FALSE;
880++}
881++
882+ guint32
883+ wifi_utils_get_freq (WifiData *data)
884+ {
885+@@ -154,15 +173,6 @@ wifi_utils_get_qual (WifiData *data)
886+ return data->get_qual (data);
887+ }
888+
889+-gboolean
890+-wifi_utils_get_wowlan (WifiData *data)
891+-{
892+- g_return_val_if_fail (data != NULL, 0);
893+- if (!data->get_wowlan)
894+- return FALSE;
895+- return data->get_wowlan (data);
896+-}
897+-
898+ void
899+ wifi_utils_deinit (WifiData *data)
900+ {
901+diff --git a/src/platform/wifi/wifi-utils.h b/src/platform/wifi/wifi-utils.h
902+index 705717b..776b3c9 100644
903+--- a/src/platform/wifi/wifi-utils.h
904++++ b/src/platform/wifi/wifi-utils.h
905+@@ -25,6 +25,7 @@
906+ #include <net/ethernet.h>
907+
908+ #include "nm-dbus-interface.h"
909++#include "nm-setting-wireless.h"
910+
911+ typedef struct WifiData WifiData;
912+
913+@@ -61,11 +62,11 @@ int wifi_utils_get_qual (WifiData *data);
914+ /* Tells the driver DHCP or SLAAC is running */
915+ gboolean wifi_utils_indicate_addressing_running (WifiData *data, gboolean running);
916+
917+-/* Returns true if WoWLAN is enabled on device */
918+-gboolean wifi_utils_get_wowlan (WifiData *data);
919+-
920+ gboolean wifi_utils_set_powersave (WifiData *data, guint32 powersave);
921+
922++NMSettingWirelessWakeOnWLan wifi_utils_get_wake_on_wlan (WifiData *data);
923++
924++gboolean wifi_utils_set_wake_on_wlan (WifiData *data, NMSettingWirelessWakeOnWLan wowl);
925+
926+ /* OLPC Mesh-only functions */
927+ guint32 wifi_utils_get_mesh_channel (WifiData *data);
928diff --git a/debian/patches/add-snap-support.patch b/debian/patches/add-snap-support.patch
929new file mode 100644
930index 0000000..a661864
931--- /dev/null
932+++ b/debian/patches/add-snap-support.patch
933@@ -0,0 +1,946 @@
934+Index: nm/src/nm-core-utils.c
935+===================================================================
936+--- nm.orig/src/nm-core-utils.c
937++++ nm/src/nm-core-utils.c
938+@@ -44,6 +44,7 @@
939+ #include "nm-setting-ip6-config.h"
940+ #include "nm-setting-wireless.h"
941+ #include "nm-setting-wireless-security.h"
942++#include "nm-core-utils.h"
943+
944+ /*
945+ * Some toolchains (E.G. uClibc 0.9.33 and earlier) don't export
946+@@ -2978,14 +2979,17 @@ guint8 *
947+ nm_utils_secret_key_read (gsize *out_key_len, GError **error)
948+ {
949+ guint8 *secret_key = NULL;
950++ char *secret_key_path = NULL;
951+ gsize key_len;
952+
953+ /* out_key_len is not optional, because without it you cannot safely
954+ * access the returned memory. */
955+ *out_key_len = 0;
956+
957++ secret_key_path = g_strdup_printf("%s/secret_key", nm_utils_get_state_dir());
958++
959+ /* Let's try to load a saved secret key first. */
960+- if (g_file_get_contents (NMSTATEDIR "/secret_key", (char **) &secret_key, &key_len, NULL)) {
961++ if (g_file_get_contents (secret_key_path, (char **) &secret_key, &key_len, NULL)) {
962+ if (key_len < 16) {
963+ g_set_error_literal (error, NM_UTILS_ERROR, NM_UTILS_ERROR_UNKNOWN,
964+ "Key is too short to be usable");
965+@@ -3007,14 +3011,16 @@ nm_utils_secret_key_read (gsize *out_key
966+ }
967+
968+ key_mask = umask (0077);
969+- if (!g_file_set_contents (NMSTATEDIR "/secret_key", (char *) secret_key, key_len, error)) {
970+- g_prefix_error (error, "Can't write " NMSTATEDIR "/secret_key: ");
971++
972++ if (!g_file_set_contents (secret_key_path, (char *) secret_key, key_len, error)) {
973++ g_prefix_error (error, "Can't write %s/secret_key: ", secret_key_path);
974+ key_len = 0;
975+ }
976+ umask (key_mask);
977+ }
978+
979+ out:
980++ g_free (secret_key_path);
981+ if (key_len) {
982+ *out_key_len = key_len;
983+ return secret_key;
984+@@ -3853,6 +3859,74 @@ nm_utils_ip4_address_is_link_local (in_a
985+ }
986+
987+ /*****************************************************************************/
988++
989++const char*
990++nm_utils_get_state_dir(void)
991++{
992++ static const char *state_dir = NULL;
993++
994++ if (!state_dir)
995++ state_dir = g_strdup_printf("%s/state", getenv("SNAP_DATA"));
996++
997++ return state_dir;
998++}
999++
1000++const char*
1001++nm_utils_get_run_dir(void)
1002++{
1003++ static const char *run_dir = NULL;
1004++
1005++ if (!run_dir)
1006++ run_dir = g_strdup_printf("%s/run", getenv("SNAP_DATA"));
1007++
1008++ return run_dir;
1009++}
1010++
1011++const char*
1012++nm_utils_get_plugin_dir(void)
1013++{
1014++ static const char *plugin_dir = NULL;
1015++
1016++ if (!plugin_dir)
1017++ plugin_dir = g_strdup_printf("%s/%s", getenv("SNAP"), NMPLUGINDIR);
1018++
1019++ return plugin_dir;
1020++}
1021++
1022++const char*
1023++nm_utils_get_conf_dir(void)
1024++{
1025++ static const char *conf_dir = NULL;
1026++
1027++ if (!conf_dir)
1028++ conf_dir = g_strdup_printf("%s/conf", getenv("SNAP_DATA"));
1029++
1030++ return conf_dir;
1031++}
1032++
1033++const char*
1034++nm_utils_get_pppd_plugin_dir (void)
1035++{
1036++ static const char *pppd_plugin_dir = NULL;
1037++
1038++ if (!pppd_plugin_dir)
1039++ pppd_plugin_dir = g_strdup_printf("%s%s", getenv("SNAP"), PPPD_PLUGIN_DIR);
1040++
1041++ return pppd_plugin_dir;
1042++}
1043++
1044++const char*
1045++nm_utils_get_conf_device_state_dir (void)
1046++{
1047++ static const char *conf_device_state_dir = NULL;
1048++
1049++ if (!conf_device_state_dir)
1050++ conf_device_state_dir = g_strdup_printf("%s/devices", nm_utils_get_run_dir());
1051++
1052++ return conf_device_state_dir;
1053++}
1054++
1055++/*****************************************************************************/
1056+
1057+ /**
1058+ * Takes a pair @timestamp and @duration, and returns the remaining duration based
1059+Index: nm/src/nm-core-utils.h
1060+===================================================================
1061+--- nm.orig/src/nm-core-utils.h
1062++++ nm/src/nm-core-utils.h
1063+@@ -419,6 +419,13 @@ gboolean nm_utils_lifetime_get (guint32
1064+
1065+ gboolean nm_utils_ip4_address_is_link_local (in_addr_t addr);
1066+
1067++const char* nm_utils_get_state_dir (void);
1068++const char* nm_utils_get_run_dir (void);
1069++const char* nm_utils_get_plugin_dir (void);
1070++const char* nm_utils_get_conf_dir (void);
1071++const char* nm_utils_get_pppd_plugin_dir (void);
1072++const char* nm_utils_get_conf_device_state_dir (void);
1073++
1074+ const char *nm_utils_dnsmasq_status_to_string (int status, char *dest, gsize size);
1075+
1076+ void nm_utils_get_reverse_dns_domains_ip4 (guint32 ip, guint8 plen, GPtrArray *domains);
1077+Index: nm/src/devices/nm-device-factory.c
1078+===================================================================
1079+--- nm.orig/src/devices/nm-device-factory.c
1080++++ nm/src/devices/nm-device-factory.c
1081+@@ -32,6 +32,7 @@
1082+ #include "nm-utils.h"
1083+ #include "nm-core-internal.h"
1084+ #include "nm-setting-bluetooth.h"
1085++#include "nm-core-utils.h"
1086+
1087+ #define PLUGIN_PREFIX "libnm-device-plugin-"
1088+
1089+@@ -375,7 +376,7 @@ nm_device_factory_manager_load_factories
1090+ _ADD_INTERNAL (nm_vlan_device_factory_get_type);
1091+ _ADD_INTERNAL (nm_vxlan_device_factory_get_type);
1092+
1093+- paths = nm_utils_read_plugin_paths (NMPLUGINDIR, PLUGIN_PREFIX);
1094++ paths = nm_utils_read_plugin_paths (nm_utils_get_plugin_dir(), PLUGIN_PREFIX);
1095+ if (!paths)
1096+ return;
1097+
1098+Index: nm/src/dhcp/nm-dhcp-dhclient.c
1099+===================================================================
1100+--- nm.orig/src/dhcp/nm-dhcp-dhclient.c
1101++++ nm/src/dhcp/nm-dhcp-dhclient.c
1102+@@ -46,6 +46,7 @@
1103+ #include "NetworkManagerUtils.h"
1104+ #include "nm-dhcp-listener.h"
1105+ #include "nm-dhcp-client-logging.h"
1106++#include "nm-core-utils.h"
1107+
1108+ /*****************************************************************************/
1109+
1110+@@ -123,7 +124,8 @@ get_dhclient_leasefile (int addr_family,
1111+ char *path;
1112+
1113+ /* /var/lib/NetworkManager is the preferred leasefile path */
1114+- path = g_strdup_printf (NMSTATEDIR "/dhclient%s-%s-%s.lease",
1115++ path = g_strdup_printf ("%s/dhclient%s-%s-%s.lease",
1116++ nm_utils_get_state_dir(),
1117+ _addr_family_to_path_part (addr_family),
1118+ uuid,
1119+ iface);
1120+@@ -313,7 +315,8 @@ create_dhclient_config (NMDhcpDhclient *
1121+
1122+ g_return_val_if_fail (iface != NULL, NULL);
1123+
1124+- new = g_strdup_printf (NMSTATEDIR "/dhclient%s-%s.conf", _addr_family_to_path_part (addr_family), iface);
1125++ new = g_strdup_printf ("%s/dhclient%s-%s.conf", nm_utils_get_state_dir(),
1126++ _addr_family_to_path_part (addr_family), iface);
1127+ _LOGD ("creating composite dhclient config %s", new);
1128+
1129+ orig = find_existing_config (self, addr_family, iface, uuid);
1130+Index: nm/src/dhcp/nm-dhcp-systemd.c
1131+===================================================================
1132+--- nm.orig/src/dhcp/nm-dhcp-systemd.c
1133++++ nm/src/dhcp/nm-dhcp-systemd.c
1134+@@ -445,7 +445,8 @@ lease_to_ip4_config (NMDedupMultiIndex *
1135+ static char *
1136+ get_leasefile_path (int addr_family, const char *iface, const char *uuid)
1137+ {
1138+- return g_strdup_printf (NMSTATEDIR "/internal%s-%s-%s.lease",
1139++ return g_strdup_printf ("%s/dhcp/internal%s-%s-%s.lease",
1140++ nm_utils_get_state_dir(),
1141+ addr_family == AF_INET6 ? "6" : "",
1142+ uuid,
1143+ iface);
1144+Index: nm/src/main-utils.c
1145+===================================================================
1146+--- nm.orig/src/main-utils.c
1147++++ nm/src/main-utils.c
1148+@@ -34,6 +34,7 @@
1149+
1150+ #include "main-utils.h"
1151+ #include "NetworkManagerUtils.h"
1152++#include "nm-core-utils.h"
1153+ #include "nm-config.h"
1154+
1155+ static gboolean
1156+@@ -118,7 +119,7 @@ nm_main_utils_ensure_statedir ()
1157+ gs_free char *parent = NULL;
1158+ int errsv;
1159+
1160+- parent = g_path_get_dirname (NMSTATEDIR);
1161++ parent = g_path_get_dirname (nm_utils_get_state_dir());
1162+
1163+ /* Ensure parent state directories exists */
1164+ if ( parent
1165+@@ -126,13 +127,13 @@ nm_main_utils_ensure_statedir ()
1166+ && parent[1] != '\0'
1167+ && g_mkdir_with_parents (parent, 0755) != 0) {
1168+ errsv = errno;
1169+- fprintf (stderr, "Cannot create parents for '%s': %s", NMSTATEDIR, g_strerror (errsv));
1170++ fprintf (stderr, "Cannot create parents for '%s': %s", nm_utils_get_state_dir(), g_strerror (errsv));
1171+ exit (1);
1172+ }
1173+ /* Ensure state directory exists */
1174+- if (g_mkdir_with_parents (NMSTATEDIR, 0700) != 0) {
1175++ if (g_mkdir_with_parents (nm_utils_get_state_dir(), 0700) != 0) {
1176+ errsv = errno;
1177+- fprintf (stderr, "Cannot create '%s': %s", NMSTATEDIR, g_strerror (errsv));
1178++ fprintf (stderr, "Cannot create '%s': %s", nm_utils_get_state_dir(), g_strerror (errsv));
1179+ exit (1);
1180+ }
1181+ }
1182+@@ -143,20 +144,19 @@ nm_main_utils_ensure_rundir ()
1183+ int errsv;
1184+
1185+ /* Setup runtime directory */
1186+- if (g_mkdir_with_parents (NMRUNDIR, 0755) != 0) {
1187++ if (g_mkdir_with_parents (nm_utils_get_run_dir(), 0755) != 0) {
1188+ errsv = errno;
1189+- fprintf (stderr, _("Cannot create '%s': %s"), NMRUNDIR, g_strerror (errsv));
1190++ fprintf (stderr, _("Cannot create '%s': %s"), nm_utils_get_run_dir(), g_strerror (errsv));
1191+ exit (1);
1192+ }
1193+
1194+ /* NM_CONFIG_DEVICE_STATE_DIR is used to determine whether NM is restarted or not.
1195+ * It is important to set NMConfigCmdLineOptions.first_start before creating
1196+ * the directory. */
1197+- nm_assert (g_str_has_prefix (NM_CONFIG_DEVICE_STATE_DIR, NMRUNDIR"/"));
1198+- if (g_mkdir (NM_CONFIG_DEVICE_STATE_DIR, 0755) != 0) {
1199++ if (g_mkdir (nm_utils_get_conf_device_state_dir(), 0755) != 0) {
1200+ errsv = errno;
1201+ if (errsv != EEXIST) {
1202+- fprintf (stderr, _("Cannot create '%s': %s"), NM_CONFIG_DEVICE_STATE_DIR, g_strerror (errsv));
1203++ fprintf (stderr, _("Cannot create '%s': %s"), nm_utils_get_conf_device_state_dir(), g_strerror (errsv));
1204+ exit (1);
1205+ }
1206+ }
1207+Index: nm/src/main.c
1208+===================================================================
1209+--- nm.orig/src/main.c
1210++++ nm/src/main.c
1211+@@ -53,12 +53,15 @@
1212+ #include "dns/nm-dns-manager.h"
1213+ #include "systemd/nm-sd.h"
1214+ #include "nm-netns.h"
1215++#include "nm-core-utils.h"
1216+
1217+ #if !defined(NM_DIST_VERSION)
1218+ # define NM_DIST_VERSION VERSION
1219+ #endif
1220+
1221+ #define NM_DEFAULT_PID_FILE NMRUNDIR "/NetworkManager.pid"
1222++
1223++/* TODO[snap]: this doesn't appear to be used anywhere else? */
1224+ #define NM_DEFAULT_SYSTEM_STATE_FILE NMSTATEDIR "/NetworkManager.state"
1225+
1226+ #define CONFIG_ATOMIC_SECTION_PREFIXES ((char **) NULL)
1227+@@ -212,7 +215,7 @@ do_early_setup (int *argc, char **argv[]
1228+ _("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.")))
1229+ exit (1);
1230+
1231+- global_opt.pidfile = global_opt.pidfile ? global_opt.pidfile : g_strdup (NM_DEFAULT_PID_FILE);
1232++ global_opt.pidfile = global_opt.pidfile ? global_opt.pidfile : g_strdup_printf ("%s/NetworkManager.pid", nm_utils_get_run_dir());
1233+ }
1234+
1235+ /*
1236+@@ -244,7 +247,7 @@ main (int argc, char *argv[])
1237+
1238+ /* we determine a first-start (contrary to a restart during the same boot)
1239+ * based on the existence of NM_CONFIG_DEVICE_STATE_DIR directory. */
1240+- config_cli = nm_config_cmd_line_options_new (!g_file_test (NM_CONFIG_DEVICE_STATE_DIR,
1241++ config_cli = nm_config_cmd_line_options_new (!g_file_test (nm_utils_get_conf_device_state_dir(),
1242+ G_FILE_TEST_IS_DIR));
1243+
1244+ do_early_setup (&argc, &argv, config_cli);
1245+Index: nm/src/nm-config.c
1246+===================================================================
1247+--- nm.orig/src/nm-config.c
1248++++ nm/src/nm-config.c
1249+@@ -167,6 +167,16 @@ static void _set_config_data (NMConfig *
1250+
1251+ /*****************************************************************************/
1252+
1253++static const char *get_no_auto_default_file_path()
1254++{
1255++ const char *no_auto_default_file = NULL;
1256++
1257++ if (!no_auto_default_file)
1258++ no_auto_default_file = g_strdup_printf("%s/no-auto-default.state", nm_utils_get_state_dir());
1259++
1260++ return no_auto_default_file;
1261++}
1262++
1263+ gint
1264+ nm_config_parse_boolean (const char *str,
1265+ gint default_value)
1266+@@ -2052,13 +2062,14 @@ NMConfigDeviceStateData *
1267+ nm_config_device_state_load (int ifindex)
1268+ {
1269+ NMConfigDeviceStateData *device_state;
1270+- char path[NM_STRLEN (NM_CONFIG_DEVICE_STATE_DIR) + 60];
1271++ gsize dev_state_dir_len = strlen (nm_utils_get_conf_device_state_dir ());
1272++ char path[dev_state_dir_len + 60];
1273+ gs_unref_keyfile GKeyFile *kf = NULL;
1274+ const char *nm_owned_str;
1275+
1276+ g_return_val_if_fail (ifindex > 0, NULL);
1277+
1278+- nm_sprintf_buf (path, "%s/%d", NM_CONFIG_DEVICE_STATE_DIR, ifindex);
1279++ nm_sprintf_buf (path, "%s/%d", nm_utils_get_conf_device_state_dir(), ifindex);
1280+
1281+ kf = nm_config_create_keyfile ();
1282+ if (!g_key_file_load_from_file (kf, path, G_KEY_FILE_NONE, NULL))
1283+@@ -2102,7 +2113,7 @@ nm_config_device_state_load_all (void)
1284+
1285+ states = g_hash_table_new_full (nm_direct_hash, NULL, NULL, g_free);
1286+
1287+- dir = g_dir_open (NM_CONFIG_DEVICE_STATE_DIR, 0, NULL);
1288++ dir = g_dir_open (nm_utils_get_conf_device_state_dir(), 0, NULL);
1289+ if (!dir)
1290+ return states;
1291+
1292+@@ -2134,7 +2145,8 @@ nm_config_device_state_write (int ifinde
1293+ guint32 route_metric_default_aspired,
1294+ guint32 route_metric_default_effective)
1295+ {
1296+- char path[NM_STRLEN (NM_CONFIG_DEVICE_STATE_DIR) + 60];
1297++ gsize dev_state_dir_len = strlen (nm_utils_get_conf_device_state_dir ());
1298++ char path[dev_state_dir_len + 60];
1299+ GError *local = NULL;
1300+ gs_unref_keyfile GKeyFile *kf = NULL;
1301+
1302+@@ -2144,7 +2156,7 @@ nm_config_device_state_write (int ifinde
1303+
1304+ nm_assert (!perm_hw_addr_fake || nm_utils_hwaddr_valid (perm_hw_addr_fake, -1));
1305+
1306+- nm_sprintf_buf (path, "%s/%d", NM_CONFIG_DEVICE_STATE_DIR, ifindex);
1307++ nm_sprintf_buf (path, "%s/%d", nm_utils_get_conf_device_state_dir(), ifindex);
1308+
1309+ kf = nm_config_create_keyfile ();
1310+ if (NM_IN_SET (managed,
1311+@@ -2209,12 +2221,15 @@ nm_config_device_state_prune_unseen (GHa
1312+ const char *fn;
1313+ int ifindex;
1314+ gsize fn_len;
1315+- char buf[NM_STRLEN (NM_CONFIG_DEVICE_STATE_DIR"/") + 30 + 3] = NM_CONFIG_DEVICE_STATE_DIR"/";
1316+- char *buf_p = &buf[NM_STRLEN (NM_CONFIG_DEVICE_STATE_DIR"/")];
1317++ gsize dev_state_dir_len = strlen (nm_utils_get_conf_device_state_dir ()) + 1;
1318++ char buf[dev_state_dir_len + 30 + 3];
1319++ char *buf_p = &buf[dev_state_dir_len];
1320++
1321++ g_snprintf(buf, dev_state_dir_len, "%s/", nm_utils_get_conf_device_state_dir ());
1322+
1323+ g_return_if_fail (seen_ifindexes);
1324+
1325+- dir = g_dir_open (NM_CONFIG_DEVICE_STATE_DIR, 0, NULL);
1326++ dir = g_dir_open (nm_utils_get_conf_device_state_dir (), 0, NULL);
1327+ if (!dir)
1328+ return;
1329+
1330+@@ -2525,7 +2540,7 @@ init_sync (GInitable *initable, GCancell
1331+ if (priv->cli.no_auto_default_file)
1332+ priv->no_auto_default_file = g_strdup (priv->cli.no_auto_default_file);
1333+ else
1334+- priv->no_auto_default_file = g_strdup (DEFAULT_NO_AUTO_DEFAULT_FILE);
1335++ priv->no_auto_default_file = g_strdup (get_no_auto_default_file_path());
1336+
1337+ priv->monitor_connection_files = nm_config_keyfile_get_boolean (keyfile, NM_CONFIG_KEYFILE_GROUP_MAIN, "monitor-connection-files", FALSE);
1338+
1339+Index: nm/src/ppp/nm-ppp-manager.c
1340+===================================================================
1341+--- nm.orig/src/ppp/nm-ppp-manager.c
1342++++ nm/src/ppp/nm-ppp-manager.c
1343+@@ -57,7 +57,7 @@
1344+
1345+ #include "introspection/org.freedesktop.NetworkManager.PPP.h"
1346+
1347+-#define NM_PPPD_PLUGIN PPPD_PLUGIN_DIR "/nm-pppd-plugin.so"
1348++#define NM_PPPD_PLUGIN "nm-pppd-plugin.so"
1349+
1350+ static NM_CACHED_QUARK_FCN ("ppp-manager-secret-tries", ppp_manager_secret_tries_quark)
1351+
1352+@@ -739,6 +739,7 @@ create_pppd_cmd_line (NMPPPManager *self
1353+ const char *pppd_binary = NULL;
1354+ NMCmdLine *cmd;
1355+ gboolean ppp_debug;
1356++ char *pppd_plugin_dir;
1357+ static int unit;
1358+
1359+ g_return_val_if_fail (setting != NULL, NULL);
1360+@@ -901,8 +902,12 @@ create_pppd_cmd_line (NMPPPManager *self
1361+ nm_cmd_line_add_string (cmd, "ipparam");
1362+ nm_cmd_line_add_string (cmd, nm_exported_object_get_path (NM_EXPORTED_OBJECT (self)));
1363+
1364++ pppd_plugin_dir = g_strdup_printf ("%s/%s", nm_utils_get_pppd_plugin_dir (), NM_PPPD_PLUGIN);
1365++
1366+ nm_cmd_line_add_string (cmd, "plugin");
1367+- nm_cmd_line_add_string (cmd, NM_PPPD_PLUGIN);
1368++ nm_cmd_line_add_string (cmd, pppd_plugin_dir);
1369++
1370++ g_free (pppd_plugin_dir);
1371+
1372+ if (pppoe && nm_setting_pppoe_get_parent (pppoe)) {
1373+ /* The PPP interface is going to be renamed, so pass a
1374+Index: nm/src/nm-iface-helper.c
1375+===================================================================
1376+--- nm.orig/src/nm-iface-helper.c
1377++++ nm/src/nm-iface-helper.c
1378+@@ -48,8 +48,6 @@
1379+ # define NM_DIST_VERSION VERSION
1380+ #endif
1381+
1382+-#define NMIH_PID_FILE_FMT NMRUNDIR "/nm-iface-helper-%d.pid"
1383+-
1384+ /*****************************************************************************/
1385+
1386+ static struct {
1387+@@ -385,7 +383,7 @@ main (int argc, char *argv[])
1388+ fprintf (stderr, _("Failed to find interface index for %s (%s)\n"), global_opt.ifname, strerror (errno));
1389+ return 1;
1390+ }
1391+- pidfile = g_strdup_printf (NMIH_PID_FILE_FMT, gl.ifindex);
1392++ pidfile = g_strdup_printf ("%s/nm-iface-helper-%d.pid", nm_utils_get_run_dir(), gl.ifindex);
1393+ nm_main_utils_ensure_not_running_pidfile (pidfile);
1394+
1395+ nm_main_utils_ensure_rundir ();
1396+Index: nm/src/settings/nm-settings-connection.c
1397+===================================================================
1398+--- nm.orig/src/settings/nm-settings-connection.c
1399++++ nm/src/settings/nm-settings-connection.c
1400+@@ -41,9 +41,6 @@
1401+
1402+ #include "introspection/org.freedesktop.NetworkManager.Settings.Connection.h"
1403+
1404+-#define SETTINGS_TIMESTAMPS_FILE NMSTATEDIR "/timestamps"
1405+-#define SETTINGS_SEEN_BSSIDS_FILE NMSTATEDIR "/seen-bssids"
1406+-
1407+ #define AUTOCONNECT_RETRIES_UNSET -2
1408+ #define AUTOCONNECT_RETRIES_FOREVER -1
1409+ #define AUTOCONNECT_RESET_RETRIES_TIMER 300
1410+@@ -146,6 +143,27 @@ G_DEFINE_TYPE_WITH_CODE (NMSettingsConne
1411+
1412+ /*****************************************************************************/
1413+
1414++static const char *get_settings_timestamps_path()
1415++{
1416++ static const char *timestamps_path = NULL;
1417++
1418++ if (!timestamps_path)
1419++ timestamps_path = g_strdup_printf("%s/timestamps", nm_utils_get_state_dir());
1420++
1421++ return timestamps_path;
1422++}
1423++
1424++static const char *get_settings_seen_bssids_path()
1425++{
1426++ static const char *seen_bssids_path = NULL;
1427++
1428++ if (!seen_bssids_path)
1429++ seen_bssids_path = g_strdup_printf("%s/seen-bssids", nm_utils_get_state_dir());
1430++ return seen_bssids_path;
1431++}
1432++
1433++/*****************************************************************************/
1434++
1435+ static void
1436+ _emit_updated (NMSettingsConnection *self, gboolean by_user)
1437+ {
1438+@@ -748,9 +766,9 @@ remove_entry_from_db (NMSettingsConnecti
1439+ const char *db_file;
1440+
1441+ if (strcmp (db_name, "timestamps") == 0)
1442+- db_file = SETTINGS_TIMESTAMPS_FILE;
1443++ db_file = get_settings_timestamps_path();
1444+ else if (strcmp (db_name, "seen-bssids") == 0)
1445+- db_file = SETTINGS_SEEN_BSSIDS_FILE;
1446++ db_file = get_settings_seen_bssids_path();
1447+ else
1448+ return;
1449+
1450+@@ -2432,9 +2450,9 @@ nm_settings_connection_update_timestamp
1451+
1452+ /* Save timestamp to timestamps database file */
1453+ timestamps_file = g_key_file_new ();
1454+- if (!g_key_file_load_from_file (timestamps_file, SETTINGS_TIMESTAMPS_FILE, G_KEY_FILE_KEEP_COMMENTS, &error)) {
1455++ if (!g_key_file_load_from_file (timestamps_file, get_settings_timestamps_path(), G_KEY_FILE_KEEP_COMMENTS, &error)) {
1456+ if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
1457+- _LOGW ("error parsing timestamps file '%s': %s", SETTINGS_TIMESTAMPS_FILE, error->message);
1458++ _LOGW ("error parsing timestamps file '%s': %s", get_settings_timestamps_path(), error->message);
1459+ g_clear_error (&error);
1460+ }
1461+
1462+@@ -2445,11 +2463,11 @@ nm_settings_connection_update_timestamp
1463+
1464+ data = g_key_file_to_data (timestamps_file, &len, &error);
1465+ if (data) {
1466+- g_file_set_contents (SETTINGS_TIMESTAMPS_FILE, data, len, &error);
1467++ g_file_set_contents (get_settings_timestamps_path(), data, len, &error);
1468+ g_free (data);
1469+ }
1470+ if (error) {
1471+- _LOGW ("error saving timestamp to file '%s': %s", SETTINGS_TIMESTAMPS_FILE, error->message);
1472++ _LOGW ("error saving timestamp to file '%s': %s", get_settings_timestamps_path(), error->message);
1473+ g_error_free (error);
1474+ }
1475+ g_key_file_free (timestamps_file);
1476+@@ -2475,7 +2493,7 @@ nm_settings_connection_read_and_fill_tim
1477+ g_return_if_fail (NM_IS_SETTINGS_CONNECTION (self));
1478+
1479+ timestamps_file = g_key_file_new ();
1480+- if (!g_key_file_load_from_file (timestamps_file, SETTINGS_TIMESTAMPS_FILE, G_KEY_FILE_KEEP_COMMENTS, &error)) {
1481++ if (!g_key_file_load_from_file (timestamps_file, get_settings_timestamps_path(), G_KEY_FILE_KEEP_COMMENTS, &error)) {
1482+ _LOGD ("failed to read connection timestamp: %s", error->message);
1483+ return;
1484+ }
1485+@@ -2585,10 +2603,10 @@ nm_settings_connection_add_seen_bssid (N
1486+ /* Save BSSID to seen-bssids file */
1487+ seen_bssids_file = g_key_file_new ();
1488+ g_key_file_set_list_separator (seen_bssids_file, ',');
1489+- if (!g_key_file_load_from_file (seen_bssids_file, SETTINGS_SEEN_BSSIDS_FILE, G_KEY_FILE_KEEP_COMMENTS, &error)) {
1490++ if (!g_key_file_load_from_file (seen_bssids_file, get_settings_seen_bssids_path(), G_KEY_FILE_KEEP_COMMENTS, &error)) {
1491+ if (!g_error_matches (error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) {
1492+ _LOGW ("error parsing seen-bssids file '%s': %s",
1493+- SETTINGS_SEEN_BSSIDS_FILE, error->message);
1494++ get_settings_seen_bssids_path(), error->message);
1495+ }
1496+ g_clear_error (&error);
1497+ }
1498+@@ -2599,14 +2617,14 @@ nm_settings_connection_add_seen_bssid (N
1499+
1500+ data = g_key_file_to_data (seen_bssids_file, &len, &error);
1501+ if (data) {
1502+- g_file_set_contents (SETTINGS_SEEN_BSSIDS_FILE, data, len, &error);
1503++ g_file_set_contents (get_settings_seen_bssids_path(), data, len, &error);
1504+ g_free (data);
1505+ }
1506+ g_key_file_free (seen_bssids_file);
1507+
1508+ if (error) {
1509+ _LOGW ("error saving seen-bssids to file '%s': %s",
1510+- SETTINGS_SEEN_BSSIDS_FILE, error->message);
1511++ get_settings_seen_bssids_path(), error->message);
1512+ g_error_free (error);
1513+ }
1514+ }
1515+@@ -2631,7 +2649,7 @@ nm_settings_connection_read_and_fill_see
1516+ /* Get seen BSSIDs from database file */
1517+ seen_bssids_file = g_key_file_new ();
1518+ g_key_file_set_list_separator (seen_bssids_file, ',');
1519+- if (g_key_file_load_from_file (seen_bssids_file, SETTINGS_SEEN_BSSIDS_FILE, G_KEY_FILE_KEEP_COMMENTS, NULL)) {
1520++ if (g_key_file_load_from_file (seen_bssids_file, get_settings_seen_bssids_path(), G_KEY_FILE_KEEP_COMMENTS, NULL)) {
1521+ connection_uuid = nm_settings_connection_get_uuid (self);
1522+ tmp_strv = g_key_file_get_string_list (seen_bssids_file, "seen-bssids", connection_uuid, &len, NULL);
1523+ }
1524+Index: nm/Makefile.am
1525+===================================================================
1526+--- nm.orig/Makefile.am
1527++++ nm/Makefile.am
1528+@@ -1135,6 +1135,7 @@ src_cppflags = \
1529+ -DNMRUNDIR=\"$(nmrundir)\" \
1530+ -DNMSTATEDIR=\"$(nmstatedir)\" \
1531+ -DNMLIBDIR=\"$(nmlibdir)\" \
1532++ -DPPPD_PLUGIN_DIR=\"$(PPPD_PLUGIN_DIR)\" \
1533+ \
1534+ -DDHCPCANON_PATH=\"$(DHCPCANON_PATH)\" \
1535+ -DDHCLIENT_PATH=\"$(DHCLIENT_PATH)\" \
1536+Index: nm/src/settings/nm-settings.c
1537+===================================================================
1538+--- nm.orig/src/settings/nm-settings.c
1539++++ nm/src/settings/nm-settings.c
1540+@@ -76,6 +76,7 @@
1541+ #include "NetworkManagerUtils.h"
1542+ #include "nm-dispatcher.h"
1543+ #include "nm-hostname-manager.h"
1544++#include "nm-core-utils.h"
1545+
1546+ #include "introspection/org.freedesktop.NetworkManager.Settings.h"
1547+
1548+@@ -717,7 +718,7 @@ load_plugin:
1549+ int errsv;
1550+
1551+ full_name = g_strdup_printf ("nm-settings-plugin-%s", pname);
1552+- path = g_module_build_path (NMPLUGINDIR, full_name);
1553++ path = g_module_build_path (nm_utils_get_plugin_dir(), full_name);
1554+
1555+ if (stat (path, &st) != 0) {
1556+ errsv = errno;
1557+Index: nm/src/settings/plugins/keyfile/nms-keyfile-utils.c
1558+===================================================================
1559+--- nm.orig/src/settings/plugins/keyfile/nms-keyfile-utils.c
1560++++ nm/src/settings/plugins/keyfile/nms-keyfile-utils.c
1561+@@ -30,8 +30,6 @@
1562+ #include "nm-setting-wireless-security.h"
1563+ #include "nm-config.h"
1564+
1565+-#define NM_CONFIG_KEYFILE_PATH_DEFAULT NMCONFDIR "/system-connections"
1566+-
1567+ /*****************************************************************************/
1568+
1569+ static const char temp_letters[] =
1570+@@ -163,7 +161,8 @@ nms_keyfile_utils_get_path (void)
1571+ NM_CONFIG_KEYFILE_KEY_KEYFILE_PATH,
1572+ NM_CONFIG_GET_VALUE_STRIP | NM_CONFIG_GET_VALUE_NO_EMPTY);
1573+ if (!path)
1574+- path = g_strdup (""NM_CONFIG_KEYFILE_PATH_DEFAULT"");
1575++ path = g_strdup_printf ("%s/system-connections", nm_utils_get_conf_dir());
1576++
1577+ }
1578+ return path;
1579+ }
1580+Index: nm/src/dns/nm-dns-dnsmasq.c
1581+===================================================================
1582+--- nm.orig/src/dns/nm-dns-dnsmasq.c
1583++++ nm/src/dns/nm-dns-dnsmasq.c
1584+@@ -38,9 +38,6 @@
1585+ #include "nm-bus-manager.h"
1586+ #include "NetworkManagerUtils.h"
1587+
1588+-#define PIDFILE NMRUNDIR "/dnsmasq.pid"
1589+-#define CONFDIR NMCONFDIR "/dnsmasq.d"
1590+-
1591+ #define DNSMASQ_DBUS_SERVICE "org.freedesktop.NetworkManager.dnsmasq"
1592+ #define DNSMASQ_DBUS_PATH "/uk/org/thekelleys/dnsmasq"
1593+
1594+@@ -480,6 +477,10 @@ start_dnsmasq (NMDnsDnsmasq *self)
1595+ guint idx = 0;
1596+ NMBusManager *dbus_mgr;
1597+ GDBusConnection *connection;
1598++ char *pidfile = NULL;
1599++ char *pidfile_arg = NULL;
1600++ char *confdir = NULL;
1601++ char *confdir_arg = NULL;
1602+
1603+ if (priv->running) {
1604+ /* the dnsmasq process is running. Nothing to do. */
1605+@@ -498,12 +499,15 @@ start_dnsmasq (NMDnsDnsmasq *self)
1606+ return;
1607+ }
1608+
1609++ pidfile = g_strdup_printf ("%s/dnsmasq.pid", nm_utils_get_run_dir ());
1610++ pidfile_arg = g_strdup_printf ("--pid-file=%s", pidfile);
1611++
1612+ argv[idx++] = dm_binary;
1613+ argv[idx++] = "--no-resolv"; /* Use only commandline */
1614+ argv[idx++] = "--keep-in-foreground";
1615+ argv[idx++] = "--no-hosts"; /* don't use /etc/hosts to resolve */
1616+ argv[idx++] = "--bind-interfaces";
1617+- argv[idx++] = "--pid-file=" PIDFILE;
1618++ argv[idx++] = pidfile_arg;
1619+ argv[idx++] = "--listen-address=127.0.1.1"; /* Should work for both 4 and 6 */
1620+ argv[idx++] = "--cache-size=0";
1621+ argv[idx++] = "--clear-on-reload"; /* clear cache when dns server changes */
1622+@@ -511,15 +515,24 @@ start_dnsmasq (NMDnsDnsmasq *self)
1623+ argv[idx++] = "--proxy-dnssec"; /* Allow DNSSEC to pass through */
1624+ argv[idx++] = "--enable-dbus=" DNSMASQ_DBUS_SERVICE;
1625+
1626++ confdir = g_strdup_printf ("%s/dnsmasq.d", nm_utils_get_conf_dir ());
1627++ confdir_arg = g_strdup_printf ("--pid-file=%s", confdir);
1628++
1629+ /* dnsmasq exits if the conf dir is not present */
1630+- if (g_file_test (CONFDIR, G_FILE_TEST_IS_DIR))
1631+- argv[idx++] = "--conf-dir=" CONFDIR;
1632++ if (g_file_test (confdir, G_FILE_TEST_IS_DIR))
1633++ argv[idx++] = confdir_arg;
1634+
1635+ argv[idx++] = NULL;
1636+ nm_assert (idx <= G_N_ELEMENTS (argv));
1637+
1638+ /* And finally spawn dnsmasq */
1639+- pid = nm_dns_plugin_child_spawn (NM_DNS_PLUGIN (self), argv, PIDFILE, "bin/dnsmasq");
1640++ pid = nm_dns_plugin_child_spawn (NM_DNS_PLUGIN (self), argv, pidfile, "bin/dnsmasq");
1641++
1642++ g_free (pidfile);
1643++ g_free (pidfile_arg);
1644++ g_free (confdir);
1645++ g_free (confdir_arg);
1646++
1647+ if (!pid)
1648+ return;
1649+
1650+Index: nm/src/dnsmasq/nm-dnsmasq-manager.c
1651+===================================================================
1652+--- nm.orig/src/dnsmasq/nm-dnsmasq-manager.c
1653++++ nm/src/dnsmasq/nm-dnsmasq-manager.c
1654+@@ -35,8 +35,6 @@
1655+ #include "NetworkManagerUtils.h"
1656+ #include "nm-core-internal.h"
1657+
1658+-#define CONFDIR NMCONFDIR "/dnsmasq-shared.d"
1659+-
1660+ /*****************************************************************************/
1661+
1662+ enum {
1663+@@ -161,6 +159,8 @@ create_dm_cmd_line (const char *iface,
1664+ const char *dm_binary;
1665+ const NMPlatformIP4Address *listen_address;
1666+ guint i, n;
1667++ char *confdir = NULL;
1668++ char *confdir_arg = NULL;
1669+
1670+ listen_address = nm_ip4_config_get_first_address (ip4_config);
1671+ g_return_val_if_fail (listen_address, NULL);
1672+@@ -254,10 +254,16 @@ create_dm_cmd_line (const char *iface,
1673+ nm_cmd_line_add_string (cmd, s->str);
1674+ g_string_truncate (s, 0);
1675+
1676++ confdir = g_strdup_printf("%s/dnsmasq-shared.d", nm_utils_get_conf_dir());
1677++
1678+ /* dnsmasq exits if the conf dir is not present */
1679+- if (g_file_test (CONFDIR, G_FILE_TEST_IS_DIR))
1680+- nm_cmd_line_add_string (cmd, "--conf-dir=" CONFDIR);
1681++ if (g_file_test (confdir, G_FILE_TEST_IS_DIR)) {
1682++ confdir_arg = g_strdup_printf("--conf-dir=%s", confdir);
1683++ nm_cmd_line_add_string (cmd, confdir_arg);
1684++ }
1685+
1686++ g_free (confdir);
1687++ g_free (confdir_arg);
1688+ return cmd;
1689+ }
1690+
1691+@@ -381,7 +387,7 @@ nm_dnsmasq_manager_new (const char *ifac
1692+
1693+ priv = NM_DNSMASQ_MANAGER_GET_PRIVATE (manager);
1694+ priv->iface = g_strdup (iface);
1695+- priv->pidfile = g_strdup_printf (RUNSTATEDIR "/nm-dnsmasq-%s.pid", iface);
1696++ priv->pidfile = g_strdup_printf ("%s/nm-dnsmasq-%s.pid", nm_utils_get_run_dir(), iface);
1697+
1698+ return manager;
1699+ }
1700+Index: nm/src/nm-config.h
1701+===================================================================
1702+--- nm.orig/src/nm-config.h
1703++++ nm/src/nm-config.h
1704+@@ -197,8 +197,6 @@ extern char *_nm_config_match_env;
1705+
1706+ /*****************************************************************************/
1707+
1708+-#define NM_CONFIG_DEVICE_STATE_DIR ""NMRUNDIR"/devices"
1709+-
1710+ #define NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT_BOOL (nm_streq (""NM_CONFIG_DEFAULT_MAIN_AUTH_POLKIT, "true"))
1711+ #define NM_CONFIG_DEFAULT_LOGGING_AUDIT_BOOL (nm_streq (""NM_CONFIG_DEFAULT_LOGGING_AUDIT, "true"))
1712+
1713+Index: nm/src/dns/nm-dns-manager.c
1714+===================================================================
1715+--- nm.orig/src/dns/nm-dns-manager.c
1716++++ nm/src/dns/nm-dns-manager.c
1717+@@ -623,8 +623,6 @@ _read_link_cached (const char *path, gbo
1718+ return (*cached = g_file_read_link (path, NULL));
1719+ }
1720+
1721+-#define MY_RESOLV_CONF NMRUNDIR "/resolv.conf"
1722+-#define MY_RESOLV_CONF_TMP MY_RESOLV_CONF ".tmp"
1723+ #define RESOLV_CONF_TMP "/etc/.resolv.conf.NetworkManager"
1724+
1725+ static SpawnResult
1726+@@ -644,6 +642,11 @@ update_resolv_conf (NMDnsManager *self,
1727+ nm_auto_free char *rc_path_real = NULL;
1728+ gboolean resconf_link_cached = FALSE;
1729+ gs_free char *resconf_link = NULL;
1730++ gs_free char *my_resolv_conf = NULL;
1731++ gs_free char *my_resolv_conf_tmp = NULL;
1732++
1733++ my_resolv_conf = g_strdup_printf ("%s/resolv.conf", nm_utils_get_run_dir ());
1734++ my_resolv_conf_tmp = g_strdup_printf ("%s.tmp", my_resolv_conf);
1735+
1736+ /* If we are not managing /etc/resolv.conf and it points to
1737+ * MY_RESOLV_CONF, don't write the private DNS configuration to
1738+@@ -654,9 +657,9 @@ update_resolv_conf (NMDnsManager *self,
1739+ * internal resolv.conf file. */
1740+ if (rc_manager == NM_DNS_MANAGER_RESOLV_CONF_MAN_UNMANAGED) {
1741+ if (nm_streq0 (_read_link_cached (_PATH_RESCONF, &resconf_link_cached, &resconf_link),
1742+- MY_RESOLV_CONF)) {
1743+- _LOGD ("update-resolv-conf: not updating " _PATH_RESCONF
1744+- " since it points to " MY_RESOLV_CONF);
1745++ my_resolv_conf)) {
1746++ _LOGD ("update-resolv-conf: not updating %s since it points to %s",
1747++ _PATH_RESCONF, my_resolv_conf);
1748+ return SR_SUCCESS;
1749+ }
1750+ }
1751+@@ -689,16 +692,16 @@ update_resolv_conf (NMDnsManager *self,
1752+ }
1753+ }
1754+
1755+- if ((f = fopen (MY_RESOLV_CONF_TMP, "we")) == NULL) {
1756++ if ((f = fopen (my_resolv_conf_tmp, "we")) == NULL) {
1757+ errsv = errno;
1758+ g_set_error (error,
1759+ NM_MANAGER_ERROR,
1760+ NM_MANAGER_ERROR_FAILED,
1761+ "Could not open %s: %s",
1762+- MY_RESOLV_CONF_TMP,
1763++ my_resolv_conf_tmp,
1764+ g_strerror (errsv));
1765+ _LOGT ("update-resolv-conf: open temporary file %s failed (%s)",
1766+- MY_RESOLV_CONF_TMP, g_strerror (errsv));
1767++ my_resolv_conf_tmp, g_strerror (errsv));
1768+ return SR_ERROR;
1769+ }
1770+
1771+@@ -706,7 +709,7 @@ update_resolv_conf (NMDnsManager *self,
1772+ if (!success) {
1773+ errsv = errno;
1774+ _LOGT ("update-resolv-conf: write temporary file %s failed (%s)",
1775+- MY_RESOLV_CONF_TMP, g_strerror (errsv));
1776++ my_resolv_conf_tmp, g_strerror (errsv));
1777+ }
1778+
1779+ if (fclose (f) < 0) {
1780+@@ -719,25 +722,25 @@ update_resolv_conf (NMDnsManager *self,
1781+ NM_MANAGER_ERROR,
1782+ NM_MANAGER_ERROR_FAILED,
1783+ "Could not close %s: %s",
1784+- MY_RESOLV_CONF_TMP,
1785++ my_resolv_conf_tmp,
1786+ g_strerror (errsv));
1787+ _LOGT ("update-resolv-conf: close temporary file %s failed (%s)",
1788+- MY_RESOLV_CONF_TMP, g_strerror (errsv));
1789++ my_resolv_conf_tmp, g_strerror (errsv));
1790+ }
1791+ return SR_ERROR;
1792+ } else if (!success)
1793+ return SR_ERROR;
1794+
1795+- if (rename (MY_RESOLV_CONF_TMP, MY_RESOLV_CONF) < 0) {
1796++ if (rename (my_resolv_conf_tmp, my_resolv_conf) < 0) {
1797+ errsv = errno;
1798+ g_set_error (error,
1799+ NM_MANAGER_ERROR,
1800+ NM_MANAGER_ERROR_FAILED,
1801+ "Could not replace %s: %s",
1802+- MY_RESOLV_CONF,
1803++ my_resolv_conf,
1804+ g_strerror (errno));
1805+ _LOGT ("update-resolv-conf: failed to rename temporary file %s to %s (%s)",
1806+- MY_RESOLV_CONF_TMP, MY_RESOLV_CONF, g_strerror (errsv));
1807++ my_resolv_conf_tmp, my_resolv_conf, g_strerror (errsv));
1808+ return SR_ERROR;
1809+ }
1810+
1811+@@ -749,14 +752,14 @@ update_resolv_conf (NMDnsManager *self,
1812+
1813+ if ( rc_manager != NM_DNS_MANAGER_RESOLV_CONF_MAN_SYMLINK
1814+ || !_read_link_cached (_PATH_RESCONF, &resconf_link_cached, &resconf_link)) {
1815+- _LOGT ("update-resolv-conf: write internal file %s succeeded", MY_RESOLV_CONF);
1816++ _LOGT ("update-resolv-conf: write internal file %s succeeded", my_resolv_conf);
1817+ return SR_SUCCESS;
1818+ }
1819+
1820+ if (!nm_streq0 (_read_link_cached (_PATH_RESCONF, &resconf_link_cached, &resconf_link),
1821+- MY_RESOLV_CONF)) {
1822++ my_resolv_conf)) {
1823+ _LOGT ("update-resolv-conf: write internal file %s succeeded (don't touch symlink %s linking to %s)",
1824+- MY_RESOLV_CONF, _PATH_RESCONF,
1825++ my_resolv_conf, _PATH_RESCONF,
1826+ _read_link_cached (_PATH_RESCONF, &resconf_link_cached, &resconf_link));
1827+ return SR_SUCCESS;
1828+ }
1829+@@ -775,22 +778,22 @@ update_resolv_conf (NMDnsManager *self,
1830+ g_strerror (errsv));
1831+ _LOGT ("update-resolv-conf: write internal file %s succeeded "
1832+ "but canot delete temporary file %s: %s",
1833+- MY_RESOLV_CONF, RESOLV_CONF_TMP, g_strerror (errsv));
1834++ my_resolv_conf, RESOLV_CONF_TMP, g_strerror (errsv));
1835+ return SR_ERROR;
1836+ }
1837+
1838+- if (symlink (MY_RESOLV_CONF, RESOLV_CONF_TMP) == -1) {
1839++ if (symlink (my_resolv_conf, RESOLV_CONF_TMP) == -1) {
1840+ errsv = errno;
1841+ g_set_error (error,
1842+ NM_MANAGER_ERROR,
1843+ NM_MANAGER_ERROR_FAILED,
1844+ "Could not create symlink %s pointing to %s: %s",
1845+ RESOLV_CONF_TMP,
1846+- MY_RESOLV_CONF,
1847++ my_resolv_conf,
1848+ g_strerror (errsv));
1849+ _LOGT ("update-resolv-conf: write internal file %s succeeded "
1850+ "but failed to symlink %s: %s",
1851+- MY_RESOLV_CONF, RESOLV_CONF_TMP, g_strerror (errsv));
1852++ my_resolv_conf, RESOLV_CONF_TMP, g_strerror (errsv));
1853+ return SR_ERROR;
1854+ }
1855+
1856+@@ -805,12 +808,12 @@ update_resolv_conf (NMDnsManager *self,
1857+ g_strerror (errsv));
1858+ _LOGT ("update-resolv-conf: write internal file %s succeeded "
1859+ "but failed to rename temporary symlink %s to %s: %s",
1860+- MY_RESOLV_CONF, RESOLV_CONF_TMP, _PATH_RESCONF, g_strerror (errsv));
1861++ my_resolv_conf, RESOLV_CONF_TMP, _PATH_RESCONF, g_strerror (errsv));
1862+ return SR_ERROR;
1863+ }
1864+
1865+ _LOGT ("update-resolv-conf: write internal file %s succeeded and update symlink %s",
1866+- MY_RESOLV_CONF, _PATH_RESCONF);
1867++ my_resolv_conf, _PATH_RESCONF);
1868+ return SR_SUCCESS;
1869+ }
1870+
1871+@@ -1660,6 +1663,8 @@ again:
1872+ _clear_plugin (self);
1873+ priv->plugin = nm_dns_systemd_resolved_new ();
1874+ plugin_changed = TRUE;
1875++
1876++ _LOGI ("init: plugin_changed: systemd-resolvd");
1877+ }
1878+ mode = "systemd-resolved";
1879+ } else if (nm_streq0 (mode, "dnsmasq")) {
1880diff --git a/debian/patches/disable-libnm-glib-test-devices-array.patch b/debian/patches/disable-libnm-glib-test-devices-array.patch
1881new file mode 100644
1882index 0000000..e847fc5
1883--- /dev/null
1884+++ b/debian/patches/disable-libnm-glib-test-devices-array.patch
1885@@ -0,0 +1,13 @@
1886+Index: nm/libnm-glib/tests/test-nm-client.c
1887+===================================================================
1888+--- nm.orig/libnm-glib/tests/test-nm-client.c
1889++++ nm/libnm-glib/tests/test-nm-client.c
1890+@@ -1135,7 +1135,7 @@ main (int argc, char **argv)
1891+ g_test_add_func ("/libnm-glib/device-added", test_device_added);
1892+ g_test_add_func ("/libnm-glib/wifi-ap-added-removed", test_wifi_ap_added_removed);
1893+ g_test_add_func ("/libnm-glib/wimax-nsp-added-removed", test_wimax_nsp_added_removed);
1894+- g_test_add_func ("/libnm-glib/devices-array", test_devices_array);
1895++ /* g_test_add_func ("/libnm-glib/devices-array", test_devices_array); */
1896+ g_test_add_func ("/libnm-glib/client-manager-running", test_client_manager_running);
1897+ g_test_add_func ("/libnm/connection/invalid", test_connection_invalid);
1898+
1899diff --git a/debian/patches/disable-libnm-glib-wifi-ap-test.patch b/debian/patches/disable-libnm-glib-wifi-ap-test.patch
1900new file mode 100644
1901index 0000000..171b6f1
1902--- /dev/null
1903+++ b/debian/patches/disable-libnm-glib-wifi-ap-test.patch
1904@@ -0,0 +1,13 @@
1905+Index: build/libnm-glib/tests/test-nm-client.c
1906+===================================================================
1907+--- build.orig/libnm-glib/tests/test-nm-client.c
1908++++ build/libnm-glib/tests/test-nm-client.c
1909+@@ -1133,7 +1133,7 @@ main (int argc, char **argv)
1910+ loop = g_main_loop_new (NULL, FALSE);
1911+
1912+ g_test_add_func ("/libnm-glib/device-added", test_device_added);
1913+- g_test_add_func ("/libnm-glib/wifi-ap-added-removed", test_wifi_ap_added_removed);
1914++ /* g_test_add_func ("/libnm-glib/wifi-ap-added-removed", test_wifi_ap_added_removed); */
1915+ g_test_add_func ("/libnm-glib/wimax-nsp-added-removed", test_wimax_nsp_added_removed);
1916+ g_test_add_func ("/libnm-glib/devices-array", test_devices_array);
1917+ g_test_add_func ("/libnm-glib/client-manager-running", test_client_manager_running);
1918diff --git a/debian/patches/disable-link-bond-test.patch b/debian/patches/disable-link-bond-test.patch
1919new file mode 100644
1920index 0000000..e3237d8
1921--- /dev/null
1922+++ b/debian/patches/disable-link-bond-test.patch
1923@@ -0,0 +1,14 @@
1924+Index: build/src/platform/tests/test-link.c
1925+===================================================================
1926+--- build.orig/src/platform/tests/test-link.c
1927++++ build/src/platform/tests/test-link.c
1928+@@ -475,7 +475,8 @@ test_bond (void)
1929+ return;
1930+ }
1931+
1932+- test_software (NM_LINK_TYPE_BOND, "bond");
1933++ g_test_skip ("Skipping test for bonding...");
1934++ /* test_software (NM_LINK_TYPE_BOND, "bond"); */
1935+ }
1936+
1937+ static void
1938diff --git a/debian/patches/disable-link-team-test.patch b/debian/patches/disable-link-team-test.patch
1939new file mode 100644
1940index 0000000..775c086
1941--- /dev/null
1942+++ b/debian/patches/disable-link-team-test.patch
1943@@ -0,0 +1,14 @@
1944+Index: build/src/platform/tests/test-link.c
1945+===================================================================
1946+--- build.orig/src/platform/tests/test-link.c
1947++++ build/src/platform/tests/test-link.c
1948+@@ -482,7 +482,8 @@ test_bond (void)
1949+ static void
1950+ test_team (void)
1951+ {
1952+- test_software (NM_LINK_TYPE_TEAM, "team");
1953++ g_test_skip ("Skipping test for teaming...");
1954++ /* test_software (NM_LINK_TYPE_TEAM, "team"); */
1955+ }
1956+
1957+ static void
1958diff --git a/debian/patches/series b/debian/patches/series
1959index faca637..0366f7e 100644
1960--- a/debian/patches/series
1961+++ b/debian/patches/series
1962@@ -11,3 +11,9 @@ libnm-Check-self-still-NMManager-or-not.patch
1963 #dns-manager-don-t-merge-split-DNS-search-domains.patch
1964 Read-system-connections-from-run.patch
1965 e91f1a7d2a6b8400b6b331d5b72287dcb5164a39.patch
1966+Support-for-WoWLAN.patch
1967+disable-link-bond-test.patch
1968+disable-libnm-glib-wifi-ap-test.patch
1969+disable-link-team-test.patch
1970+disable-libnm-glib-test-devices-array.patch
1971+add-snap-support.patch
1972diff --git a/hooks/configure b/hooks/configure
1973new file mode 100755
1974index 0000000..4f0fe5b
1975--- /dev/null
1976+++ b/hooks/configure
1977@@ -0,0 +1,62 @@
1978+#!/bin/sh -ex
1979+# Copyright (C) 2016-2018 Canonical Ltd
1980+#
1981+# This program is free software; you can redistribute it and/or modify
1982+# it under the terms of the GNU General Public License as published by
1983+# the Free Software Foundation; either version 2 of the License, or
1984+# (at your option) any later version.
1985+#
1986+# This program is distributed in the hope that it will be useful,
1987+# but WITHOUT ANY WARRANTY; without even the implied warranty of
1988+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1989+# GNU General Public License for more details.
1990+#
1991+# You should have received a copy of the GNU General Public License
1992+# along with this program. If not, see <http://www.gnu.org/licenses/>.
1993+
1994+# Configure hook has two missions:
1995+# 1. Set properties defaults on installation, so users can see them
1996+# 2. Re-start daemon if a property has changed
1997+
1998+. "$SNAP"/bin/snap-prop.sh
1999+
2000+props_file="$SNAP_DATA"/current_snap_props
2001+
2002+_create_props_content() {
2003+ printf "wifi_powersave=%s\n" "$wifi_powersave"
2004+ printf "wifi_wake_on_wlan=%s\n" "$wifi_wake_on_wlan"
2005+ printf "wifi_wake_on_password=%s\n" "$wifi_wake_on_password"
2006+ printf "ethernet_enable=%s\n" "$ethernet_enable"
2007+ printf "debug_enable=%s\n" "$debug_enable"
2008+}
2009+
2010+wifi_powersave=$(get_wifi_powersave)
2011+wifi_wake_on_wlan=$(get_wifi_wake_on_wlan)
2012+wifi_wake_on_password=$(get_wifi_wake_on_password)
2013+ethernet_enable=$(get_ethernet_enable)
2014+debug_enable=$(get_debug_enable)
2015+
2016+# Store always, so we show defaults when properties are set to empty strings
2017+snapctl set wifi.powersave="$wifi_powersave"
2018+snapctl set wifi.wake-on-wlan="$wifi_wake_on_wlan"
2019+snapctl set wifi.wake-on-wlan-password="$wifi_wake_on_password"
2020+snapctl set ethernet.enable="$ethernet_enable"
2021+snapctl set debug.enable="$debug_enable"
2022+
2023+content=$(_create_props_content)
2024+
2025+if [ ! -e "$props_file" ]; then
2026+ # Installation or refresh from old snap. Assign defaults.
2027+ echo "$content" > "$props_file"
2028+ return 0
2029+fi
2030+
2031+old_content=$(cat "$props_file")
2032+if [ "$content" = "$old_content" ]; then
2033+ # No change in properties, this must be a snap refresh
2034+ return 0
2035+fi
2036+
2037+# Some property changed, store new values and re-start daemon to apply changes
2038+echo "$content" > "$props_file"
2039+snapctl restart "$SNAP_NAME"
2040diff --git a/snap-common/bin/dhcp-lease-mover b/snap-common/bin/dhcp-lease-mover
2041new file mode 100755
2042index 0000000..c54aeb0
2043--- /dev/null
2044+++ b/snap-common/bin/dhcp-lease-mover
2045@@ -0,0 +1,26 @@
2046+#!/bin/sh
2047+set -x
2048+
2049+lease_path=$SNAP_DATA/state/dhcp
2050+public_lease_path=/run/NetworkManager/dhcp/
2051+
2052+if [ ! -e $public_lease_path ] ; then
2053+ mkdir -p $public_lease_path
2054+fi
2055+
2056+if [ ! -e $lease_path ] ; then
2057+ mkdir -p $lease_path
2058+fi
2059+
2060+# Copy all leases when we start to make sure we're in sync
2061+rm -f $public_lease_path/*
2062+cp $lease_path/* $public_lease_path
2063+
2064+# Now we wait until a lease changes, gets added or removed and when
2065+# that happened we simply just move all leases files into the public
2066+# location.
2067+while $SNAP/usr/bin/inotifywait -e create,modify,delete,move $lease_path ; do
2068+ sleep 1
2069+ rm -f $public_lease_path/*
2070+ cp $lease_path/* $public_lease_path
2071+done
2072diff --git a/snap-common/bin/networkmanager b/snap-common/bin/networkmanager
2073new file mode 100755
2074index 0000000..bec5f63
2075--- /dev/null
2076+++ b/snap-common/bin/networkmanager
2077@@ -0,0 +1,110 @@
2078+#!/bin/sh
2079+# Copyright (C) 2016-2018 Canonical Ltd
2080+#
2081+# This program is free software; you can redistribute it and/or modify
2082+# it under the terms of the GNU General Public License as published by
2083+# the Free Software Foundation; either version 2 of the License, or
2084+# (at your option) any later version.
2085+#
2086+# This program is distributed in the hope that it will be useful,
2087+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2088+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2089+# GNU General Public License for more details.
2090+#
2091+# You should have received a copy of the GNU General Public License
2092+# along with this program. If not, see <http://www.gnu.org/licenses/>.
2093+set -ex
2094+
2095+# Create all necessary directories we need at runtime
2096+mkdir -p "$SNAP_DATA"/conf/system-connections
2097+mkdir -p "$SNAP_DATA"/run
2098+
2099+# Create DHCP lease directory
2100+mkdir -p /run/NetworkManager/dhcp
2101+
2102+# A directory where users can place any additional configuration
2103+# files for NetworkManager
2104+mkdir -p "$SNAP_DATA"/conf.d
2105+
2106+# State dir where network-manager stores several things like the
2107+# secret key used for IPv6
2108+mkdir -p "$SNAP_DATA"/state
2109+mkdir -p "$SNAP_DATA"/state/dhcp
2110+
2111+# Apply current snapctl settings
2112+. "$SNAP"/bin/snap-config.sh
2113+apply_snap_config
2114+
2115+# Select which config we're going to use. We offer our users
2116+# to provide their own configuration file in $SNAP_DATA but
2117+# will fallback if no one exists to the default one we ship
2118+# in $SNAP
2119+NM_CONF=$SNAP/etc/NetworkManager/NetworkManager.conf
2120+if [ -e "$SNAP_DATA"/NetworkManager.conf ]; then
2121+ NM_CONF=$SNAP_DATA/NetworkManager.conf
2122+fi
2123+
2124+# If netplan is not configured to render by default to NetworkManager
2125+# configuration files we disable management of any ethernet device
2126+# as this will clash with any configuration netplan puts in place
2127+# for networkd.
2128+if [ ! -e "/etc/netplan/00-default-nm-renderer.yaml" ] ; then
2129+ if [ ! -e "$SNAP_DATA"/conf.d/disable-ethernet.conf ] ; then
2130+ echo "[keyfile]" > "$SNAP_DATA"/conf.d/disable-ethernet.conf
2131+ echo "unmanaged-devices+=interface-name:eth*,interface-name:enx*" >> \
2132+ "$SNAP_DATA"/conf.d/disable-ethernet.conf
2133+ fi
2134+else
2135+ # Enable ethernet management again if the user switched the netplan
2136+ # backend and wants us to manage ethernet
2137+ if [ -e "$SNAP_DATA"/conf.d/disable-ethernet.conf ] ; then
2138+ rm -f "$SNAP_DATA"/conf.d/disable-ethernet.conf
2139+ fi
2140+
2141+ # If the snapd configuration for netplan is not present or empty
2142+ # we will start managing all ethernet ports automatically. Because
2143+ # of that we need to remove any previously created configuration files
2144+ # which prevented us from doing that.
2145+ if [ ! -e /etc/netplan/00-snapd-config.yaml ] ||
2146+ [ -s /etc/netplan/00-snapd-config.yaml ] ; then
2147+ rm -f "$SNAP_DATA"/conf.d/no-auto-default-ethernet.conf
2148+ else
2149+ if [ ! -e "$SNAP_DATA"/conf.d/no-auto-default-ethernet.conf ] ; then
2150+ # If we're running as the only network management service
2151+ # and are configured via netplan on first boot then we should
2152+ # not try to auto configure ethernet ports as this is up to
2153+ # netplan and will be the same for networkd.
2154+ echo "[main]" > "$SNAP_DATA"/conf.d/no-auto-default-ethernet.conf
2155+ echo "no-auto-default=interface-name:eth*,interface-name:enx*" >> \
2156+ "$SNAP_DATA"/conf.d/no-auto-default-ethernet.conf
2157+ fi
2158+ fi
2159+fi
2160+
2161+# HACK: Until we've fixed probert to look in $SNAP_DATA/state/dhcp or
2162+# somewhere else for our lease files we use inotifywatch to monitor
2163+# our lease files and copy all over when something has changed. This
2164+# background process gets stopped when our systemd service unit gets
2165+# stopped.
2166+"$SNAP"/bin/dhcp-lease-mover &
2167+
2168+# Identify if we are in debug mode or not
2169+LOG_LEVEL=INFO
2170+if [ -f "$SNAP_DATA"/.debug_enabled ]; then
2171+ LOG_LEVEL=DEBUG
2172+fi
2173+
2174+# Run available startup hooks to have a point to store custom
2175+# logic outside of this script. More of the things from above
2176+# should be moved into these.
2177+for hook in "$SNAP"/startup-hooks/* ; do
2178+ [ -x "$hook" ] && /bin/sh -x "$hook"
2179+done
2180+
2181+export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SNAP/usr/lib/NetworkManager
2182+
2183+exec "$SNAP"/usr/sbin/NetworkManager \
2184+ --config-dir="$SNAP_DATA"/conf.d/ \
2185+ --config="$NM_CONF" \
2186+ --log-level="$LOG_LEVEL" \
2187+ --no-daemon
2188diff --git a/snap-common/bin/nmcli-internal b/snap-common/bin/nmcli-internal
2189new file mode 100755
2190index 0000000..c4986b7
2191--- /dev/null
2192+++ b/snap-common/bin/nmcli-internal
2193@@ -0,0 +1,7 @@
2194+#!/bin/sh
2195+# This file is for internal use from hooks only
2196+export PATH="$SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH"
2197+export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$SNAP/usr/lib:$SNAP/usr/lib/x86_64-linux-gnu"
2198+export LD_LIBRARY_PATH="$SNAP/usr/lib:$SNAP/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH"
2199+export LD_LIBRARY_PATH=$SNAP_LIBRARY_PATH:$LD_LIBRARY_PATH
2200+exec "$SNAP/usr/bin/nmcli" "$@"
2201diff --git a/snap-common/bin/snap-config.sh b/snap-common/bin/snap-config.sh
2202new file mode 100644
2203index 0000000..3d0b3b9
2204--- /dev/null
2205+++ b/snap-common/bin/snap-config.sh
2206@@ -0,0 +1,159 @@
2207+#!/bin/sh -ex
2208+# Copyright (C) 2016-2018 Canonical Ltd
2209+#
2210+# This program is free software; you can redistribute it and/or modify
2211+# it under the terms of the GNU General Public License as published by
2212+# the Free Software Foundation; either version 2 of the License, or
2213+# (at your option) any later version.
2214+#
2215+# This program is distributed in the hope that it will be useful,
2216+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2217+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2218+# GNU General Public License for more details.
2219+#
2220+# You should have received a copy of the GNU General Public License
2221+# along with this program. If not, see <http://www.gnu.org/licenses/>.
2222+
2223+# Functions to apply snap settings
2224+
2225+# Replace content of file if current content is different
2226+# $1: file
2227+# $2: new content
2228+_replace_file_if_diff() {
2229+ old_content=
2230+ if [ -e "$1" ]; then
2231+ old_content=$(cat "$1")
2232+ fi
2233+ if [ "$2" != "$old_content" ]; then
2234+ echo "Replacing $1"
2235+ echo "$2" > "$1"
2236+ fi
2237+}
2238+
2239+# Disable wifi powersave
2240+# $1: enabled/disabled literal string
2241+_switch_wifi_powersave() {
2242+ path=$SNAP_DATA/conf.d/wifi-powersave.conf
2243+ # See https://developer.gnome.org/libnm/stable/NMSettingWireless.html#NMSettingWirelessPowersave
2244+ # for the meaning of the different values for the wifi.powersave option.
2245+ case $1 in
2246+ enabled)
2247+ content=$(printf "[connection]\nwifi.powersave = 3")
2248+ ;;
2249+ disabled)
2250+ content=$(printf "[connection]\nwifi.powersave = 2")
2251+ ;;
2252+ *)
2253+ echo "WARNING: invalid value '$1' supplied for wifi.powersave configuration option"
2254+ exit 1
2255+ ;;
2256+ esac
2257+ _replace_file_if_diff "$path" "$content"
2258+}
2259+
2260+# Set WoWLAN configuration
2261+# $1: disabled/any/disconnect/magic/gtk-rekey-failure/eap-identity-request/
2262+# 4way-handshake/rfkill-release/tcp literal string. They
2263+# correspond to the enum NMSettingWirelessWakeOnWLan defined
2264+# in libnm-core. NetworkManager only allows us to set integer
2265+# values here. This still needs to be upstreamed: see
2266+# https://mail.gnome.org/archives/networkmanager-list/2017-January/thread.html
2267+# $2: WoWLAN activation password
2268+_switch_wifi_wake_on_wlan() {
2269+ value=0
2270+ case "$1" in
2271+ disabled)
2272+ value=0
2273+ ;;
2274+ any)
2275+ value=2
2276+ ;;
2277+ disconnect)
2278+ value=4
2279+ ;;
2280+ magic)
2281+ value=8
2282+ ;;
2283+ gtk-rekey-failure)
2284+ value=16
2285+ ;;
2286+ eap-identity-request)
2287+ value=32
2288+ ;;
2289+ 4way-handshake)
2290+ value=64
2291+ ;;
2292+ rfkill-release)
2293+ value=128
2294+ ;;
2295+ tcp)
2296+ value=256
2297+ ;;
2298+ *)
2299+ echo "ERROR: Invalid value provided for wifi.wake-on-wlan"
2300+ exit 1
2301+ ;;
2302+ esac
2303+ password=$2
2304+ path=$SNAP_DATA/conf.d/wifi-wowlan.conf
2305+
2306+ content=$(printf "[connection]")
2307+ # If we don't get a value provided there is not one set in the snap
2308+ # configuration and we can simply leave it out here and let
2309+ # NetworkManager take its default one.
2310+ if [ -n "$value" ]; then
2311+ content=$(printf "%s\nwifi.wake-on-wlan=%s" "$content" "$value")
2312+ fi
2313+ if [ -n "$password" ]; then
2314+ content=$(printf "%s\nwifi.wake-on-wlan-password=%s" "$content" "$password")
2315+ fi
2316+
2317+ _replace_file_if_diff "$path" "$content"
2318+}
2319+
2320+# Change netplan renderer to NM
2321+# $1: true/false literal string
2322+_switch_ethernet() {
2323+ path=/etc/netplan/00-default-nm-renderer.yaml
2324+ case "$1" in
2325+ true)
2326+ content=$(printf "network:\n renderer: NetworkManager")
2327+ _replace_file_if_diff "$path" "$content"
2328+ ;;
2329+ false)
2330+ rm -f "$path"
2331+ ;;
2332+ *)
2333+ echo "ERROR: Invalid value provided for ethernet"
2334+ exit 1
2335+ esac
2336+}
2337+
2338+# Enable debug mode
2339+# $1: true/false literal string
2340+_switch_debug_enable() {
2341+ DEBUG_FILE=$SNAP_DATA/.debug_enabled
2342+ # $1 true/false for enabling/disabling debug log level in nm
2343+ # We create/remove the file for future executions and also change
2344+ # the logging level of the running daemon.
2345+ if [ "$1" = "true" ]; then
2346+ if [ ! -f "$DEBUG_FILE" ]; then
2347+ touch "$DEBUG_FILE"
2348+ "$SNAP"/bin/nmcli-internal g log level DEBUG
2349+ fi
2350+ else
2351+ if [ -f "$DEBUG_FILE" ]; then
2352+ rm -f "$DEBUG_FILE"
2353+ "$SNAP"/bin/nmcli-internal g log level INFO
2354+ fi
2355+ fi
2356+}
2357+
2358+. "$SNAP"/bin/snap-prop.sh
2359+
2360+apply_snap_config() {
2361+ _switch_wifi_powersave "$(get_wifi_powersave)"
2362+ _switch_wifi_wake_on_wlan "$(get_wifi_wake_on_wlan)" "$(get_wifi_wake_on_password)"
2363+ _switch_ethernet "$(get_ethernet_enable)"
2364+ _switch_debug_enable "$(get_debug_enable)"
2365+}
2366diff --git a/snap-common/bin/snap-prop.sh b/snap-common/bin/snap-prop.sh
2367new file mode 100644
2368index 0000000..8ac560a
2369--- /dev/null
2370+++ b/snap-common/bin/snap-prop.sh
2371@@ -0,0 +1,60 @@
2372+#!/bin/sh -ex
2373+# Copyright (C) 2016-2018 Canonical Ltd
2374+#
2375+# This program is free software; you can redistribute it and/or modify
2376+# it under the terms of the GNU General Public License as published by
2377+# the Free Software Foundation; either version 2 of the License, or
2378+# (at your option) any later version.
2379+#
2380+# This program is distributed in the hope that it will be useful,
2381+# but WITHOUT ANY WARRANTY; without even the implied warranty of
2382+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2383+# GNU General Public License for more details.
2384+#
2385+# You should have received a copy of the GNU General Public License
2386+# along with this program. If not, see <http://www.gnu.org/licenses/>.
2387+
2388+# Getters for snap properties. They write the current value to stdout.
2389+
2390+get_wifi_powersave() {
2391+ value=$(snapctl get wifi.powersave)
2392+ if [ -z "$value" ]; then
2393+ value=disabled
2394+ fi
2395+ echo "$value"
2396+}
2397+
2398+get_wifi_wake_on_wlan() {
2399+ value=$(snapctl get wifi.wake-on-wlan)
2400+ if [ -z "$value" ]; then
2401+ value=disabled
2402+ fi
2403+ echo "$value"
2404+}
2405+
2406+get_wifi_wake_on_password() {
2407+ snapctl get wifi.wake-on-wlan-password
2408+}
2409+
2410+get_ethernet_enable() {
2411+ value=$(snapctl get ethernet.enable)
2412+ if [ -z "$value" ]; then
2413+ # If this file was already present, assume NM is wanted to handle
2414+ # ethernet in the device. Ideally this should be handled by setting
2415+ # NM's ethernet.enable property in the gadget snap though.
2416+ if [ -e /etc/netplan/00-default-nm-renderer.yaml ]; then
2417+ value=true
2418+ else
2419+ value=false
2420+ fi
2421+ fi
2422+ echo "$value"
2423+}
2424+
2425+get_debug_enable() {
2426+ value=$(snapctl get debug.enable)
2427+ if [ -z "$value" ]; then
2428+ value=false
2429+ fi
2430+ echo "$value"
2431+}
2432diff --git a/snap-common/etc/NetworkManager/NetworkManager.conf b/snap-common/etc/NetworkManager/NetworkManager.conf
2433new file mode 100644
2434index 0000000..e332099
2435--- /dev/null
2436+++ b/snap-common/etc/NetworkManager/NetworkManager.conf
2437@@ -0,0 +1,14 @@
2438+[main]
2439+plugins=ifupdown,keyfile
2440+# Not using dnsmasq yet. Need to get it properly integrated
2441+# into the snap or reuse the one shiped with the OS snap.
2442+dns=systemd-resolved
2443+
2444+
2445+# Use internal DHCP stack which is based on the systemd
2446+# implementation and is enough for our purpose until we
2447+# need something more complex.
2448+dhcp=internal
2449+
2450+[ifupdown]
2451+managed=false
2452diff --git a/snap-common/startup-hooks/99-wol-by-default.sh b/snap-common/startup-hooks/99-wol-by-default.sh
2453new file mode 100755
2454index 0000000..c2d4480
2455--- /dev/null
2456+++ b/snap-common/startup-hooks/99-wol-by-default.sh
2457@@ -0,0 +1,13 @@
2458+#!/bin/sh
2459+
2460+# Enable wake-on-lan by default until we have a configuration
2461+# hook to do that.
2462+if [ ! -e $SNAP_DATA/conf.d/enable-wol.conf ] ; then
2463+ mkdir -p $SNAP_DATA/conf.d
2464+ cat <<-EOF > $SNAP_DATA/conf.d/enable-wol.conf
2465+ [connection]
2466+ # Value 64 maps to the 'magic' setting; see man nm-settings
2467+ # for more information.
2468+ 802-3-ethernet.wake-on-lan=64
2469+ EOF
2470+fi
2471diff --git a/snap-common/usr/share/doc/network-manager/copyright b/snap-common/usr/share/doc/network-manager/copyright
2472new file mode 100644
2473index 0000000..71d773a
2474--- /dev/null
2475+++ b/snap-common/usr/share/doc/network-manager/copyright
2476@@ -0,0 +1,74 @@
2477+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
2478+Upstream-Name: NetworkManager
2479+Source: http://ftp.gnome.org/pub/GNOME/sources/NetworkManager/
2480+
2481+Files: *
2482+Copyright: 2004 - 2014 Red Hat, Inc.
2483+ 2005 - 2009 Novell, Inc.
2484+License: GPL-2+
2485+
2486+Files: libnm-util/*
2487+ libnm-glib/*
2488+ libnm-core/*
2489+ libnm/*
2490+Copyright: 2005 - 2014 Red Hat, Inc.
2491+ 2005 - 2009 Novell, Inc.
2492+License: LGPL-2+
2493+
2494+Files: src/systemd/*
2495+Copyright: 2013 - 2015 Tom Gundersen
2496+ 2014 Susant Sahani
2497+ 2014 - 2015 Intel Corporation. All rights reserved.
2498+License: LGPL-2.1+
2499+
2500+License: GPL-2+
2501+ This package is free software; you can redistribute it and/or modify
2502+ it under the terms of the GNU General Public License as published by
2503+ the Free Software Foundation; either version 2 of the License, or
2504+ (at your option) any later version.
2505+ .
2506+ This package is distributed in the hope that it will be useful,
2507+ but WITHOUT ANY WARRANTY; without even the implied warranty of
2508+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2509+ GNU General Public License for more details.
2510+ .
2511+ You should have received a copy of the GNU General Public License
2512+ along with this program. If not, see <http://www.gnu.org/licenses/>
2513+ .
2514+ On Debian systems, the complete text of the GNU General Public
2515+ License version 2 can be found in "/usr/share/common-licenses/GPL-2".
2516+
2517+License: LGPL-2+
2518+ This package is free software; you can redistribute it and/or
2519+ modify it under the terms of the GNU Lesser General Public
2520+ License as published by the Free Software Foundation; either
2521+ version 2 of the License, or (at your option) any later version.
2522+ .
2523+ This package is distributed in the hope that it will be useful,
2524+ but WITHOUT ANY WARRANTY; without even the implied warranty of
2525+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2526+ Lesser General Public License for more details.
2527+ .
2528+ You should have received a copy of the GNU General Public License
2529+ along with this program. If not, see <http://www.gnu.org/licenses/>.
2530+ .
2531+ On Debian systems, the complete text of the GNU Lesser General
2532+ Public License can be found in "/usr/share/common-licenses/LGPL-2".
2533+
2534+License: LGPL-2.1+
2535+ This package is free software; you can redistribute it and/or
2536+ modify it under the terms of the GNU Lesser General Public
2537+ License as published by the Free Software Foundation; either
2538+ version 2.1 of the License, or (at your option) any later version.
2539+ .
2540+ This package is distributed in the hope that it will be useful,
2541+ but WITHOUT ANY WARRANTY; without even the implied warranty of
2542+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2543+ Lesser General Public License for more details.
2544+ .
2545+ You should have received a copy of the GNU General Public License
2546+ along with this program. If not, see <http://www.gnu.org/licenses/>.
2547+ .
2548+ On Debian systems, the complete text of the GNU Lesser General
2549+ Public License can be found in "/usr/share/common-licenses/LGPL-2.1".
2550+
2551diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml
2552new file mode 100644
2553index 0000000..aec7c74
2554--- /dev/null
2555+++ b/snap/snapcraft.yaml
2556@@ -0,0 +1,300 @@
2557+name: network-manager
2558+version: '1.10.6'
2559+version-script: |
2560+ echo $SNAPCRAFT_PROJECT_VERSION-$(date +%Y%m%d)+$(git rev-parse --short HEAD)
2561+summary: Network Manager
2562+description: |
2563+ NetworkManager is a system network service that manages your network
2564+ devices and connections, attempting to keep active network connectivity
2565+ when available. It manages ethernet, WiFi, mobile broadband (WWAN) and
2566+ PPPoE devices, provides VPN integration with a variety of different
2567+ VPN serivces.
2568+ Please find the source code at: https://code.launchpad.net/~network-manager/network-manager/+git/ubuntu/+ref/snap-1.10
2569+base: core18
2570+confinement: strict
2571+grade: stable
2572+
2573+slots:
2574+ service: network-manager
2575+
2576+plugs:
2577+ nmcli: network-manager
2578+ wpa:
2579+ interface: dbus
2580+ bus: system
2581+ name: fi.w1.wpa_supplicant1
2582+
2583+hooks:
2584+ configure:
2585+ plugs:
2586+ - nmcli
2587+ - network-setup-control
2588+apps:
2589+ nmcli:
2590+ command: usr/bin/nmcli
2591+ plugs: [nmcli]
2592+ networkmanager:
2593+ command: bin/networkmanager
2594+ daemon: simple
2595+ slots: [service]
2596+ plugs: [modem-manager, ppp, network-setup-observe, wpa, firewall-control]
2597+ # FIXME: This will create currently a symlink inside /snap/bin
2598+ # which points nowhere as the service isn't exposed as application
2599+ # for the user. Instead snapd needs to gain support to handle
2600+ # aliases for services differently by adding the Alias= option
2601+ # within the systemd unit file instead for example. Until this
2602+ # is implemented we keep the alias disabled.
2603+ #
2604+ # aliases: [NetworkManager]
2605+
2606+parts:
2607+ hooks:
2608+ plugin: dump
2609+ source: hooks
2610+ organize:
2611+ configure: meta/hooks/configure
2612+ networkmanager-common:
2613+ plugin: dump
2614+ source: snap-common
2615+ #
2616+ # TODO: investigate whether this HACK is still needed. The script
2617+ # dhcp-lease-mover relies on inotifywait to determine if any DHCP
2618+ # DHCP leases stored under $SNAP_DATA are created or modified, and
2619+ # if so, it triggers a copy of the files to /run/NetworkManager/dhcp.
2620+ # This is done so that subiquity's hardware probing tool (probert) is
2621+ # able to detect active leases.
2622+ #
2623+ #inotify-tools:
2624+ # plugin: nil
2625+ # stage-packages:
2626+ # - libinotifytools0
2627+ # - inotify-tools
2628+ # filesets:
2629+ # wanted:
2630+ # - usr/share/doc/inotify-tools/copyright
2631+ # - usr/bin/inotifywait
2632+ # - usr/share/doc/libinotifytools0/copyright
2633+ # - usr/lib/libinotifytools.so.0.4.1
2634+ # - usr/lib/libinotifytools.so.0
2635+ # snap:
2636+ # - $wanted
2637+ networkmanager:
2638+ plugin: autotools
2639+ source: .
2640+ build-attributes: [no-system-libraries]
2641+ build-packages:
2642+ - intltool
2643+ - libdbus-glib-1-dev
2644+ - libdbus-1-dev
2645+ - libglib2.0-dev
2646+ - libiw-dev
2647+ - libnl-3-dev
2648+ - libnl-route-3-dev
2649+ - libnl-genl-3-dev
2650+ - ppp-dev
2651+ - libgnutls28-dev
2652+ - uuid-dev
2653+ - systemd
2654+ - libsystemd-dev
2655+ - libudev-dev
2656+ - libgirepository1.0-dev
2657+ - gobject-introspection
2658+ - python-gi
2659+ - libpsl-dev
2660+ - libcurl4-gnutls-dev
2661+ - perl
2662+ - libyaml-perl
2663+ - libglib2.0-doc
2664+ - libmm-glib-dev
2665+ - libndp-dev
2666+ - libreadline-dev
2667+ - libnewt-dev
2668+ - libteam-dev
2669+ - libjansson-dev
2670+ - dbus
2671+ - python-dbus
2672+ - quilt
2673+ - xsltproc
2674+ configflags:
2675+ - --prefix=/usr
2676+ - --libdir=/usr/lib
2677+ - --disable-qt
2678+ # dhcp handled by systemd client
2679+ - --with-dhcpcd=no
2680+ - --with-dhclient=no
2681+ - --with-dnsmasq=no
2682+ - --with-systemd-journal=yes
2683+ # from 1.10 deb:
2684+ - --libexecdir=/usr/lib/NetworkManager
2685+ - --with-pppd=/usr/sbin/pppd
2686+ - --with-resolvconf=no
2687+ #
2688+ # TODO: iptables & dnsmasq are used for AP mode; not
2689+ # currently supported by the snap:
2690+ # - --with-iptables=/sbin/iptables
2691+ # - --with-dnsmasq=/usr/sbin/dnsmasq
2692+ - --with-dnssec-trigger=/usr/lib/dnssec-trigger/dnssec-trigger-script
2693+ - --with-systemdsystemunitdir=/lib/systemd/system
2694+ - --with-udev-dir=/lib/udev
2695+ - --with-crypto=gnutls
2696+ # Explicitly disable session tracking, as it's not applicable on Ubuntu Core
2697+ - --with-session-tracking=no
2698+ - --with-suspend-resume=systemd
2699+ - --with-modem-manager-1
2700+ - --with-nmtui=yes
2701+ - --with-nmcli=yes
2702+ - --with-selinux=no
2703+ - --with-tests
2704+ - --with-libaudit=no
2705+ - --without-dhcpcanon
2706+ # Explicitly disable polkit, as it's not applicable on Ubuntu Core
2707+ - --disable-polkit
2708+ - --disable-polkit-agent
2709+ - --enable-ppp
2710+ - --enable-ifupdown
2711+ - --disable-config-plugin-ibft
2712+ - --enable-introspection
2713+ - --disable-gtk-doc
2714+ - --enable-concheck
2715+ - --enable-teamdctl
2716+ - --enable-json-validation
2717+ - --disable-more-warnings
2718+ - --disable-modify-system
2719+ - --disable-ovs
2720+ override-build: |
2721+ echo "networkmanager override-build called <patches go here>"
2722+ export QUILT_PATCHES=debian/patches
2723+ quilt push -a
2724+
2725+ # remove configure to trigger autotools
2726+ rm ./configure
2727+ snapcraftctl build
2728+
2729+ # Run all tests NetworkManager ships by default
2730+ make check
2731+ stage-packages:
2732+ - libasn1-8-heimdal
2733+ - libdbus-glib-1-2
2734+ - libcurl3-gnutls
2735+ - libgssapi3-heimdal
2736+ - libgssapi-krb5-2
2737+ - libhcrypto4-heimdal
2738+ - libheimbase1-heimdal
2739+ - libheimntlm0-heimdal
2740+ - libhx509-5-heimdal
2741+ - libidn2-0
2742+ - libjansson4
2743+ - libkeyutils1
2744+ - libkrb5-3
2745+ - libkrb5-26-heimdal
2746+ - libkrb5support0
2747+ - libk5crypto3
2748+ - libldap-2.4-2
2749+ - libmm-glib0
2750+ - libnghttp2-14
2751+ - libroken18-heimdal
2752+ - libndp0
2753+ - libpsl5
2754+ - libreadline7
2755+ - librtmp1
2756+ - libsasl2-2
2757+ - libteamdctl0
2758+ - libunistring2
2759+ - libblkid1
2760+ - libgcrypt20
2761+ - libgpg-error0
2762+ - liblzma5
2763+ - libmount1
2764+ - libnl-3-200
2765+ - libpcre3
2766+ - libselinux1
2767+ - libtinfo5
2768+ - libuuid1
2769+ - zlib1g
2770+ - libgmp10
2771+ - libgnutls30
2772+ - libhogweed4
2773+ - liblz4-1
2774+ - libnettle6
2775+ - libp11-kit0
2776+ - libtasn1-6
2777+ - libwind0-heimdal
2778+
2779+ # Filter files pulled in by stage-packages so they aren't
2780+ # included in the final snap. We only need them to build
2781+ # NetworkManager. All runtime dependencies are pulled in with
2782+ # the rdepends part below. The only left items specified
2783+ # here are the results of the network manager build.
2784+ filesets:
2785+ binaries:
2786+ - usr/bin/nmcli
2787+ - usr/lib/*/NetworkManager
2788+ # TODO: figure out pppd
2789+ #- usr/lib/pppd/2.4.5/nm-pppd-plugin.so
2790+ - usr/lib/NetworkManager
2791+ - usr/sbin/NetworkManager
2792+ - usr/lib/*/libnm-*
2793+ configs:
2794+ - etc/NetworkManager/*
2795+ docs:
2796+ - usr/share/doc
2797+ rdepends:
2798+ - lib64/*
2799+ - lib/*/
2800+ - usr/lib/*
2801+ unwanted:
2802+ # We don't want anything in usr/share but the doc folder
2803+ # to carry all copyright information
2804+ - -usr/share/bash-completion
2805+ - -usr/share/bug
2806+ - -usr/share/dbus-1
2807+ - -usr/share/gir-1.0
2808+ - -usr/share/glib-2.0
2809+ - -usr/share/gtk-doc
2810+ - -usr/share/lintian
2811+ - -usr/share/locale
2812+ - -usr/share/man
2813+ - -usr/share/pam-configs
2814+ - -usr/share/polkit-1
2815+ - -usr/share/upstart
2816+
2817+ # We don't use dhclient so we don't need this helper
2818+ - -usr/lib/NetworkManager/nm-dhcp-helper
2819+ # Things we don't support yet and don't have to ship
2820+ - -usr/lib/NetworkManager/libnm-device-plugin-adsl.so
2821+ - -usr/lib/NetworkManager/libnm-device-plugin-bluetooth.so
2822+
2823+ # Unwanted content coming from the stage debian packages
2824+ - -etc/
2825+ # Contains many libraries which are already present in usr/lib/
2826+ - -lib/
2827+ - -usr/include/
2828+ - -usr/etc
2829+ - -usr/sbin/invoke-rc.d
2830+ - -usr/sbin/service
2831+ - -usr/sbin/update-rc.d
2832+ - -usr/lib/dbus-1.0/
2833+ - -usr/lib/tmpfiles.d/
2834+ - -usr/lib/*/pkgconfig
2835+ - -usr/lib/pkgconfig
2836+ - -usr/lib/gcc/
2837+ - -usr/lib/*/gconv/
2838+ - -usr/lib/girepository-1.0/
2839+ - -usr/lib/systemd/
2840+ - -usr/lib/udev/
2841+ - -usr/lib/*.a
2842+ - -usr/lib/*/*.a
2843+ - -usr/lib/*.la
2844+ - -usr/lib/*/*.la
2845+ - -usr/lib/*/*.o
2846+ - -usr/lib/*/systemd-shim
2847+ - -usr/lib/*/systemd-shim-cgroup-release-agent
2848+ prime:
2849+ - $binaries
2850+ - $configs
2851+ - $docs
2852+ - $rdepends
2853+ - $unwanted
2854+
2855+
2856+

Subscribers

People subscribed via source and target branches

to all changes: