Commit Graph

30058 Commits

Author SHA1 Message Date
Thomas Haller
49b0a92b5a contrib: add "nm-python-black-format.sh" script
This is more for completeness, to go along "nm-code-format.sh"
script.

Usually it's very simple to run black directly (you may still do that).
However, black by default only reformats files with ".py" extension.
So to get all our python files, you'd need to know and explicitly
select them... or use this script.

Also, `black .` scans the entire source tree, and is rather slow.
This script knows which files to select and is thus faster.
2022-04-01 14:00:30 +02:00
Thomas Haller
670894b667 contrib: fix wrong usage text for "nm-code-format.sh" 2022-04-01 13:51:56 +02:00
muzena
5d440610a9 po: update Croatian (hr) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1172
2022-04-01 12:25:30 +02:00
Beniamino Galvani
586afdfc52 wwan: re-enable IPv6 once the modem returns a IPv6 configuration
IPv6 gets disabled at the beginning of the activation in
ip_ifindex_changed_cb(). Enable it again when the modem returns a IPv6
configuration.

Fixes: 58287cbcc0 ('core: rework IP configuration in NetworkManager using layer 3 configuration')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/944
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1170
2022-04-01 09:13:57 +02:00
Fernando Fernandez Mancera
2bbe7f9204 ovs, dpdk: ignore ovs-netdev tun interface
When configuring a OVS bridge to use the netdev datapath, OpenvSwitch
will create a tun interface named ovs-netdev. This interface should be
ignored by NetworkManager.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1169
2022-03-31 11:49:34 +02:00
Thomas Haller
e99d0b333c po: make update-po
$ make -C po update-po
2022-03-30 23:46:49 +02:00
Thomas Haller
11e8b3375f gitlab-ci: fix archiving build log
During the test, we `tee` the output to a log file in "/tmp".
We do that, because the test script cleans the working directory
several times, so the file cannot reside there.

Afterwards, we need to move the file back into the git-tree, so that
gitlab can archive it.

Previously that was done by "after_script", but the "after_script" may not
see the same "/tmp" as the test run ([1]). This needs to be done as part of the
"script" step.

[1] https://docs.gitlab.com/ee/ci/yaml/#after_script
2022-03-30 11:25:08 +02:00
Thomas Haller
318776c56d libnm: merge branch 'th/libnm-crypto'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1155
2022-03-29 12:00:28 +02:00
Thomas Haller
9aa02f6543 crypto: cleanup error handling in nm_crypto_is_pkcs12_data()
Our convention is that a function that fails MUST set the GError output.
No need to check for that in nm_crypto_is_pkcs12_data(). Simplify the
error paths.

Also, in gnutls' _nm_crypto_verify_pkcs12(), don't call gnutls_pkcs12_deinit()
before gnutls_strerror(). It's unclear whether that couldn't set a
different error reason.
2022-03-29 11:56:05 +02:00
Thomas Haller
79f676c83a crypto: move nm_crypto_read_file() to "libnm-glib-aux"
It has no actual dependency on the crypto library. All it does, is
to be careful about not leaking secrets in memory. We have code
for that in libnm-glib-aux already. Move.

The goal is to reduce the number of places where we use libnm-crypto,
because that has a large dependency. libnm-glib-aux is a very light
dependency instead.
2022-03-29 11:56:04 +02:00
Thomas Haller
723e1fc76f libnm: move dependency to libnm-crypto out of libnm-core's "nm-utils.c"
libnm-core is also used by the daemon, thus currently dragging in
libnm-crypto there. But could we ever drop that dependency?

One use of the libnm-crypto is in functions like nm_utils_file_is_certificate()
in "nm-utils.h". These are part of the public API of libnm.

But this is not used by the daemon. Move it to "libnm-client-core"
to be closer to where it's actually used.

As we have unit tests in "libnm-core-impl/tests" that test this function,
those unit tests also would need to move to "libnm-client-impl".
Instead, add the actual implementation of these function to "libnm-crypto"
and test it there.

This patch moves forward declarations from public header "nm-utils.h" to
"nm-client.h". Arguably, "nm-client.h" is not a great name, but we don't
have a general purpose header in "libnm-client-public", so use this.
Note that libnm users can only include <NetworkManager.h> and including
individual files is not supported (and even prevented). Thus moving
the declarations won't break any users.
2022-03-29 11:56:04 +02:00
Thomas Haller
901787e06f build: move nm-crypto to separate directory "src/libnm-crypto"
libnm-core currently has a dependency on crypto libraries (either
"gnutls", "nss" or "null"). We need this huge dependency for few cases.

Move the crypto code to a separate static library"src/libnm-crypto/libnm-crypto.la".
The reasoning is that it becomes clearer where we have this dependency,
to use it more consciously, and to be better see how it's used.

We clearly need the crypto functionality in libnm. But do we also need
it in the daemon? Could we ever link the daemon without crypto libraries?

The goal of splitting the crypto part out, to better understand the
crypto dependency.
2022-03-29 11:56:04 +02:00
Thomas Haller
3a97604a27 libnm: don't depend nm-crypto on "nm-error.h"
"nm-error.h" is public API of libnm, and contains error numbers and
quarks. Clearly our "nm-crypto" implementation wants to use those
errors.

I want to move "nm-crypto" out of libnm, and as it's more basic, I think
it should not have a dependency on all of libnm-core. Also because
libnm-core currently uses nm-crypto, so there would be a circular
dependency. Which would be possible to do (libnm-core-aux-intern is
also used in such a way). But it's better avoided, to have clear
hierarchy of dependencies.

Add a version of the same error codes to libnm-base. libnm-base is a
very basic dependency (just one step above libnm-glib-aux).
2022-03-29 11:56:03 +02:00
Thomas Haller
89bba8fa84 libnm-base: add "nm-base.c" for implementing stuff from "nm-base.h" 2022-03-29 11:56:03 +02:00
Thomas Haller
34b4496028 libnm: no longer use "nm-utils.h" from "nm-crypto.c"
The goal is to make "nm-crypto.c" independent of libnm-core.
2022-03-29 11:56:03 +02:00
Thomas Haller
526a05d6f2 glib-aux: add _nm_utils_bin2hexstr() and use from nm_utils_bin2hexstr()
nm_utils_bin2hexstr() is part of public libnm API.
That means, if we want to use this function, we need to link with
libnm-core-impl.

This is used by "nm-crypto.c". That file is currently part of
libnm-core, but that will change.

Move the implementation to libnm-glib-aux, so that we can use this code
from all our glib-based code (because all our glib-based code is allowed
to link with libnm-glib-aux).
2022-03-29 11:56:03 +02:00
Thomas Haller
7e0a094187 build/meson: log enabled crypto libraries in summary
"autotools" also prints a similar output. It's useful to know
which libraries were enabled. Because, we run unit test against
all enabled libraries, even if they are actually used.
2022-03-29 11:56:02 +02:00
Thomas Haller
ccce9d394f libnm/trivial: fix indentation in "NetworkManager.h" 2022-03-29 11:56:02 +02:00
Thomas Haller
f6ee923ff5 libnm: merge branch 'th/libnm-8021x-cleanup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1167
2022-03-29 11:52:56 +02:00
Thomas Haller
ee1467fcdb libnm/802-1x: check is-pkcs12 only for blob certificates in verify_tls()
If the certificate is not a blob, it makes no sense to call
nm_crypto_is_pkcs12_data().
2022-03-29 11:52:38 +02:00
Thomas Haller
d3a6b9e7cc libnm/802-1x: move need_private_key_password() to need_secrets_tls()
When a static function only has one caller, it is often simpler to not
have the code in a separate function. Drop need_private_key_password()
and move it to need_secrets_tls().
2022-03-29 11:52:37 +02:00
Thomas Haller
bcb1ab9e1c libnm/802-1x: don't use g_warning() in need_secrets_tls()
g_warning() for unexpected scheme is not right. Either, this should be an
assertion (and never be hit), or the library should be silent about conditions
that can happen regularly.
2022-03-29 11:52:37 +02:00
Thomas Haller
e4a7b671d6 libnm/802-1x: cleanup duplicate code paths in need_secrets_tls()
I think code is easier to understand, if the difference (between phase1
and phase2) is pushed to the bottom. Having one large "if(phase2){}else{}"
at the top makes it harder to compare the two branches and see where
they differ.
2022-03-29 11:52:37 +02:00
Thomas Haller
47f2c5e5db libnm/802-1x: cleanup need_secrets_phase2() 2022-03-29 11:52:37 +02:00
Thomas Haller
a3aec9dc5c libnm/802-1x: reuse verify_identity() in verify_ttls() implementation 2022-03-29 11:52:37 +02:00
Thomas Haller
d5ee67981c libnm/802-1x: simplify verify_tls() for phase1 and phase2
The checks are duplicated and verbose. Combine them.
2022-03-29 11:52:33 +02:00
Beniamino Galvani
7d5a8d4f74 merge: branch 'bg/rfkill'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1157
https://bugzilla.redhat.com/show_bug.cgi?id=1996918
2022-03-29 09:37:36 +02:00
Beniamino Galvani
e51b4ca5fe cli: indicate missing radio hardware in "nmcli radio"
When no radio hardware is present in the system, "nmcli radio"
currently displays:

  WIFI-HW  WIFI     WWAN-HW  WWAN
  enabled  enabled  enabled  enabled

which is misleading. Use the new RadioFlags property to display
"missing" in the *-HW columns when there is no hardware for the
given radio technology.

https://bugzilla.redhat.com/show_bug.cgi?id=1996918
2022-03-29 09:34:07 +02:00
Beniamino Galvani
4a8a3847ad libnm: support radio flags 2022-03-29 09:34:07 +02:00
Beniamino Galvani
580ef03bee core: export radio flags
Introduce a RadioFlags property on the manager object. For now it
contains two bits WLAN_AVAILABLE, WWAN_AVAILABLE to indicate whether
any radio interface is present in the system. The presence of a radio
is detected by looking at devices and rfkill switches.

In future, any radio-related read-only boolean flag can be exposed via
this property, including the already existing WirelessHardwareEnabled
and WwanHardwareEnabled properties.
2022-03-29 09:34:07 +02:00
Beniamino Galvani
2343148da8 core: introduce "unavailable" rfkill state
Introduce a new "unavailable" rfkill state to indicate that no rfkill
hardware was found. Currently it is still handled as "unblocked".
2022-03-29 09:12:36 +02:00
Thomas Haller
2bdca1f5d6 libnm/keyfile: merge branch 'th/keyfile-cleanup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1161
2022-03-28 18:31:41 +02:00
Thomas Haller
782f2fa8ef keyfile: don't require verified profile in nm_keyfile_write()
Previously, only the daemon was writing keyfiles, and it ensures
that they are always valid.

As we now have this function as public API of libnm, we should drop this
restriction and write the profile the best we can. Granted, an invalid
profile may not be expressed in keyfile format, and the result is
undefined. But make the best of it.
2022-03-28 18:27:37 +02:00
Thomas Haller
b07bf1a8bb keyfile: add write_handle_warn() helper 2022-03-28 18:27:37 +02:00
Thomas Haller
cec1269795 keyfile: rename handle_warn() to read_handle_warn()
We will also want to warn during write.
2022-03-28 18:27:36 +02:00
Thomas Haller
cfe594903e keyfile: simplify code path in write_setting_value()
Avoid nested blocks. Check one condition after the other and handle it.
2022-03-28 18:27:36 +02:00
Thomas Haller
a0db72bf6d keyfile: use nm_setting_8021x_scheme_vtable_by_setting_key() helper in cert_writer() 2022-03-28 18:27:36 +02:00
Thomas Haller
e965aa2536 libnm: add nm_setting_8021x_scheme_vtable_by_setting_key() helper
Add function to lookup the vtable by name. Implement a binary search.
2022-03-28 18:27:36 +02:00
Thomas Haller
22dcfb3a67 libnm: fix update of cached option names in nm_setting_option_set()
This is severe. We cache the list of names, and we must invalidate the
cache when the names change. Otherwise, out-of-bound access and crash.

Fixes: d0192b698e ('libnm: add nm_setting_option_set(), nm_setting_option_get_boolean(), nm_setting_option_set_boolean()')
Fixes: 150af44e10 ('libnm: add nm_setting_option_get_uint32(), nm_setting_option_set_uint32()')
2022-03-28 18:27:35 +02:00
Thomas Haller
681926ad43 glib-aux: make nm_gobject_notify_together_full() macro more robust
If __VA_ARGS__ contains odd arguments, it's not clear that N_ARG() gives
the same as the array initialization. Add a static assert that the
numbers agree to catch wrong usage of the macro.

For example:

    nm_gobject_notify_together(setting, a, b, );
2022-03-28 18:27:35 +02:00
Thomas Haller
321b59e84b docs: add "sandboxing.md" 2022-03-28 18:04:18 +02:00
Lubomir Rintel
aba3401df0 cli: remove one more g_assert()
I pushed accidentally pushed commit 9702310f25 ('clients: bulk removal
of g_assert*() statements') earlier than I intended, without addressing
one more case introduced by preceding merge. Fix it now.

Fixes: 9702310f25 ('clients: bulk removal of g_assert*() statements')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1166
2022-03-28 15:04:07 +02:00
Lubomir Rintel
8dbe6fa0d5 merge: branch 'lr/conn-migrate'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1146
https://bugzilla.redhat.com/show_bug.cgi?id=2059608
2022-03-28 15:00:45 +02:00
Lubomir Rintel
1aa9c80b9b cli: add "connection migrate" subcommand
This is used to move a connection to a different settings plugin.
2022-03-28 14:59:30 +02:00
Lubomir Rintel
9702310f25 clients: bulk removal of g_assert*() statements
Assertions should be done in tests. If we detect an unexpected situation
at runtime, we shall fail more gracefully than crashing right away.
2022-03-28 13:51:44 +02:00
Lubomir Rintel
c7ab380a5c cli: fix handling of erroneous connections in "delete"
If we can't find a connection for any reason other than that it doesn't
exist, we should error out immediately and consistently, regardless of
whether we already encountered a non-existent connection.
2022-03-28 13:29:28 +02:00
Lubomir Rintel
e39e5d9372 cli: fix up help string for "delete"
Make it obvious that we can delete more connections in one go.
2022-03-28 13:29:28 +02:00
Lubomir Rintel
82d16789a5 settings-connection: add a "plugin" argument to Update2()
This will allow migrating a connection. If specified, the connection will
be confined to a particular settings plugin when written back. If the
plugin differs from the existing one, it will be removed from the old one.
2022-03-28 13:29:28 +02:00
Lubomir Rintel
f4f165f945 settings: add "plugin" argument to AddAndActivate2()
This will confine a newly added connection to a particular settings
plugin.
2022-03-28 13:29:28 +02:00
Nathan Follens
18b4ea7468 po: update Dutch (nl) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1163
2022-03-28 12:43:48 +02:00