Commit Graph

30304 Commits

Author SHA1 Message Date
Thomas Haller
c19b5d76c2 contrib: install "policykit-1" package on Debian
This is needed to get "/usr/share/gettext/its/polkit.its",
otherwise msgfmt will fail on Debian:

  /usr/bin/msgfmt: cannot locate ITS rules for data/org.freedesktop.NetworkManager.policy.in
2022-03-16 00:58:28 +01:00
Thomas Haller
f307e12080 std-aux: cast NM_IN_SET_SET() operands to "int" for "-Wbitwise-instead-of-logical" warning
Clang 14 has a new warning "-Wbitwise-instead-of-logical", and it warns
about our usage with NM_IN_SET_SE()/NM_IN_STRSET_SE(). It complains that we
are using '|' with boolean operands. Which is true (and intended), as we bitwise-or
the result of the '==' comparisons.

Work around the warning by casting the operands to "int". Note that
in C, the comparison operators have already a type "int", so this cast
should not result in any changes in the compiled code.

    ../src/libnm-core-impl/tests/test-general.c:9415:17: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
        _ASSERT(2, !NM_IN_SET_SE(-1, G(1), G(2)));
        ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../src/libnm-std-aux/nm-std-aux.h:800:30: note: expanded from macro 'NM_IN_SET_SE'
    #define NM_IN_SET_SE(x, ...) _NM_IN_SET(|, typeof(x), x, __VA_ARGS__)
                                 ^
    ../src/libnm-std-aux/nm-std-aux.h:789:39: note: expanded from macro '_NM_IN_SET'
            !!(NM_VA_ARGS_FOREACH(, , op, _NM_IN_SET_OP, __VA_ARGS__)); \
                                          ^
    ../src/libnm-std-aux/nm-std-aux.h:772:20: note: expanded from macro 'NM_VA_ARGS_FOREACH'
                       op,                                                   \
                       ^
    note: (skipping 7 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
    ../src/libnm-glib-aux/nm-macros-internal.h:1603:47: note: expanded from macro '_G_BOOLEAN_EXPR'
    #define _G_BOOLEAN_EXPR(expr) NM_BOOLEAN_EXPR(expr)
                                  ~~~~~~~~~~~~~~~~^~~~~
    ../src/libnm-std-aux/nm-std-aux.h:167:62: note: expanded from macro 'NM_BOOLEAN_EXPR'
    #define NM_BOOLEAN_EXPR(expr) _NM_BOOLEAN_EXPR_IMPL(NM_UNIQ, expr)
                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
    ../src/libnm-std-aux/nm-std-aux.h:161:13: note: expanded from macro '_NM_BOOLEAN_EXPR_IMPL'
            if (expr)                      \
                ^~~~
    ../src/libnm-core-impl/tests/test-general.c:9415:17: note: cast one or both operands to int to silence this warning
    ../src/libnm-std-aux/nm-std-aux.h:800:30: note: expanded from macro 'NM_IN_SET_SE'
    #define NM_IN_SET_SE(x, ...) _NM_IN_SET(|, typeof(x), x, __VA_ARGS__)
                                 ^
    ../src/libnm-std-aux/nm-std-aux.h:789:39: note: expanded from macro '_NM_IN_SET'
            !!(NM_VA_ARGS_FOREACH(, , op, _NM_IN_SET_OP, __VA_ARGS__)); \
                                          ^
2022-03-16 00:57:17 +01:00
Yuri Chornoivan
bf5ca02ba8 po: update Ukrainian (uk) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1145
2022-03-14 13:59:01 +01:00
Thomas Haller
45d2537116 glib-aux: restrict NM_PRAGMA_WARNING_DISABLE_DANGLING_POINTER workaround to gcc 12.0.1
This was a bug in gcc 12 (<= 12.0.1). Restrict the macro further
for when we disable the warning.

See-also: https://bugzilla.redhat.com/show_bug.cgi?id=2056613
2022-03-14 13:51:29 +01:00
Thomas Haller
1d6080827b coding-style: fix formatting 2022-03-14 13:01:06 +01:00
Beniamino Galvani
e2fe97a25f merge: branch 'bg/wifi-disabled-freq'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1142
https://bugzilla.redhat.com/show_bug.cgi?id=2062785
2022-03-14 09:22:30 +01:00
Beniamino Galvani
5abb113386 wifi: ignore disabled frequencies
Frequencies with the 'disabled' flag are supported by the driver but
disabled in the current regulatory domain. Don't add them to the list
of supported frequencies since they are not usable.

This is especially needed since commit f18bf17dea ('wifi: cleanup
ensure_hotspot_frequency()'), as now NetworkManager explicitly sets a
random, stable channel for Wi-Fi hotspots. If the choosen channel is
disabled, the hotspot fails to start.

Disabled channels are displayed in the 'iw phy' output as '(disabled)':

                [...]
                Frequencies:
                        * 2412 MHz [1] (30.0 dBm)
                        * 2417 MHz [2] (30.0 dBm)
                        * 2422 MHz [3] (30.0 dBm)
                        * 2427 MHz [4] (30.0 dBm)
                        * 2432 MHz [5] (30.0 dBm)
                        * 2437 MHz [6] (30.0 dBm)
                        * 2442 MHz [7] (30.0 dBm)
                        * 2447 MHz [8] (30.0 dBm)
                        * 2452 MHz [9] (30.0 dBm)
                        * 2457 MHz [10] (30.0 dBm)
                        * 2462 MHz [11] (30.0 dBm)
                        * 2467 MHz [12] (disabled)
                        * 2472 MHz [13] (disabled)
                        * 2484 MHz [14] (disabled)

Note that currently NM loads the list only at startup and therefore,
in case of a change of regulatory domain, a restart of the daemon is
needed to have the list updated. This needs to be improved.

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

Fixes: f18bf17dea ('wifi: cleanup ensure_hotspot_frequency()')
2022-03-14 08:50:28 +01:00
Beniamino Galvani
3a41f6539e platform: rework initialization of wifi frequencies
Iterate only once over the netlink array, and realloc the buffer when
needed.
2022-03-14 08:50:28 +01:00
Lubomir Rintel
9863475b2d merge: branch 'lr/wep-cli'
This makes it more obvious in client when a feature that will not work
(now or in future) is being used. The motivation is to phase out WEP nicely.

To keep this simple this does not impose any policy decisions, nor is
configurable (contrary to what i've suggested before).

The policy on whether a connection activation will succeed or not is left
to the daemon. For WEP the idea is to delegate the decision further to the
supplicant while also provide a reasonable error handling [1].

[1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1138

The lack of configurability is due to the fact that WEP is going away
everywhere, regardless of whether it is enabled at the moment (Fedora 36)
or not (RHEL 9).

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1139
https://bugzilla.redhat.com/show_bug.cgi?id=2030997
2022-03-13 18:25:43 +01:00
Lubomir Rintel
5b4b00b8d2 cli: connection: check for deprecated features on "add"/"modify"
If the user happens to create a WiMax or Wi-Fi WEP connection they get a
warning.
2022-03-13 18:23:44 +01:00
Lubomir Rintel
061c342474 cli: connection: check for warnings after "modify"
Run the same checks after "nmcli c modify" as we do for "nmcli c add".
That is -- warn if the resulting connection has a connection ID
collision.
2022-03-13 18:23:44 +01:00
Lubomir Rintel
b3f79ac366 cli: connection: factor out warning from "add" callback
We sometimes emit warnings after a connection is added. Currently
there's a warning when the connection ID collides with another one (and
a suggestion to use an UUID instead).

Let's move the check into a separate routine, so that we can reuse it
elsewhere, such as on connection "modify" (in a following commit).
2022-03-13 18:23:44 +01:00
Lubomir Rintel
f377114d6e cli: connection: check for deprecated features
Check if a connection uses something that is likely not to work --
either now or in future.

The ultimate decision on whether it's going to work is up to the daemon.
We just use the result to color the connection differently to provide
slight visual cue to the user.
2022-03-13 18:23:44 +01:00
Lubomir Rintel
550e3bbdd8 cli: device: color WEP APs differently in "wifi list"
Provide a visual cue suggesting that an attempt to associate with an WEP
access point might not work. Whether it actually will work up to the daemon.
2022-03-13 18:23:44 +01:00
Lubomir Rintel
422ae6bea6 cli: device: factor out checking whether an AP is a WEP one
This is going to be useful elsewhere. We're going to mark WEP APs as
deprecated.
2022-03-13 18:23:44 +01:00
Lubomir Rintel
cd7687ff60 cli: add color codes for deprecated features
Follow-up commits are going color Wi-Fi networks and connections that rely
on deprecated features differently, to provide a visual cue.

Add color definitions for those.
2022-03-13 18:23:44 +01:00
Thomas Haller
912effaec0 core: merge branch 'th/ports-cleanup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1132
2022-03-13 12:10:44 +01:00
Thomas Haller
8aaee8c50c core/device: avoid logging "%p" format and use obfuscated ptr 2022-03-13 12:08:59 +01:00
Thomas Haller
4629506b80 core/device: rename nm_device_master_release_one_slave()
We have nm_device_master_add_slave(). This should be mirrored by
nm_device_master_release_slave() (not release-one-slave).

Thereby, also rename nm_device_master_release_slaves() to
nm_device_master_release_slaves_all() to make it clearer.
2022-03-13 12:08:52 +01:00
Thomas Haller
17ac71cd58 core/device: add ReleaseSlaveType argument for nm_device_master_release_one_slave()
I find the two (dependent) booleans "configure" and "force" confusing.
nm_device_master_release_one_slave() has many callers, it's interesting
to be able to grep for the release-type. Add an enum to make this more
readable.
2022-03-13 12:08:08 +01:00
Thomas Haller
a566fd8cf4 core/device: use c_list_for_each_entry() for interating of slaves list
This convenience macro is just shorter, resulting in more(?) readable
code and less clutter.
2022-03-13 12:02:09 +01:00
Thomas Haller
53406e721d core/trivial: rename parameter to link_changed_cb()
"info" is not a good name. Variables of this kind are usually
called "plink" or "pllink". Rename.
2022-03-13 12:02:08 +01:00
Thomas Haller
6f948fcd2e core: use nm_dbus_manager_lookup_object_with_type()
I think this makes it clearer that we should always look for a certain
type, because NMDBusManager tracks all D-Bus objects.
2022-03-13 12:02:08 +01:00
Thomas Haller
de61722efe core: add nm_dbus_manager_lookup_object_with_type() helper
This makes the non-obvious fact clearer, that when you look up an object
by an untrusted, user-provided path, it might not be the object type you
are looking for. In basically all cases, you need to check that the
result is of the expected type. This helper makes that clearer.
2022-03-13 12:02:07 +01:00
Thomas Haller
256a4cb5d6 all: merge branch 'th/gsource-attach'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1141
2022-03-13 12:01:13 +01:00
Thomas Haller
216c46c881 all: prefer nm wrappers to automatically attach GSource to default context
We often create the source with default priority, no destroy function and
attach it to the default context (g_main_context_default()). For that
case, we have wrapper functions like nm_g_timeout_add_source()
and nm_g_idle_add_source(). Use those.

There should be no change in behavior.
2022-03-13 11:59:42 +01:00
Thomas Haller
9b030a3988 all: change scheduling priority for idle actions to G_PRIORITY_DEFAULT_IDLE
g_idle_add() uses G_PRIORITY_DEFAULT_IDLE priority. Most of the time we don't
care much about the priority.

But at the places that this patch changes, I think that using
G_PRIORITY_DEFAULT_IDLE (and following g_idle_add()) is more correct. The
reason for this is not very strong, except that it's probably the better
choice. And the old choice was made because I didn't realize that
g_idle_add() uses another default priority. Hence, the old choice was not
for good reasons either.
2022-03-13 11:59:42 +01:00
Thomas Haller
15e8837945 glib-aux: fix priority for nm_g_idle_add_source()
nm_g_idle_add_source() is supposed to work like g_idle_add(). Use the correct
priority.

I think this causes little actual problems, because usually we don't
carefully tune the priorities and would be mostly fine with either.

Fixes: 6b18fc252d ('shared: add nm_g_{idle,timeout}_add_source() helpers')
2022-03-13 11:59:31 +01:00
Fernando Fernandez Mancera
482d99f549 bond: do not reapply when setting fail_over_mac
When a bond has ports attached kernel disallows writing
`/sys/devices/virtual/net/bond0/bonding/fail_over_mac`. NetworkManager
should fail when trying to do reapply if `fail_over_mac` needs to be
set.

https://bugzilla.redhat.com/2003214
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1143
2022-03-11 20:49:10 +01:00
Thomas Haller
ae0cc9618c libnm: fix assertion in NMClient checking for current main context
NMClient is strongly tied to the GMainContext with which it was created.
Several operations must only be called from within the context. There
was an assertion for that.

However, creating (and init_async()) should be allowed to call not
from within the GMainContext. So if the current context has no owner
(is not acquired), then it's also OK.

Fix the assertion for that.

Fixes: ce0e898fb4 ('libnm: refactor caching of D-Bus objects in NMClient')
2022-03-11 12:11:44 +01:00
Thomas Haller
5dc9307a34 glib-aux: add nm_g_main_context_can_acquire() helper 2022-03-11 12:10:18 +01:00
Thomas Haller
9c8a937280 core/trivial: add code comment to nm_utils_stable_id_parse() 2022-03-11 10:21:44 +01:00
Thomas Haller
8fc40206ec core: use NM_STR_HAS_PREFIX() in nm_utils_stable_id_parse()
NM_STR_HAS_PREFIX() expands to one `strncpy()`, with the length being a
compile time constant. It's faster than calling through glib.
2022-03-11 10:09:16 +01:00
Thomas Haller
69376e20a5 core: rename nm_utils_host_id_get_timestamp_ns() to "nsec"
We change more and more to prefer "nsec" (and "usec", "msec", and "sec")
as abbreviations, instead of "ns" (and "us", "ms", "s"). Rename.
2022-03-11 09:43:02 +01:00
Thomas Haller
513c0b3f24 core/trivial: reword code comment about fake host-id timestamp 2022-03-11 09:43:02 +01:00
Thomas Haller
20060327d4 libnm/docs: add reference to secret-key in description for stable-id 2022-03-11 09:27:33 +01:00
Thomas Haller
63664719be core/dhcp: use gs_free_error in NMDhcpDhcpcd's ip4_start()
It just seems less error prone. Use the cleanup attribute.
2022-03-09 23:14:39 +01:00
Thomas Haller
fd50323232 core/dhcp: fix uninitialized GError in NMDhcpDhcpcd's ip4_start()
Found with `git grep 'GError.*[^,)];'| grep ' *= *NULL;' -v`

Fixes: a2abd15fe0 ('DHCP: Support dhcpcd-9.x')
2022-03-09 23:14:38 +01:00
Thomas Haller
a9d521bf8c libnm: fix uninitialized GError in NMClient's _init_start_cancel_on_idle_cb()
Found with `git grep 'GError.*[^,)];'| grep ' *= *NULL;' -v`

Fixes: ce0e898fb4 ('libnm: refactor caching of D-Bus objects in NMClient')
2022-03-09 23:14:37 +01:00
Thomas Haller
43748d2980 core/team: fix leak and uninitialized GError in NMDeviceTeam's constructed()
Found with `git grep 'GError.*[^,)];'| grep ' *= *NULL;' -v`

Fixes: d689380cfc ('team: support operation without D-Bus')
2022-03-09 23:14:37 +01:00
Thomas Haller
a628a35e80 contrib/checkpatch: try to warn about uninitialized GError variables
When we have a GError* variable on the stack, we usually want to pass
it on to function that can fail. In that case, the variable MUST be
initialized to NULL. This is an easy mistake to make.

Note that this check still can have lots of false positives, for
example, if you have a struct with an GError field. In that case, you
would need to ensure that the entire struct is initialized. Ignore the
warning then.

Also, the check misses if you declare multiple variables on one line.
But that is already discouraged by our style.
2022-03-09 23:14:37 +01:00
Beniamino Galvani
2ccfc86939 release: bump version to 1.37.2 (development) 2022-03-09 17:07:24 +01:00
Beniamino Galvani
429228bfdd NEWS: update 2022-03-09 15:32:51 +01:00
Wen Liang
549761b0ad libnm: fix crash during the restart after killed
When cloud-init job (metadata service crawler) starts, it sends the
SIGTERM signal to nm-cloud-setup and force the nm-cloud-setup to
restart, however, because the error is not initialized as NULL in
`_init_start_cancelled_cb()` before it is set, nm-cloud-setup will hit
a dumped core.

TO fix it, initialize the error as NULL in `_init_start_cancelled_cb()`.

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

Fixes: ce0e898fb4 ('libnm: refactor caching of D-Bus objects in NMClient')

Backtrace:

 #0  g_logv (log_domain=0x7f833a872071 "GLib", log_level=G_LOG_LEVEL_WARNING, format=<optimized out>, args=<optimized out>) at ../glib/gmessages.c:1413
 #1  0x00007f833a81f043 in g_log (log_domain=<optimized out>, log_level=<optimized out>, format=<optimized out>) at ../glib/gmessages.c:1451
 #2  0x00007f833ab97230 in nm_utils_error_set_cancelled (is_disposing=<optimized out>, instance_name=<optimized out>, error=0x7ffff79cb980) at src/libnm-glib-aux/nm-shared-utils.c:2599
 #3  nm_utils_error_set_cancelled (is_disposing=0, instance_name=0x0, error=0x7ffff79cb980) at src/libnm-glib-aux/nm-shared-utils.c:2590
 #4  _init_start_cancelled_cb (cancellable=<optimized out>, user_data=0x5640ca292150) at src/libnm-client-impl/nm-client.c:7324
 #5  _init_start_cancelled_cb (cancellable=<optimized out>, user_data=0x5640ca292150) at src/libnm-client-impl/nm-client.c:7307
 #6  0x00007f833a93094a in _g_closure_invoke_va (param_types=0x0, n_params=<optimized out>, args=0x7ffff79cbb40, instance=0x5640ca267020, return_value=0x0, closure=0x5640ca29d430)
     at ../gobject/gclosure.c:873
 #7  g_signal_emit_valist (instance=0x5640ca267020, signal_id=<optimized out>, detail=0, var_args=var_args@entry=0x7ffff79cbb40) at ../gobject/gsignal.c:3406
 #8  0x00007f833a930a93 in g_signal_emit (instance=instance@entry=0x5640ca267020, signal_id=<optimized out>, detail=detail@entry=0) at ../gobject/gsignal.c:3553
 #9  0x00007f833a9a6475 in g_cancellable_cancel (cancellable=0x5640ca267020) at ../gio/gcancellable.c:513
 #10 g_cancellable_cancel (cancellable=0x5640ca267020) at ../gio/gcancellable.c:487
 #11 0x00005640ca1a8bd4 in sigterm_handler (user_data=0x5640ca267020) at src/nm-cloud-setup/main.c:599
 #12 0x00007f833a819d4f in g_main_dispatch (context=0x5640ca268ef0) at ../glib/gmain.c:3337
 #13 g_main_context_dispatch (context=0x5640ca268ef0) at ../glib/gmain.c:4055
 #14 0x00007f833a86e608 in g_main_context_iterate.constprop.0 (context=0x5640ca268ef0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../glib/gmain.c:4131
 #15 0x00007f833a819463 in g_main_loop_run (loop=0x5640ca24fdb0) at ../glib/gmain.c:4329
 #16 0x00005640ca1a6d04 in nmc_client_new_waitsync (cancellable=0x5640ca267020, out_nmc=0x7ffff79cbfa0, error=0x7ffff79cbf98, first_property_name=0x5640ca1b11db "instance-flags",
     first_property_name=0x5640ca1b11db "instance-flags") at src/libnm-client-aux-extern/nm-libnm-aux.c:129
 #17 0x00005640ca1a3863 in main (argc=1, argv=<optimized out>) at src/nm-cloud-setup/main.c:639
2022-03-09 09:24:25 -05:00
Lubomir Rintel
7f1840bbb6 libnm: fix an assert in nm_client_get_capabilities()
The length argument is optional. That makes sense, because the returned
array is NUL-terminated.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1136
2022-03-09 14:18:26 +01:00
Lubomir Rintel
d3d2e9b508 cli: document connection/device-external colors
These were added without documentation.

Fixes: 16cff1149a ('core: fix taking over external connection after restart')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1137
2022-03-09 14:18:26 +01:00
Beniamino Galvani
b580741ef4 rpm: fix autotools build options for default plugins
Fixes: bb832641eb ('rpm: remove build-time default for plugins on newer distros')
2022-03-09 10:14:04 +01:00
Yuri Chornoivan
1d0a4fbc28 po: update Ukrainian (uk) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1140
2022-03-09 09:16:58 +01:00
Thomas Haller
71f53d4069 std-aux: add code comment for NM_STR_HAS_PREFIX()/NM_STR_HAS_SUFFIX() 2022-03-09 09:10:45 +01:00
Beniamino Galvani
4f570f0f1f merge: branch 'bg/dhcp-overlong-hostname'
https://bugzilla.redhat.com/show_bug.cgi?id=2033643
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/572
2022-03-09 08:39:45 +01:00