Commit Graph

25333 Commits

Author SHA1 Message Date
Thomas Haller
431c349b47 libnm: enable macros for marking sync libnm methods as deprecated 2020-03-23 09:38:24 +01:00
Thomas Haller
7c2bcd4bc9 libnm: drop unused code 2020-03-23 09:38:23 +01:00
Thomas Haller
42edeb62a3 cli: use async method D-Bus for nmcli radio wifi on|off
Showcase nm_client_dbus_set_property().

Thereby, also print error messages and return an error if
the command fails.

Also, enable PolicyKit authentication (although, I think there are
some bugs with this still).
2020-03-23 09:38:23 +01:00
Thomas Haller
c6c15c2c25 cli: use async method D-Bus for nmcli networking on|off
Previously, we would call the synchronous nm_client_networking_set_enabled()
method. There were 3 problems:

1) nmcli ignored the return value, that means, if the request failed with
  access denied it would just silently pretend that it succeeded.

2) nmcli first called nmc_start_polkit_agent_start_try(), but when
  invoking the synchronous method, the main context is busy and a
  polkit request cannot possibly be handled.

3) nm_client_networking_set_enabled() is deprecated.

Fix all of these, by calling the D-Bus method directly.

Policykit authentication requests are only handled partly. There
seems to be an unrelated race/bug. Now it works sometimes.
2020-03-23 09:37:53 +01:00
Thomas Haller
d99d1dc265 cli: replace deprecated and synchronous nm_client_set_logging()
This is more a showcase for using nm_client_dbus_call(), than a
real use.

In this case, nmcli was mostly fine to just invoke the synchronous API
and not care about the problems that it had.

Still, replace it, and show the suggested alternative.
2020-03-23 09:33:52 +01:00
Thomas Haller
06da903bb6 libnm: advise using D-Bus instead of deprecated synchronous methods
With 1.22, various synchronous functions for invoking D-Bus methods were
deprecated. The reason was that D-Bus is fundamentally asynchronous, and
providing synchronous API in NMClient is inherently wrong. That is
because NMClient essentially is a cache of the D-Bus API, and invoking
g_dbus_connection_call_sync() messes up the order of events from D-Bus.
In particular, when the synchronous function completes, the content of
the cache does not yet reflect the change.

Since they got deprecated, the question is with what to replace them.

Instead of adding a (e.g.) nm_client_networking_set_enabled_async()
for nm_client_networking_set_enabled(), just expect the user to call
D-Bus directly.

D-Bus itself defines a reasonable API, and with GDBusConnection it
is fine (and convenient) to just call D-Bus operations directly.
Often libraries try to abstract D-Bus by providing convenience
wrappers around D-Bus API. I think that often is wrong and unnecessary.

Note that libnm's NMClient does a lot more than just wrapping simple
D-Bus calls. It provides a complete client-side cache of the D-Bus
interface. As such, what libnm's NMClient does is more than simple
wrappers around D-Bus. NMClient is a reasonable thing to do.

However, it is unnecessary to add API like nm_client_networking_set_enabled_async()
that only calls g_dbus_connection_call(). Don't pretend that we would need such
trivial wrappers in libnm.

Instead, recommend to use g_dbus_connection_call(). Or alternatively,
the convenience wrappers nm_client_dbus_call() and
nm_client_dbus_set_property().
2020-03-23 09:33:51 +01:00
Thomas Haller
a7b8c82ee2 libnm: add nm_client_dbus_set_property() API
Similar to nm_client_dbus_call(), but useful for setting a D-Bus
property on NetworkManager's D-Bus interface.

Note that we currently have various synchronous API for setting D-Bus
properties (like nm_client_networking_set_enabled()). Synchronous
API does not play well with the content of NMClient's cache, and was
thus deprecated. However, until now no async variant exists.

Instead of adding multiple async operations, I think it should be
sufficient to only add one nm_client_dbus_set_property() property.
It's still reasonably convenient to use for setting a property.
2020-03-23 09:33:01 +01:00
Thomas Haller
1a36bdbb2c libnm: add nm_client_dbus_call() API
Add an API for calling D-Bus methods arbitrary objects of
NetworkManager's API.

Of course, this is basically just a call to g_dbus_connection_call(),
using the current name owner, nm_client_get_dbus_connection() and
nm_client_get_main_context().

All of this could also be achieved without this new API. However,
nm_client_dbus_call() also gracefully handles if the current name
owner is %NULL.

It's a valid concern whether such API is useful, as the users already
have all pieces to do it themself. I think it is.
2020-03-23 09:32:04 +01:00
Thomas Haller
0f15d5aa40 shared: allow nm_dbus_connection_call_finish_variant_cb() with D-Bus methods that have no return value 2020-03-23 09:32:04 +01:00
Thomas Haller
61615781c5 libnm/doc: fix gtk-doc for deprecated markers in libnm 2020-03-23 09:32:04 +01:00
Thomas Haller
2686de2ede wifi: merge branch 'blocktrron/owe-tm'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/442
2020-03-22 11:08:57 +01:00
Thomas Haller
277044de10 core/wifi: minor cleanup in _bss_info_properties_changed()
Move local variables to inner scope.

Also, drop code comment that doesn't give additional information
beyond what is already plainly visible in source code.
2020-03-22 11:07:37 +01:00
Thomas Haller
7ccd2bb35e core/wifi: always set owe_transition_mode output in nm_wifi_utils_parse_ies()
... and rename output variable.
2020-03-22 11:07:24 +01:00
David Bauer
37e7fa38c2 nm-supplicant-interface: enable OWE security when transition mode is available
This pull requests sets the OWE flag for an open network advertising an
OWE enabled transition BSSID. This way, hostapd will automatically
connect to the OWE secured BSSID advertised in the transition mode
information element.

Signed-off-by: David Bauer <mail@david-bauer.net>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/442
2020-03-22 11:03:00 +01:00
Thomas Haller
11797f4ad4 supplicant: fix crash setting supplicant state down
When we receive a "InterfaceRemoved" signal, we will end up calling
set_state_down(). That emits a "state" change signal, which causes
NMDeviceWifi to unref the supplicant interface. This may already
give up the last reference, and we cleanup the supplicant state
(by again calling set_state_down()). When we return, set_state_down()
will crash because it operates on an already destroyed instance.

Avoid that by keeping a reference to the interface during set_state_down().

Fixes: b83f07916a ('supplicant: large rework of wpa_supplicant handling')

https://bugzilla.redhat.com/show_bug.cgi?id=1815058
2020-03-20 11:34:01 +01:00
Thomas Haller
c03f88575d cli: fix nmcli device wifi with no Wi-Fi devices available
Fixes: db396cea9d ('cli: rework do_device_wifi_list() to scan and print Wi-Fi list')
2020-03-20 10:38:09 +01:00
Antonio Cardace
8d6998cb77 nm-setting-bond: merge branch 'ac/fix_add_miimon'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/438
2020-03-19 17:26:32 +01:00
Antonio Cardace
97d3f1b4b9 nm-setting-bond: don't take default values into account when comparing options
This solves a bug exposed by the following cmds:
$ nmcli c add type bond ifname bond0 con-name bond0
$ nmcli c modify bond0 +bond.options miimon=100
$ nmcli -f bond.options c show bond0
bond.options:                           mode=balance-rr

Here we just added the option 'miimon=100', but it doesn't get saved in
because nm_settings_connection_set_connection() which is responsible for
actually updating the connection compares the new connection with old
one and if and only if the 2 are different the update is carried out.

The bug is triggered because when comparing, if default values are taken into
account, then having 'miimon=100' or not having it it's essentially the
same for compare(). While this doesn't cause a bond to have a wrong
setting when activated it's wrong from a user experience point of view
and thus must be fixed.

When this patch is applied, the above
commands will give the following results:
$ nmcli c add type bond ifname bond0 con-name bond0
$ nmcli c modify bond0 +bond.options miimon=100
$ nmcli -f bond.options c show bond0
bond.options:                           mode=balance-rr,miimon=100

Fix unit tests and also add a new case covering this bug.

https://bugzilla.redhat.com/show_bug.cgi?id=1806549
2020-03-19 17:26:08 +01:00
Antonio Cardace
fcbef9b6d3 ifcfg-rh: add 'timestamp' property before comparing a reread connection
Since ifcfg-rh doesn't write out to file the 'connection.timestamp' property
let's add it before comparing an updated connection with the plugin's reread
one otherwise the comparison operation would always fail.
The fix is not necessary for the keyfile plugin, because the reader/writer
correctly reads/writes the connection timestamp.
2020-03-19 17:26:08 +01:00
Antonio Cardace
fc8784a011 libnm-core: fix wording for 'nm_sett_info_propert_type_mac_addrees'
$ sed -i 's/nm_sett_info_propert_type_mac_addrees/nm_sett_info_propert_type_mac_address/' $(git grep -l 'nm_sett_info_propert_type_mac_addrees' | tr '\n' ' ')
2020-03-19 16:59:07 +01:00
Thomas Haller
3e869c107d cli: fix use after free in wifi_list_finish()
Fixes: db396cea9d ('cli: rework do_device_wifi_list() to scan and print Wi-Fi list')
2020-03-19 14:45:38 +01:00
Thomas Haller
24a714d12e cli: merge branch 'th/cli-device-wifi-list-rework'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/443
2020-03-19 10:47:56 +01:00
Thomas Haller
db396cea9d cli: rework do_device_wifi_list() to scan and print Wi-Fi list
Drop the special casing of not scanning. Now do_device_wifi_list()
always handles the scan list in a callback.

Also fix the error code for scanning for a certain "bssid", which
previously was not set if scanning was not performed:

  $ nmcli device wifi list --rescan no bssid bogus
  Success
2020-03-19 10:46:58 +01:00
Thomas Haller
81d12f020a cli: use nm_utils_hwaddr_matches() for matching BSSID in wifi_print_aps()
We have a proper implementation for comparing MAC addresses. Don't
reimplement it differently.
2020-03-19 10:40:13 +01:00
Antonio Cardace
17082a868e gitlab-ci: use ruby:2.7 for triage pipeline
This fixes the pipeline as 'gem' will be installed by default in the
container image.

Also fix wording and run gitlab-triage in debug mode to get more output.
2020-03-18 17:40:59 +01:00
Antonio Cardace
968e7898e6 gitlab-ci: add scheduled pipeline to triage inactive issues and MRs 2020-03-18 16:25:55 +01:00
Thomas Haller
a6574b7124 n-dhcp4: fallback to CLOCK_MONOTONIC for timerfd (resync with upstream)
The upstream merge request [1] was solved differently from
commit f49ce41214 ('client: fallback to CLOCK_MONOTONIC for timerfd').

Resync with upstream.

[1] https://github.com/nettools/n-dhcp4/pull/13
[2] a0bb7c69a1
2020-03-18 16:10:49 +01:00
Thomas Haller
6c837a366b supplicant: combine multiple log lines about supported supplicant features
For many purposes, the supplicant features are not very interesting (as
they are also mostly static for a certain release/distribution). Combine
the multiple logging lines into one.

Also, sort the NMSupplCapType enum values consistently with the order
in which we log them.

Also, rename the logging output for features to match the enum name.
E.g. "FAST" instead of "EAP-FAST".

Now:

  > supplicant: supported features: AP+ PMF+ FILS- P2P+ FT+ SHA384+ MESH+ FAST+ WFD+
2020-03-18 09:52:16 +01:00
Beniamino Galvani
8fe2046f08 core: avoid unbound recursion in IPv6 connection sharing
When a device gets a prefix delegation, we call
nm_device_use_ip6_subnet() for all other devices that have IPv6
sharing enabled, which changes the current IPv6 configuration and
notifies NMPolicy. When updating the DNS configuration in NMPolicy, we
should notify all devices except the one that triggered the change.

https://bugzilla.redhat.com/show_bug.cgi?id=1488030
2020-03-17 21:42:42 +01:00
Thomas Haller
1a387f9ef9 license: add Soapux to RELICENSE.md
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/397#note_438764
2020-03-17 16:26:57 +01:00
Thomas Haller
fe1005f876 license: fix Dan's email address in RELICENSE.md
The email address should match the commit's authors and
what we track in .mailmap file. Adjust the email address
for Dan.
2020-03-17 15:10:59 +01:00
Thomas Haller
2ae81250c4 license: add Christian to RELICENSE.md
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/397#note_438590
2020-03-17 14:47:40 +01:00
Thomas Haller
b2a0738765 man: improve manual page for nm-online
https://bugzilla.redhat.com/show_bug.cgi?id=1706646
2020-03-17 13:33:51 +01:00
Thomas Haller
32d79f6c6e license: add Jan to RELICENSE.md
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/397#note_438497
2020-03-17 13:01:29 +01:00
Thomas Haller
f34510988f license: add Corentin to RELICENSE.md
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/397#note_438328
2020-03-17 11:36:30 +01:00
Thomas Haller
13f9a742b4 license: add Javier to RELICENSE.md
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/397#note_438327
2020-03-17 11:27:51 +01:00
Thomas Haller
b97bf184a1 license: add Jan to RELICENSE.md
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/397#note_438290
2020-03-17 09:30:04 +01:00
Thomas Haller
9a2a8feb41 license: add Benjamin to RELICENSE.md
https://mail.gnome.org/archives/networkmanager-list/2020-March/msg00023.html
2020-03-17 09:27:56 +01:00
Thomas Haller
cd21e5fdff device: merge branch 'th/act-stage2-re-entrant'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/427
2020-03-17 08:16:52 +01:00
Thomas Haller
7af61e2aa0 device: make device stage2 reentrant for NMDeviceBridge 2020-03-17 08:13:22 +01:00
Thomas Haller
ea3912b70b device: make device stage2 reentrant for NMDeviceAdsl
Configuration stages like act_stage2_config() can postpone progressing
to the next stage. Currently, when the condition that we wait for gets
satisfied, the code schedules the next stage from there.

I think that is wrong, because when we postpone from act_stage2_config(),
follow up steps of stage2 get skipped. Thus, when we are ready to progress,
the class should enter stage 2 again.

This requires that stage2 becomes reentrant and that the code reenters the
same stage.
2020-03-17 08:13:22 +01:00
Thomas Haller
99cb791813 device: allow scheduling nm_device_activate_schedule_stage2_device_config() right away
We usually want to schedule stage2 when we just completed with the previous
stage (or, if we are currently in stage2, and want to re-enter it).

In those cases, the conditions are often right to just proceed right away.
No need to schedule the stage on an idle handler. Allow to invoke stage2
right away.
2020-03-17 08:13:22 +01:00
Thomas Haller
3d78740398 device: allow scheduling nm_device_activate_schedule_stage1_prepare() right away
There was only API to schedule the stage on an idle handler.

Sometimes, we are just in the right situation to schedule the stage
right away. It should be possibly to avoid going through the extra hop.

For now, none of the caller makes use of this. So, there isn't any
actual change in behavior. But by adding this possibility, we may do
use in the future.
2020-03-17 08:13:22 +01:00
Thomas Haller
5979972e20 device/wifi: don't postpone act_stage2_config() for iwd when nothing to wait 2020-03-17 08:13:22 +01:00
Thomas Haller
aa991916dc device: various code cleanups in devices
Mostly just cleanups, there should be no significant change in behavior.
2020-03-17 08:09:32 +01:00
Thomas Haller
607a22b900 libnm-core: minor cleanup checks in "nm-setting-adsl.c"'s verify() 2020-03-17 08:02:54 +01:00
Thomas Haller
d3e5eab734 shared: add nm_g_variant_is_of_type() helper 2020-03-17 08:02:54 +01:00
Thomas Haller
c3bfd57c69 cli: merge branch 'th/cli-device-wifi-cleanup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/435
2020-03-16 13:44:38 +01:00
Thomas Haller
3d2b982fb7 cli: fix out of bounds access in _print_fill()
cols_len might be larger than header_row->len. That is when
the cols has entries that are not leaf entries (which currently
I think is never the case).

Fix it to use the right variable for the length of the row.
2020-03-16 13:44:12 +01:00
Thomas Haller
5bef7d7453 cli: minor cleanup dropping unnecessary local variables 2020-03-16 13:44:12 +01:00