Commit graph

23808 commits

Author SHA1 Message Date
Thomas Haller
2b01ac0932 tests: don't install bzip2 as REQUIRED_PACKAGES on Fedora/RHEL
(cherry picked from commit 3a1b2b9885)
2019-09-25 15:52:17 +02:00
Thomas Haller
6ff16a48bb tests: don't install unnecessary package in gitlab-ci tests
REQUIRED_PACKAGES has two uses:

 - to setup a system for developing NetworkManager. This installs
   convenience packages like "cscope".

 - to install the packages required for unit testing in gitlab-ci.

For gitlab-ci we should only install the packages that we actually
need.

(cherry picked from commit 1a2a5b37b4)
2019-09-25 15:52:17 +02:00
Thomas Haller
888718d6f4 tests: fix failure installing non-existing packages in REQUIRED_PACKAGES
Previously, dnf/yum used to ignore packages that didn't exist.
In Fedora 32, dnf starts to fail the entire command:

  No match for argument: python-gobject-base
  Error: Unable to find a match: python-gobject-base

Since this script is supposed to work with different RHEL/Fedora
versions, it's expected that not all packages are available everywhere.

Fix that, by installing packages that we know that they might be missing
one by one (and ignore the error).

(cherry picked from commit 185567559c)
2019-09-25 15:52:17 +02:00
Thomas Haller
ae2d6c0bc9 tests: fix "clients/tests/test-client.py" concatenating binary for Python 3
Python 3 doesn't like this:

    ======================================================================
    ERROR: test_001 (__main__.TestNmcli)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "./clients/tests/test-client.py", line 785, in f
        self._nm_test_post()
      File "./clients/tests/test-client.py", line 767, in _nm_test_post
        content_new = ''.join([r['content'] for r in results])
    TypeError: sequence item 0: expected str instance, bytes found

(cherry picked from commit 97646d81ce)
2019-09-25 15:52:17 +02:00
Thomas Haller
992c5abb53 tests: don't compare string literal with "is" in "clients/tests/test-client.py"
Recent Python versions warn about this:

  ./clients/tests/test-client.py:569: SyntaxWarning: "is" with a literal. Did you mean "=="?
    elif lang is de:
  ./clients/tests/test-client.py:572: SyntaxWarning: "is" with a literal. Did you mean "=="?
    elif lang is pl:

And rightly so: https://bugs.python.org/issue34850

(cherry picked from commit 989b26a843)
2019-09-25 15:52:17 +02:00
Thomas Haller
a2af6cc298 tests: avoid deprecated GLib.IOChannel.add_watch() in "test-networkmanager-service.py"
test_001 (__main__.TestNmcli) ... /tmp/NetworkManager/tools/test-networkmanager-service.py:2346: PyGIDeprecationWarning: add_watch is deprecated; use GLib.io_add_watch() instead
  id1 = GLib.IOChannel(0).add_watch(GLib.IOCondition.HUP,

(cherry picked from commit ceae05cc4b)
2019-09-25 15:52:17 +02:00
Thomas Haller
c44c796a90 contrib/rpm: "Suggest" wpa_supplicant for NetworkManager-wifi package
"NetworkManager-wifi" package requires either wpa_supplicant or iwd.
When installing the package without explicitly installing supplicant
or iwd (and not having it installed yet), then we want to drag in
wpa_supplicant by default. That is accomplished by suggesting wpa_supplicant
package.

Otherwise, the user installing NetworkManager-wifi might get iwd,
which is only functioning if the user explicitly enables the backend
in "NetworkManager.conf".

https://bugzilla.redhat.com/show_bug.cgi?id=1743585
(cherry picked from commit 4b1cb404fd)
2019-09-23 13:30:17 +02:00
Thomas Haller
2d7195fc9d wifi/p2p: fix crash due to invalid signal handler supplicant_group_iface_group_finished_cb()
Fixes: 00e64d1332 ('core/devices: Add P2P Wifi device and peer tracking')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/249

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/284
(cherry picked from commit 9aa6c676ef)
2019-09-23 13:24:06 +02:00
Thomas Haller
d49e96649f core: merge branch 'th/check-have-connection-for-auto-default'
https://bugzilla.redhat.com/show_bug.cgi?id=1727909

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/232

(cherry picked from commit c03defa3a8)
2019-09-23 13:21:07 +02:00
Thomas Haller
cdb719c756 settings: drop redundant check from have_connection_for_device()
have_connection_for_device() really should just call nm_device_check_connection_compatible().
Note that nm_device_check_connection_compatible() of course checks the
connection type already, so this is redundant.

(cherry picked from commit 2a506d8a09)
2019-09-23 13:20:45 +02:00
Thomas Haller
bad64d1cf6 settings: shortcut check for whether to create auto-default wired connection
This check is only useful for devices that implement new_default_connection.
We can shortcut the possibly expensive checks like have_connection_for_device(),
which need to iterate all profiles.

(cherry picked from commit 3e39d2a586)
2019-09-23 13:20:45 +02:00
Thomas Haller
04c5cc5a5c core: fix wrongly generating "Wired connection 1" (auto-default) for ethernet with MAC
If a profile has only "ethernet.mac-address" set, but
"connection.interface-name" not, then the previous check

    iface = nm_setting_connection_get_interface_name (s_con);
    if (!nm_streq0 (iface, nm_device_get_iface (device)))
         continue;

would wrongly consider the profile not matching for the device.
As a result, we would wrongly create a auto-default connection.

Fix that. We already call nm_device_check_connection_compatible()
above. That is fully suitable to compare the interface name and
the MAC address. We don't need to duplicate this check (wrongly).

See also commit 77d01c9094 ('settings: ignore incompatible connections
when looking for existing ones') for how this code changed.

https://bugzilla.redhat.com/show_bug.cgi?id=1727909
(cherry picked from commit 5aa50d7c87)
2019-09-23 13:20:45 +02:00
Beniamino Galvani
900eb63cf3 tui: wifi: support WPA3-Personal (SAE)
(cherry picked from commit b57f8d93e2)
2019-09-20 13:23:47 +02:00
Beniamino Galvani
7686415ad2 libnm-core: support SAE when determining AP compatibility
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/172
(cherry picked from commit 84a86ce55f)
2019-09-20 13:23:46 +02:00
Beniamino Galvani
9a5935f716 device: accept lease only after addresses are configured
In the accept() callback, the nettools client creates a UDP socket
with the received address as source, so the address must be already
configured on the interface.

Also, handle errors returned by nm_dhcp_client_accept().

Fixes: 401fee7c20 ('dhcp: support notifying the client of the result of DAD')
(cherry picked from commit 8b5bf6e4d1)
2019-09-18 09:38:54 +02:00
Beniamino Galvani
06e4c877dd n-dhcp4: arm timers in bound state
Arm timers when the bound state is reached, otherwise the lease is
never renewed.

https://github.com/nettools/n-dhcp4/pull/4
(cherry picked from commit 687d0dd95e)
2019-09-18 09:38:52 +02:00
Francesco Giudici
bf28a9e92f dhcp: nettools: retrieve and expose the expiry time
also fix the lease time: it should be the time in seconds that the lease
lasts

(cherry picked from commit cded6d5184)
2019-09-18 09:38:38 +02:00
Beniamino Galvani
7f8fdd28f2 supplicant: add FT-SAE key-mgmt to verification list
FT-SAE is missing in the supplicant configuration verification list,
causing an activation failure when using SAE and the supplicant
supports FT.

Fixes: d17a0a0905 ('supplicant: allow fast transition for WPA-PSK and WPA-EAP')
(cherry picked from commit c177a38e88)
2019-09-16 17:08:29 +02:00
Beniamino Galvani
81cc4ddb1a wifi: allow reapply when the seen-bssids property changed
wifi.seen-bssid is a synthetic read-only property that lists all the
bssids seen for that connection; it should be ignored during a
reapply.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/243
(cherry picked from commit 8cd8a5fbed)
2019-09-13 14:30:19 +02:00
Lubomir Rintel
1c950c180f platforn/linux: don't fall back to WEXT for OLPC Mesh
nl80211 offers the same functionality sans the bugs.

(cherry picked from commit f537056589)
2019-09-07 17:26:16 +02:00
Lubomir Rintel
60bff25333 wifi/olpc-mesh: fix the stage2
There's multiple things wrong there, but unnoticed because the error handling
was entirely missing or nobody is using thie anymore.

The Mesh ID needs to be set while the device is down. Also, the channel
needs to be set last, because that's what triggers the connection
attempt. For that the device needs to be up.

Also, fix the error handling.

(cherry picked from commit 13bd678dd5)
2019-09-07 17:26:16 +02:00
Lubomir Rintel
b6d7e44bd8 wifi/olpc-mesh: drop assert(companion) from get_autoconnect_allowed()
The comment is wrong. Since 6eaded9071 ('device: add
get_autoconnect_allowed() virtual function'), get_autoconnect_allowed()
is called before the device state is consulted.

(cherry picked from commit ad86ee4d48)
2019-09-07 17:26:16 +02:00
Lubomir Rintel
15e813deff wifi: add OLPC Mesh support via nl80211
(cherry picked from commit cc96771f32)
2019-09-07 17:26:16 +02:00
Beniamino Galvani
a369e61d2a build: use regexp in gtkdoc --ignore-decorators option
gtkdoc-scan supports regular expressions in the --ignore-decorators
command-line option. Since it is easier to use a regexp than grepping
macros from a source file, revert the ugly solution from commit
2d941dc95a ('build: fix errors when building with gtk-doc 1.32').

(cherry picked from commit 11cf082a62)
2019-09-06 14:22:18 +02:00
Lubomir Rintel
b2447b4169 release: bump version to 1.20.3 (development) 2019-09-05 14:44:17 +02:00
Lubomir Rintel
4ef27f896e release: bump version to 1.20.2 2019-09-05 14:33:41 +02:00
Lubomir Rintel
ee8947f11c release: update NEWS 2019-09-05 13:59:57 +02:00
Beniamino Galvani
2c0de62a47 core: add audit log for the SaveHostname call
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/260
(cherry picked from commit 2ca8b511e6)
2019-09-05 11:43:13 +02:00
Beniamino Galvani
45c903dc88 core: add defines for common authentication-related error messages
All D-Bus method call implementations use similar error messages when
authenticating requests; add defines for them to ensure the same exact
message is reused.

(cherry picked from commit 4bd192a350)
2019-09-05 11:43:11 +02:00
Beniamino Galvani
d5ed990caf build: fix errors when building with gtk-doc 1.32
gtkdoc-scan 1.32 performs stricter checks on structures definitions
and so it complains on:

 /build/networkmanager/src/NetworkManager/libnm/./nm-vpn-plugin-old.h:0: warning: partial declaration (struct) : typedef struct {
 	NM_DEPRECATED_IN_1_2
 	GObject parent;
 } NMVpnPluginOld NM_DEPRECATED_IN_1_2;

because of the unrecognized token 'NM_DEPRECATED_IN_1_2'.

Pass all allowed macros to gtkdoc-scan through the --ignore-decorators
argument.

https://gitlab.gnome.org/GNOME/gtk-doc/issues/98
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/238
(cherry picked from commit 2d941dc95a)
2019-09-05 11:25:36 +02:00
Thomas Haller
9e209138dc core/tests: avoid deprecated g_main_run()/g_main_loop_unref() in test
These are deprecated. Also, they are nowadays implemented as macros
that expand to

  #define g_main_run(loop) g_main_loop_run(loop) GLIB_DEPRECATED_MACRO_IN_2_26_FOR(g_main_loop_run)

This can cause compilation failure (in some environments).

(cherry picked from commit de6f0bc6db)
2019-09-03 18:18:48 +02:00
Beniamino Galvani
0e4d0f8d3f core: merge branch 'bg/device-realize-failed-rh1686634'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/252
https://bugzilla.redhat.com/show_bug.cgi?id=1686634
(cherry picked from commit dbfbbed53c)
2019-09-03 16:57:04 +02:00
Beniamino Galvani
5d45ac0650 manager: keep device if realize() fails
system_create_virtual_device() first creates the device (unrealized)
and then, if there a connection for the device with autoconnect=yes,
creates the backing resources. If this last step fails the device
should continue to exist, even if in an unrealized state.

https://bugzilla.redhat.com/show_bug.cgi?id=1686634
(cherry picked from commit f07aa329b2)
2019-09-03 16:56:47 +02:00
Beniamino Galvani
9d0e8e851f device: don't set nm-owned flag if realize() fails
The nm-owned flag indicates whether the device was created by NM. If
the realization step fails, the device was not created and so nm-owned
should not be updated.

(cherry picked from commit 4bc4156424)
2019-09-03 16:56:45 +02:00
Davide Palma
36ef996a5f po: fixed typo in it.po
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/259
(cherry picked from commit 6a7c2d44ae)
2019-09-03 16:07:02 +02:00
Lubomir Rintel
3c4a7cd4a9 core: fix a typo
s/grater/greater/

(cherry picked from commit 4534c6c366)
2019-09-03 16:04:48 +02:00
Thomas Haller
18dfbeefd4 keyfile: reorder printing empty [wireguard] section with peers and fix test failure
We want to print the [wireguard] section before printing sections of the
peers. It just looks nicer.

This also fixes a test failure:

  /libnm/settings/roundtrip-conversion/wireguard/2: **
  test:ERROR:./shared/nm-utils/nm-test-utils.h:2254:nmtst_keyfile_assert_data: assertion failed (d1 == data): ("[connection]\nid=roundtrip-conversion-2\nuuid=63376701-b61e-4318-bf7e-664a1c1eeaab\ntype=wireguard\ninterface-name=ifname2\npermissions=\n\n[wireguard-peer.uoGoXWWRxJvu4jDva8pPGA4nxau8B33S+YR+MfPFjxc=]\nendpoint=192.168.255.180:30429\npreshared-key-flags=2\n\n[wireguard-peer.BED73rH9j3OCHYAeXNrW5y5oia/Ngj+M04e9sG7DQOo=]\nendpoint=192.168.188.253:30407\npreshared-key-flags=1\npersistent-keepalive=5070\nallowed-ips=192.168.215.179/32;192.168.120.249/32;a🅱️c::e4:13/128;192.168.157.84/32;a🅱️c::1b:df/128;a🅱️c::b0:84/128;192.168.168.17/32;\n\n[wireguard]\n\n[ipv4]\ndns-search=\nmethod=disabled\n\n[ipv6]\naddr-gen-mode=stable-privacy\ndns-search=\nmethod=ignore\n\n[proxy]\n" == "[connection]\nid=roundtrip-conversion-2\nuuid=63376701-b61e-4318-bf7e-664a1c1eeaab\ntype=wireguard\ninterface-name=ifname2\npermissions=\n\n[wireguard]\n\n[wireguard-peer.uoGoXWWRxJvu4jDva8pPGA4nxau8B33S+YR+MfPFjxc=]\nendpoint=192.168.255.180:30429\npreshared-key-flags=2\n\n[wireguard-peer.BED73rH9j3OCHYAeXNrW5y5oia/Ngj+M04e9sG7DQOo=]\nendpoint=192.168.188.253:30407\npreshared-key-flags=1\npersistent-keepalive=5070\nallowed-ips=192.168.215.179/32;192.168.120.249/32;a🅱️c::e4:13/128;192.168.157.84/32;a🅱️c::1b:df/128;a🅱️c::b0:84/128;192.168.168.17/32;\n\n[ipv4]\ndns-search=\nmethod=disabled\n\n[ipv6]\naddr-gen-mode=stable-privacy\ndns-search=\nmethod=ignore\n\n[proxy]\n")

Fixes: ddd148e02b ('keyfile: let keyfile writer serialize setting with all default values')
(cherry picked from commit 576a128954)
2019-09-02 13:21:01 +02:00
Beniamino Galvani
30d2f6cacc dhcp: fall back to 'internal' client for IPv6 when using 'nettools'
The 'nettools' client doesn't support IPv6, fall back to 'internal'.

(cherry picked from commit c0a825bc8e)
2019-08-29 09:55:32 +02:00
Beniamino Galvani
52241748e8 core: fix adding objects to NMIPConfig with @append_force
If the @append_force argument is set and the object is already in the
list, it must be moved at the end.

Fixes: 22edeb5b69 ('core: track addresses for NMIP4Config/NMIP6Config via NMDedupMultiIndex')
(cherry picked from commit 8b121c7048)
2019-08-28 16:14:13 +02:00
Beniamino Galvani
ebaf890057 core: add test to show nm_ipX_config_replace() bug
Add test to show a wrong result of ip_ipX_config_replace() due to a
bug in _nm_ip_config_add_obj(). When an address is added to the tail
of the index and another address with the same id already exists, the
existing object is left at the same place, breaking the order of
addresses.

(cherry picked from commit 24741bff8b)
2019-08-28 16:14:11 +02:00
Thomas Haller
faf12086c1 acd: fix memleak in acd_event()
Only happens with debug logging enabled. So, not a large problem.

Found by Coverity.

Fixes: d9a4b59c18 ('acd: adapt NM code and build options')
(cherry picked from commit 0300c1823a)
2019-08-27 18:21:24 +02:00
Thomas Haller
ceb1ba69b4 contrib/rpm: explicitly set runstatedir to "/run" when building release tarball
Nowadays, we should prefer "/run" over "/var/run". When not specifying
during ./configure, autotools however still defaults to "/var/run".

This default is also visible in the pre-generated documenation, for
example `man NetworkManager.conf` says

  Unless the symlink points to the internal file /run/NetworkManager/resolv.conf,
  in which case the ...

(cherry picked from commit 081b16cdb8)
2019-08-27 16:32:51 +02:00
Thomas Haller
c658427869 keyfile: merge branch 'th/keyfile-fix-empty-settings'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/248

(cherry picked from commit 01ef7c4079)
2019-08-27 12:07:38 +02:00
Thomas Haller
aca5b672ad keyfile: let keyfile writer serialize setting with all default values
It's important whether a setting is present or not. Keyfile writer
omits properties that have a default value, that means, if the setting
has all-default values, it would be dropped. For [proxy] that doesn't
really matter, because we tend to normalize it back. For some settings
it matters:

  $ nmcli connection add type bluetooth con-name bt autoconnect no bluetooth.type dun bluetooth.bdaddr aa:bb:cc:dd:ee:ff gsm.apn a
  Connection 'bt' (652cabd8-d350-4246-a6f3-3dc17eeb028f) successfully added.

  $ nmcli connection modify bt gsm.apn ''

When storing this to keyfile, the [gsm] section was dropped
(server-side) and we fail an nm_assert() (omitted from the example
output below).

  <error> [1566732645.9845] BUG: failure to normalized profile that we just wrote to disk: bluetooth: 'dun' connection requires 'gsm' or 'cdma' setting
  <trace> [1566732645.9846] keyfile: commit: "/etc/NetworkManager/system-connections/bt.nmconnection": profile 652cabd8-d350-4246-a6f3-3dc17eeb028f (bt) written
  <trace> [1566732645.9846] settings: update[652cabd8-d350-4246-a6f3-3dc17eeb028f]: update-from-dbus: update profile "bt"
  <trace> [1566732645.9849] settings: storage[652cabd8-d350-4246-a6f3-3dc17eeb028f,3e504752a4a78fb3/keyfile]: change event with connection "bt" (file "/etc/NetworkManager/system-connections/>
  <trace> [1566732645.9849] settings: update[652cabd8-d350-4246-a6f3-3dc17eeb028f]: updating connection "bt" (3e504752a4a78fb3/keyfile)
  <debug> [1566732645.9857] ++ connection 'update connection' (0x7f7918003340/NMSimpleConnection/"bluetooth" < 0x55e1c52480e0/NMSimpleConnection/"bluetooth") [/org/freedesktop/NetworkManager>
  <debug> [1566732645.9857] ++ gsm                       [ 0x55e1c5276f80 < 0x55e1c53205f0 ]
  <debug> [1566732645.9858] ++ gsm.apn                   < 'a'

Of course, after reload the connection on disk is no loner valid.
Keyfile writer wrote an invalid setting.

  # nmcli connection reload

Logfile:

  <warn>  [1566732775.4920] keyfile: load: "/etc/NetworkManager/system-connections/bt.nmconnection": failed to load connection: invalid connection: bluetooth: 'dun' connection requires 'gsm' or 'cdma' setting
  ...
  <trace> [1566732775.5432] settings: update[652cabd8-d350-4246-a6f3-3dc17eeb028f]: delete connection "bt" (3e504752a4a78fb3/keyfile)
  <debug> [1566732775.5434] Deleting secrets for connection /org/freedesktop/NetworkManager/Settings (bt)
  <trace> [1566732775.5436] dbus-object[9a402fbe14c8d975]: unexport: "/org/freedesktop/NetworkManager/Settings/55"

(cherry picked from commit ddd148e02b)
2019-08-27 12:01:50 +02:00
Thomas Haller
3ea2337f27 keyfile: refactor _parse_info_find() to get ParseInfoSetting
I thought I would need this, but ended up not using it.

Anyway, it makes sense in general that the function can lookup
all relevant information, so merge it.

(cherry picked from commit e6eb01c18f)
2019-08-27 12:01:50 +02:00
Thomas Haller
b02e3acfb9 keyfile/tests: add unit test showing bug where keyfile writer looses settings that are all-default
(cherry picked from commit f8abb05eba)
2019-08-27 12:01:50 +02:00
Thomas Haller
22800c041c settings/keyfile: check whether profile can be re-read before writing to disk and fail
First of all, keyfile writer (and reader) are supposed to be able to store
every profile to disk and re-read a valid profile back. Note that the profile
might be modified in the process, for example, blob certificates are written
to a file. So, the result might no be exactly the same, but it must still be
valid (and should only diverge in expected ways from the original, like mangled
certificates).

Previously, we would re-read the profile after writing to disk. If that failed,
we would only fail an assertion but otherwise proceeed. It is a bug
after all. However, it's bad to check only after writing to file,
because it results in a unreadable profile on disk, and in the first
moment it appears that noting went wrong. Instead, we should fail early.

Note that nms_keyfile_reader_from_keyfile() must entirely operate on the in-memory
representation of the keyfile. It must not actually access any files on disk. Hence,
moving this check before writing the profile must work. Otherwise, that would be
a separate bug. Actually, keyfile reader and writer violate this. I
added FIXME comments for that. But it doesn't interfere with this
patch.

(cherry picked from commit 3b8aab2999)
2019-08-27 12:01:47 +02:00
Thomas Haller
d92ec1d499 settings/keyfile: log reason why re-read connection cannot be normalized
It's a bug either way, but let's log what exactly went wrong.

(cherry picked from commit 1c2c7d3cb7)
2019-08-27 12:00:55 +02:00
Thomas Haller
2958d04238 shared/tests: add nmtst_keyfile_get_num_keys() helper
(cherry picked from commit a265892385)
2019-08-27 12:00:55 +02:00
Thomas Haller
eaf051270c ifupdown: fix crash loading ifupdown settings with empty entries like bridge-ports and mappings
Fixes: d35d3c468a ('settings: rework tracking settings connections and settings plugins')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/235
(cherry picked from commit e9ccc2da19)
2019-08-24 13:47:38 +02:00