Skip to content

Commit

Permalink
NetworkManager 1.15.2 wants keyfiles in /run to have the .nmconnectio…
Browse files Browse the repository at this point in the history
…n extension (LP: #1817655)

This appeared in NM upstream as 648c256b9014198aac388097e410999c68c4b452; and
previous versions of NetworkManager do not seem to care, so land the changes in
general, without changes for previous Ubuntu releases.

Adjust tests so they still work with this change.

Signed-off-by: Mathieu Trudel-Lapierre <[email protected]>
  • Loading branch information
Mathieu Trudel-Lapierre authored and cyphermox committed Feb 26, 2019
1 parent 3f1e362 commit 8b779f9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
6 changes: 2 additions & 4 deletions src/nm.c
Original file line number Diff line number Diff line change
Expand Up @@ -576,18 +576,16 @@ write_nm_conf_access_point(net_definition* def, const char* rootdir, const wifi_
g_string_append(s, "\n[ipv6]\nmethod=ignore\n");
}

conf_path = g_strjoin(NULL, "run/NetworkManager/system-connections/netplan-", def->id, NULL);

if (ap) {
g_autofree char* escaped_ssid = g_uri_escape_string(ap->ssid, NULL, TRUE);
conf_path = g_strjoin(NULL, "run/NetworkManager/system-connections/netplan-", def->id, "-", escaped_ssid, NULL);
conf_path = g_strjoin(NULL, "run/NetworkManager/system-connections/netplan-", def->id, "-", escaped_ssid, ".nmconnection", NULL);

g_string_append_printf(s, "\n[wifi]\nssid=%s\nmode=%s\n", ap->ssid, wifi_mode_str(ap->mode));
if (ap->has_auth) {
write_wifi_auth_parameters(&ap->auth, s);
}
} else {
conf_path = g_strjoin(NULL, "run/NetworkManager/system-connections/netplan-", def->id, NULL);
conf_path = g_strjoin(NULL, "run/NetworkManager/system-connections/netplan-", def->id, ".nmconnection", NULL);
if (def->has_auth) {
write_dot1x_auth_parameters(&def->auth, s);
}
Expand Down
7 changes: 5 additions & 2 deletions tests/generator/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,12 @@ def assert_nm(self, connections_map=None, conf=None):
con_dir = os.path.join(self.workdir.name, 'run', 'NetworkManager', 'system-connections')
if connections_map:
self.assertEqual(set(os.listdir(con_dir)),
set(['netplan-' + n for n in connections_map]))
set(['netplan-' + n.split('.nmconnection')[0] + '.nmconnection' for n in connections_map]))
for fname, contents in connections_map.items():
with open(os.path.join(con_dir, 'netplan-' + fname)) as f:
extension = ''
if '.nmconnection' not in fname:
extension = '.nmconnection'
with open(os.path.join(con_dir, 'netplan-' + fname + extension)) as f:
self.assertEqual(f.read(), contents)
# NM connection files might contain secrets
self.assertEqual(stat.S_IMODE(os.fstat(f.fileno()).st_mode), 0o600)
Expand Down
2 changes: 1 addition & 1 deletion tests/generator/test_vlans.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def test_vlan_parent_match(self):
self.assert_networkd({})

# get assigned UUID from en-v connection
with open(os.path.join(self.workdir.name, 'run/NetworkManager/system-connections/netplan-en-v')) as f:
with open(os.path.join(self.workdir.name, 'run/NetworkManager/system-connections/netplan-en-v.nmconnection')) as f:
m = re.search('uuid=([0-9a-fA-F-]{36})\n', f.read())
self.assertTrue(m)
uuid = m.group(1)
Expand Down

0 comments on commit 8b779f9

Please sign in to comment.