Commit graph

12244 commits

Author SHA1 Message Date
Lubomir Rintel
8a668d0983 iwd: add some missing error handling
g_dbus_object_manager_get_interface() can happily return NULL and we
need to check for that.

(cherry picked from commit 59923ad85d)
2019-11-03 13:06:03 +01:00
Beniamino Galvani
58ffded2d0 dhcp: include conditionals from existing dhclient configuration
Since commit 159ff23268 ('dhcp/dhclient-utils: skip over
dhclient.conf blocks') we skip blocks enclosed in lines containing '{'
and '}' because NM should ignore 'lease', 'alias' and other
declarations. However, conditional statements seem useful and should
not be skipped.

https://bugzilla.redhat.com/show_bug.cgi?id=1758550
(cherry picked from commit b58e4d311d)
2019-10-10 14:53:01 +02:00
Beniamino Galvani
299fbc0888 supplicant: allow PMF with SAE
PMF can be used with SAE, allow it. Actually, it is required according
to WPA3 specifications but there are implementations that don't
require it (hostapd can be configured in a such way); so let's not
make it mandatory for WPA3.

Fixes: 6640fb4b36 ('supplicant: add support for SAE key management')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/257
(cherry picked from commit e36c297fd8)
2019-10-09 13:09:42 +02:00
Lubomir Rintel
fb874e6cda bluetooth: don't set the ifindex after the device has been activated
The Bluetooth DUN device's NMModem would signal the reset of ifindex to zero
when it's disconnected and the NMDeviceBt would accordingly update the
bluetooth device's ip ifindex. This is not okay since commit ab4578302d
('device: refactor nm_device_set_ip_ifindex() and set_ip_iface()') which,
although claiming to be a refactoring, made such use of
nm_device_set_ip_ifindex() illegal. Resetting the ifindex is anyway not
necessary, since it's taken care of _cleanup_generic_post().

Let's leave the ifindex alone once the device is activated, in a manner
analogous to what NMDeviceModem.

Fixes: ab4578302d ('device: refactor nm_device_set_ip_ifindex() and set_ip_iface()')
Fixes: 78ca2a70c7 ('device: don't set invalid ip-iface'):
(cherry picked from commit a5ca504b5b)
2019-10-09 12:48:29 +02:00
Beniamino Galvani
7b9abe94bf device: fix wrong string compare in _commit_mtu()
Fixes: e6628fa27c ('ipv6: add 'disabled' method')

https://bugzilla.redhat.com/show_bug.cgi?id=1753128
(cherry picked from commit 5f284e1574)
2019-09-27 13:41:05 +02:00
Beniamino Galvani
722cddfad8 device: don't reapply IP config on link up for disconnected devices
Only reapply the IP configuration on link up if the IP state is CONF
or DONE. Previously we also reapplied it when the device was
disconnected (IP state NONE) and this could lead to a situation where
an incomplete config was applied; then we intersected the desired
configuration with the external - incomplete - one, causing the
removal of part of desired configuration (for example the default
route).

Fixes: d0b16b9283 ('device: unconditionally reapply IP configuration on link up')

https://bugzilla.redhat.com/show_bug.cgi?id=1754511
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/291
(cherry picked from commit 64a9dd3804)
2019-09-27 13:28:37 +02:00
Thomas Haller
8730eac81c initrd: make "argv" argument of nmi_cmdline_reader_parse() a const strv
(cherry picked from commit eea783d129)
2019-09-27 09:31:00 +02:00
Thomas Haller
c28597e2ff initrd/tests: check for the parsed values in detail for rd.znet test
(cherry picked from commit eea8ee2321)
2019-09-27 09:29:41 +02:00
Thomas Haller
2fbd309334 initrd: avoid modifying the argv argument in nmi_cmdline_reader_parse()
While nmi_cmdline_reader_parse() only has one caller, which indeed has the
argv parameter at hand and doesn't care it to be modified, I think it
is ugly.

Arguments preferably are strictly either input or output arguments,
with input arguments not being modified by the call.

(cherry picked from commit 19604cb126)
2019-09-27 09:29:41 +02:00
Thomas Haller
7011f4f098 initrd: avoid assertion inparse_rd_znet() and cleanup
- nm_setting_wired_add_s390_option() asserts that a "value" argument
  is given. Check that the string contains a '=' where we can split.

- pass the requested NM_SETTING_WIRED_SETTING_NAME type to get_conn().
  Otherwise, @s_wired might be %NULL, resulting in an assertion.
  I do wonder whether this always retrieves a connection of the
  appropriate type for modification, or whether a profile could
  be returned that was created for a different purpose. But that
  isn't changed.

- avoid "g_strcmp0 (nettype, "ctc") != 0". I find it unexpected, that we add the
  3rd subchannel component, if the nettype is "ctc" (intuitively, I'd expect it
  to be the opposite). The reasons for this are not documented, but I
  presume it is correct.
  Anyway, using streq() makes this slightly more clear to me, as with
  strcmp() I would wonder whether this was just a typo while with
  streq() I'd be more confident that this is indeed intended.

- don't initialize local variables unnecessarily. The compiler would
  warn if we would forget about this. Also, don'\''t use { } for a
  one-line block.

(cherry picked from commit 783fe28465)
2019-09-27 09:29:41 +02:00
Dan Horák
ce0d7c4efe nm-initrd-generator - add test for rd.znet
(cherry picked from commit df07539105)
2019-09-27 09:29:41 +02:00
Dan Horák
68d6d2bd12 process s390 specific device info from rd.znet parameter in nm-initrd-generator
syntax: rd.znet=<nettype>,<subchannels>,<options>

The s390 specific options used to create the network interface in the kernel
are currently not processed by nm-initrd-generator causing incomplete ifcfg file.

fixes https://bugzilla.redhat.com/show_bug.cgi?id=1753975

(cherry picked from commit 11d4412ee1)
2019-09-27 09:29:41 +02:00
Thomas Haller
8caf3e3e9b settings: fix creation of default-wired-connection in device_realized()
Fixes-test: @allow_wired_connections

Fixes: 3e39d2a586 ('settings: shortcut check for whether to create auto-default wired connection')
(cherry picked from commit 7df769600b)
2019-09-27 09:13:51 +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
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
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
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
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
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
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
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
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
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
Thomas Haller
6118f808d9 bluetooth: fix leak in get_managed_objects_cb()
Fixes: 1ae5d53354 ('bluez: add support for BlueZ 5')
(cherry picked from commit 25571bb639)
2019-08-23 13:18:43 +02:00
Thomas Haller
b82f2d9772 wifi: detect FT support per interface and avoid enabling it
Previously we only cared whether supplicant is build with support for
FT. In that case we would pass FT-PSK to supplicant, like

  Config: added 'key_mgmt' value 'WPA-PSK WPA-PSK-SHA256 FT-PSK'

Supplicant would then always try FT with preference, regardless whether
the interface/driver support it. That results in a failure to associate, if
the driver does not support it.

  NetworkManager[1356]: <info>  [1566296144.9940] Config: added 'key_mgmt' value 'WPA-PSK WPA-PSK-SHA256 FT-PSK'
  ...
  wpa_supplicant[1348]: wlan0: WPA: AP key_mgmt 0x42 network profile key_mgmt 0x142; available key_mgmt 0x42
  wpa_supplicant[1348]: wlan0: WPA: using KEY_MGMT FT/PSK
  ...
  wpa_supplicant[1348]:   * akm=0xfac04
  ...
  kernel: ERROR @wl_set_key_mgmt :
  kernel: invalid cipher group (1027076)

Since we pass a list of acceptable "key_mgmt" options to supplicant,
FT-PSK should not be used when supplicant knows it's not supported.
That is a supplicant bug.

Regardless, work around it by checking the per-interface capability, and
avoid it if support is apparently not present.

(cherry picked from commit 2f8a4e90f0)
2019-08-20 16:38:25 +02:00
Thomas Haller
fa0c5a41c1 ifupdown: fix assertion during logging %NULL storage in load_eni_ifaces()
(cherry picked from commit ddb08e3602)
2019-08-06 12:22:15 +02:00
Beniamino Galvani
47c772354e modem: fix memory leak
Fixes: 9b935fad9b ('modem: don't use GAsyncResult pattern for disconnecting modem')
(cherry picked from commit 22cd9e754b)
2019-08-06 09:17:10 +02:00
Beniamino Galvani
e41bb8fc8e settings: fix memory leak
Fixes: d35d3c468a
(cherry picked from commit 956ffb7e96)
2019-08-05 10:11:08 +02:00
Thomas Haller
8b017dc2fb settings: fix registering AgentManager.RegisterWithCapabilities() twice
Fixes: 297d4985ab
(cherry picked from commit 1634fff1ad)
2019-08-03 18:36:15 +02:00
Thomas Haller
a3f9ab473b wireguard: fix use-after free in _peers_remove()
(cherry picked from commit 85c26341a2)
2019-08-03 12:28:33 +02:00
Thomas Haller
79660f1f5b supplicant: mark static arrays as const and static in "nm-supplicant-settings-verify.c"
They should be "static" and only visible to this source file.

Also, they should be "const", that allows the linker to place them
into read-only memory.

(cherry picked from commit 722b167953)
2019-08-02 18:19:49 +02:00
Thomas Haller
da933ffe2a supplicant: don't put binary data in error message for supplicant
For better or worse, the API does not require the value to be a
UTF-8 string. We cannot just concatenate binary to a string.
Instead, backslash escape it with utf8safe-escape.

Also, this will shut up a (wrong) coverity warning at this place.

(cherry picked from commit 55143dad95)
2019-08-02 18:19:49 +02:00
Thomas Haller
d99925a1b0 supplicant: fix nm_supplicant_settings_verify_setting() honoring the string length
We must not just pretend that the value is a NULL terminated string.
That's why we have the length argument.

(cherry picked from commit 9ed26de3da)
2019-08-02 18:19:49 +02:00
Thomas Haller
3ebad253e8 device/bluetooth: explicitly ignore return value of ioctl() in nm_bluez5_dun_cleanup()
Coverity doesn't like us not checking the result.

(cherry picked from commit 526601e4f3)
2019-08-02 18:19:49 +02:00
Thomas Haller
9168dea0da device: trigger a connectivity check when device disconnects
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/219

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/225
(cherry picked from commit 88bcf87ad9)
2019-08-02 17:53:34 +02:00
Thomas Haller
0df7f74c29 core: assert for valid arguments in _addresses_sort_cmp()
Coverity thinks that the arguments could be %NULL. Add an assertion,
hoping to silence coverity.

(cherry picked from commit 1b30797bc1)
2019-08-02 17:13:50 +02:00