Commit Graph

24195 Commits

Author SHA1 Message Date
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
Ludek Janda
ca8d54d5a1 po: RHEL 8.1 translations
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/242
(cherry picked from commit 9e57873e9c5cda8976d0cf00e08283ae080c52a9)
2019-08-15 14:41:39 +02:00
Yuri Chornoivan
1e3c359f72 po: update Ukrainian translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/240
2019-08-15 14:31:28 +02:00
Thomas Haller
02e5a8d10a cli: don't require "ifname" when adding connection
$ nmcli connection add type ethernet con-name t autoconnect no
  Error: ifname argument is required.

This reverts commit a91eafdf95 ('cli: 'con add': make ifname mandatory
(except bond,bridge,vlan) (bgo #698113)'). Apparently ifname argument was
required to avoid confusion (unexpected behavior). But I don't agree
that is an issue, it's just annoying. Often you really have just one
ethernet or Wi-Fi device, so this does not seem helpful.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/222
2019-08-13 11:19:36 +02:00
Thomas Haller
2c5176912d all: merge branch 'th/static-default-route'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/229
2019-08-13 10:45:33 +02:00
Thomas Haller
c167e0140b all: allow configuring default-routes as manual, static routes
Up until now, a default-route (with prefix length zero) could not
be configured directly. The user could only set ipv4.gateway,
ipv4.never-default, ipv4.route-metric and ipv4.route-table to influence
the setting of the default-route (respectively for IPv6).

That is a problematic limitation. For one, whether a route has prefix
length zero or non-zero does not make a fundamental difference. Also,
it makes it impossible to configure all the routing attributes that one can
configure otherwise for static routes. For example, the default-route could
not be configured as "onlink", could not have a special MTU, nor could it be
placed in a dedicated routing table.

Fix that by lifting the restriction. Note that "ipv4.never-default" does
not apply to /0 manual routes. Likewise, the previous manners of
configuring default-routes ("ipv4.gateway") don't conflict with manual
default-routes.

Server-side this all the pieces are already in place to accept a default-route
as static routes. This was done by earlier commits like 5c299454b4
('core: rework tracking of gateway/default-route in ip-config').

A long time ago, NMIPRoute would assert that the prefix length is
positive. That was relaxed by commit a2e93f2de4 ('libnm: allow zero
prefix length for NMIPRoute'), already before 1.0.0. Using libnm from
before 1.0.0 would result in assertion failures.

Note that the default-route-metric-penalty based on connectivity
checking applies to all /0 routes, even these static routes. Be they
added due to DHCP, "ipv4.gateway", "ipv4.routes" or "wireguard.peer-routes".
I wonder whether doing that unconditionally is desirable, and maybe
there should be a way to opt-out/opt-in for the entire profile or even
per-routes.

https://bugzilla.redhat.com/show_bug.cgi?id=1714438
2019-08-13 10:45:04 +02:00
Thomas Haller
539db43619 libnm: avoid heap allocation for checking valid routes in nm_ip_route_attribute_validate() 2019-08-13 10:45:04 +02:00
Thomas Haller
cc7b2cde95 libnm: set errno in nm_key_file_get_boolean() to distinguish between missing key and error
This is also what nm_keyfile_plugin_kf_get_int64() does. It's useful to
know whether a value was missing or invalid.
2019-08-13 10:45:04 +02:00
Thomas Haller
1533a3e5d1 dhcp: merge branch 'th/dhcp-factory-cleanup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/221
2019-08-13 10:41:03 +02:00
Thomas Haller
75503c8554 dhcp: minor refactoring to switch default IPv4 DHCP plugin to "nettools" with one-line change
Minor refactoring so that there is only a one-line change necessary to
flip the implementation of the "internal" DHCP plugin for IPv4 from
"systemd" to "nettools".

We don't do that yet, because there are still some issues (e.g. the
lease is not persisted for nettools plugin). Eventually we want to
switch, so prepare the code to be almost there.
2019-08-13 09:42:15 +02:00
Thomas Haller
b53e261427 dhcp: make "systemd" DHCP plugin configurable
We have the "internal" DHCP plugin. That's our preferred plugin,
and eventually we may drop all other plugins.

Currently, the "internal" plugin is based on code from systemd-networkd
and implemented in "src/dhcp/nm-dhcp-systemd.c". As this code is forked
we eventually want to switch to nettools' n-dhcp4 library (for IPv4).
For that reason we already have "src/dhcp/nm-dhcp-nettools.c".

Note that "nettools" can be configured as a DHCP plugin, but this configuration
is only experimental and for testing. There is never supposed to be a
"nettools" plugin, but eventually the "internal" plugin will switch
implementation.

We don't want to replace systemd-based implementation right away. Not until
we are sure that nettools works well. For that reason we keep them
both in parallel for a while.

This commit makes "systemd" DHCP plugin explicitly configurable
in NetworkManager.conf. Like "nettools" this is an undocumented option,
only for testing.

If you choose "internal" (the default), you get one of the
implementations (currently the "systemd" one). But by selecting
"systemd" or "nettools" explicitly, you can select the exact plugin.
2019-08-13 09:42:15 +02:00
Thomas Haller
8d8cc0da3d dhcp: log effectively used DHCP plugin type 2019-08-13 09:42:15 +02:00
Thomas Haller
b32cf71814 dhcp: cleanup selecting GType from DHCP client factory
Instead of returning a client-factory, return the GType right
away.
2019-08-13 09:42:15 +02:00
Thomas Haller
05175562f5 bluetooth: merge branch 'th/bluez-rework-1'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/236
2019-08-12 16:07:48 +02:00
Thomas Haller
84bf767520 NEWS: mention removal of BlueZ 4 support 2019-08-12 16:07:12 +02:00
Thomas Haller
3e8cba2e5b bluetooth: add _NMLOG() logging macro to NMBluezDevice 2019-08-12 16:07:12 +02:00
Thomas Haller
a76e906dca bluetooth: pass GDBusConnection to NMBluezDevice
No need to let NMBluezDevice ask for glib's G_BUS_TYPE_SYSTEM
connection. We already have the right D-Bus connection at hand,
just use it.
2019-08-12 16:07:12 +02:00
Thomas Haller
3c9b646524 bluetooth: drop BlueZ 4 support (2) 2019-08-12 16:07:05 +02:00
Thomas Haller
907ea97088 bluetooth: drop BlueZ 4 support (1)
BlueZ 5.0 was released in December 2012 and broke API with
BlueZ 4. NetworkManager supports Bluez 5 for years already.

Of course, version 4 is long gone by now, so remove it.
2019-08-12 16:05:30 +02:00
Thomas Haller
abfc14f79b libnm/doc: fix typo 2019-08-12 14:00:09 +02:00
Thomas Haller
04803a2bae libnm/doc: clarify NMMetered enum and how metered state in NetworkManager works 2019-08-12 13:52:19 +02:00
Piotr Drąg
a791dfba26 po: update Polish (pl) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/239
2019-08-12 11:34:49 +02:00
Thomas Haller
b80784a785 auth: drop unused idle-reason for NMAuthManagerCallId
We now only call the idle action with the same reason: authorized.
That is since we no longer use GDBusProxy, there are no other reasons
where we would fail.

Drop the unused code.
2019-08-10 10:36:17 +02:00