Commit Graph

24017 Commits

Author SHA1 Message Date
Thomas Haller
aef9594fa6 device/bond: cleanup act-stage return values in NMDeviceBond's act_stage1_prepare() 2019-08-28 16:27:00 +02:00
Thomas Haller
0d0d4eaf93 device/team: drop unnecessary cast for NM_DEVICE_TEAM_GET_PRIVATE() macro 2019-08-28 16:27:00 +02:00
Thomas Haller
847f9cbef3 device/modem: drop unnecessary cast for NM_DEVICE_MODEM_GET_PRIVATE() macro
NM_DEVICE_MODEM_GET_PRIVATE() is based on _NM_GET_PRIVATE(), which has
some smarts to check the pointer type, but is fine with well-known parent
pointer types like "NMDevice *".
2019-08-28 16:27:00 +02:00
Thomas Haller
96cd0ca62f modem/trivial: rename virtual function NMModemClass.act_stage1_prepare()
NMDeviceClass already has a function with this name. It's confusing
to have multiple virtual functions named the same. Rename.
2019-08-28 16:27:00 +02:00
Beniamino Galvani
8b121c7048 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')
2019-08-28 16:08:30 +02:00
Beniamino Galvani
24741bff8b 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.
2019-08-28 16:08:28 +02:00
Thomas Haller
0300c1823a 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')
2019-08-27 18:19:01 +02:00
Thomas Haller
081b16cdb8 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 ...
2019-08-27 16:31:55 +02:00
Thomas Haller
01ef7c4079 keyfile: merge branch 'th/keyfile-fix-empty-settings'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/248
2019-08-27 11:47:22 +02:00
Thomas Haller
ddd148e02b 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"
2019-08-27 11:45:14 +02:00
Thomas Haller
e6eb01c18f 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.
2019-08-27 11:45:14 +02:00
Thomas Haller
f8abb05eba keyfile/tests: add unit test showing bug where keyfile writer looses settings that are all-default 2019-08-27 11:45:14 +02:00
Thomas Haller
3b8aab2999 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.
2019-08-27 11:45:06 +02:00
Thomas Haller
1c2c7d3cb7 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.
2019-08-27 10:44:23 +02:00
Thomas Haller
a265892385 shared/tests: add nmtst_keyfile_get_num_keys() helper 2019-08-27 10:44:23 +02:00
Thomas Haller
d1307b22f3 libnm/doc: improve documentation for NMMetered enum (2) 2019-08-27 10:25:59 +02:00
Thomas Haller
703677bdad libnm/doc: improve documentation for NMMetered enum 2019-08-26 14:27:16 +02:00
Lubomir Rintel
36fec3be75 contrib/modemu: ensure the udev messages specify SEQNUM
Newer systemd rejects messages without one.
2019-08-26 12:58:55 +02:00
Beniamino Galvani
48da56ed6c wifi: merge branch 'bg/ibss-rsn'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/184
2019-08-26 10:40:44 +02:00
Beniamino Galvani
a205eb4aa4 wifi: support WPA2 ad-hoc (ibss-rsn)
If the device supports it, allow usage of WPA2 in ad-hoc networks.

Based-on-patch-by: Nicolas Cavallari <cavallar@lri.fr>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/184
2019-08-26 10:38:02 +02:00
Beniamino Galvani
c97e0ce30b wifi: drop support for wpa-none key-mgmt
NM didn't support wpa-none for years because kernel drivers used to be
broken. Note that it wasn't even possible to *add* a connection with
wpa-none because it was rejected in nm_settings_add_connection_dbus().
Given that wpa-none is also deprecated in wpa_supplicant and is
considered insecure, drop altogether any reference to it.
2019-08-26 10:25:00 +02:00
Beniamino Galvani
73b3806228 wifi: expose IBSS_RSN capability
The new capability indicates whether the device supports WPA2/RSN in
an IBSS (ad-hoc) network.

https://bugzilla.gnome.org/show_bug.cgi?id=757823
2019-08-26 10:25:00 +02:00
Thomas Haller
6101be0e2e ifupdown: merge branch 'th/ifupdown-crash'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/235
2019-08-24 13:46:11 +02:00
Thomas Haller
e9ccc2da19 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
2019-08-24 13:45:54 +02:00
Thomas Haller
a49027ab22 ifupdown/tests: add test with duplicate interfaces
This file causes a crash [1], add it to the tests.
Note that the test only check parsing the file and the
crash happens in the "upper" layers. So, it's not really
a test for the crash. But at least have such a file in
our repository.

[1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/235
2019-08-24 13:38:33 +02:00
Thomas Haller
017a4b274f ifupdown/tests: cleanup tests by freeing Expected variable with nm_auto() 2019-08-24 13:31:19 +02:00
Thomas Haller
af277fdedc bluetooth: fix getting error code creating sdp-session in nm_bluez5_dun_connect() 2019-08-24 11:32:16 +02:00
Thomas Haller
25571bb639 bluetooth: fix leak in get_managed_objects_cb()
Fixes: 1ae5d53354 ('bluez: add support for BlueZ 5')
2019-08-23 11:54:09 +02:00
Thomas Haller
a63f9aad25 shared/hash: implement nm_hash_obfuscate_ptr() as inline function instead of macro
There is really no reason for this to be a macro. Our hash-related
helpers (like nm_hash_update_val()) are macros because they do some
shenigans to accept arguments of different (compile-time) types. But
the arguments for nm_hash_obfuscate_ptr() are well known and expected
of a certain form.

Note that with "-O2" some quick testing shows that the compiler no
longer inlines the function. But I guess that's fine, probably the
compiler knows best anyway.
2019-08-23 11:48:58 +02:00
Thomas Haller
aa100d89a4 core/logging: don't log plain pointer value from nm_log_ptr()
Logging pointer values might reveal information that can be used to defeat
ASLR. We should avoid that.

On the other hand, it's useful to tag a logging message with the pointer
value of the "source" of the message. It helps to correlate messages and
search for relevant messages in the log.

As a compromise, use NM_HASH_OBFUSCATE_PTR(), like we do at several places
already. For example, we also log

  <debug> [1566550899.7901] setup NMPlatform singleton (29a6af9867f2e5d0)

This obfuscated value is a 64 bit unsigned integer with the siphash24
hash of the raw value with a randomized seed. Of course, contrary to the
pointer value, there is a tiny chance that two different pointers hash
to the same identifier. However, that seems unlikely enough to be of no
concern. Note that this pointer value is only logged to aid debugging.
It is sufficiently unlikely that this causes confusion.

One other downside of printed the obfuscated value, is that you can no
longer read the pointer from the log and use it in gdb directly. That
might be sometimes convenient, but making this impossible is kinda the
purpose of this change.

As such, nm_log_ptr() becomes a bit of a misnomer. But not too bad, it
still is a good name. For example, if we wanted we could redefine the
NM_HASH_OBFUSCATE_PTR* macros when building "--with-more-asserts".
2019-08-23 11:19:17 +02:00
Lubomir Rintel
505208a448 contrib/rpm: install our dispatcher scripts into /usr/lib/NetworkManager
That's where they always should have been.
2019-08-23 08:52:13 +02:00
Maciek Borzecki
378099c60e cli: include BSSID to NMC_FIELDS_DEV_WIFI_LIST_COMMON
When using WiFi in an environment with multiple APs of the same SSID (eg.
conference venue, hotels), it is often useful to be able to identify particular
APs by their BSSID.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/235
2019-08-22 11:36:06 +02:00
Francesco Giudici
40647bd887 cli: prefer nm_assert() to g_assert*() 2019-08-22 11:35:53 +02:00
Francesco Giudici
1a91ef2dc6 cli: fix bad indentation 2019-08-22 11:35:38 +02:00
Francesco Giudici
ed5cd288c4 meson: fix build_clean.sh -w meson -w test
Fixes: 00bb6cdb4f ('build: fix meson warning about path separator in target')
2019-08-22 11:16:31 +02:00
Thomas Haller
a7d8fe0ea5 shared: allow negative timestamps for nm_utils_monotonic_timestamp_as_boottime() 2019-08-21 11:18:39 +02:00
Thomas Haller
2f8a4e90f0 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.
2019-08-20 16:28:28 +02:00
Thomas Haller
0e1748afe1 cli: cleanup unique_master_iface_ifname()
- use appropriate types for integer variables

- rework the confusing loop which would reset the loop-counter
  to start again.
2019-08-20 15:31:08 +02:00
Thomas Haller
e1ec22f74b cli: cleanup setting default interface-name 2019-08-20 15:24:15 +02:00
Lubomir Rintel
27d380b70e data: fix the ID_NET_DRIVER udev rule
Systemd v243 is complaining about the wrong substitution there. That is
sort of harmless, because systemd-udevd in that version doesn't need the
rule anyway. But still fix it, to avoid a warning.

Also, newer udevd's $PATH doesn't include sbin. That is also okay,
because we don't need the rule to actually work there. But fix it
anyway.

https://bugzilla.redhat.com/show_bug.cgi?id=1740655
2019-08-16 14:03:46 +02:00
Thomas Haller
3bca0661f4 cli: merge branch 'th/cli-modify-enums-and-cleanup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/234
2019-08-16 08:16:14 +02:00
Thomas Haller
cec39d76bd man/cli: better explain modifying properties regarding +/- modifiers 2019-08-16 08:16:02 +02:00
Thomas Haller
b789ce01e9 cli: fix handling modifier in nmc_read_connection_properties() for aliases
Various cleanups:

  - after detecting the modifier, remove it from the string right away.
    It's redundant and confusing to do it later.

  - rename variables and move to inner scope.

  - don't use g_str_split() to split the property name at the
    first dot. strchr() is sufficient.

Also, now that we strip the modifier from option early, they start also
working for aliases. There is no need to not support (or behave
differently) w.r.t. whether aliases support modifiers or not.

This fixes:

  $ nmcli connection modify r +ip4 192.168.5.2/24
  Error: invalid <setting>.<property> 'ip4'.
2019-08-16 08:16:02 +02:00
Thomas Haller
0825ec34fd cli: add NMMetaAccessorModifier enum instead of using "char" type
The enum values are unique throughout the source code so they
can easier be searched (e.g. with grep), compared to '\0'. It
is often interesting where a certain modifier is used, so searching
the source code is important to give relevant results.

Also, the modifier is really an enum and we shouldn't misuse char type.
If that would be a good idea in general, we wouldn't need any enums
at all. But we use them for good reasons.
2019-08-16 08:16:02 +02:00
Thomas Haller
de40eb0403 cli: reorder checks in nmc_setting_set_property() for modifier type
No notable change in behavior, but makes more sense this way.
2019-08-16 08:16:02 +02:00
Thomas Haller
036b793797 cli: support +/- modifiers for flags properties 2019-08-16 08:16:02 +02:00
Thomas Haller
4e51e844d9 libnm: fix NMSetting8021xAuthFlags to be a flags type
This is an API break, but probably not too bad. A lot of
things when using the type will work as before.
2019-08-16 08:16:02 +02:00
Thomas Haller
c1e40a4f39 shared: use nm_auto_unref_gtypeclass in _nm_utils_enum_from_str_full() 2019-08-16 08:16:02 +02:00
Lubomir Rintel
78b6fd47dc Revert "po: add Zanata configuration"
Not useful anymore.

This reverts commit c5f40c701e.
2019-08-15 23:07:11 +02:00
Lubomir Rintel
b171f20141 contrib/rpm: enable IWD (outside RHEL)
Let's enable the option to use IWD as an alternative to wpa_supplicant
for Wi-Fi support. People have been asking for this, it works, and is well
maintained.
2019-08-15 23:07:02 +02:00