Commit graph

28524 commits

Author SHA1 Message Date
Thomas Haller
ae14caf05d
std-aux: add NM_ENSURE_IS_TYPE() macro 2021-06-10 11:08:57 +02:00
Thomas Haller
cf1b7d43df
std-aux: add _nm_warn_unused_result define 2021-06-10 10:36:58 +02:00
Thomas Haller
01df4a5ad0
supplicant: fix leaking handle in nm_supplicant_manager_create_interface()
Found by valgrind.

Fixes: b83f07916a ('supplicant: large rework of wpa_supplicant handling')
2021-06-10 10:36:58 +02:00
Thomas Haller
6813a4fe75
bluez: fix leak of private data "conn_data_elems" in NMBluezManager
Found by valgrind.

Fixes: 4154d9618c ('bluetooth: refactor BlueZ handling and let NMBluezManager cache ObjectManager data')
2021-06-10 10:36:58 +02:00
Thomas Haller
85c6ab97ef
tools: add debug printf statements to "tools/generate-docs-nm-settings-docs-merge.py"
It's hard to understand what "tools/generate-docs-nm-settings-docs-merge.py"
does. Add dbg() statements that are all NOP by default. But the user can
easily patch the code to print what is happening. This is only for
debugging the script.
2021-06-09 12:46:32 +02:00
Thomas Haller
e831a67cbc
contrib/rpm: configure defaults for iptables/nftables when generating distribution tarball 2021-06-08 17:40:17 +02:00
Sibo Dong
5c1181c6f3
bash-completion: localize the prev variable
The prev variable is not localzed in the nmcli Bash completion script,
which calls _init_completion.

Even though prev does not appear in the completion script, it should
still be localized. This variable may otherwise appear in the user's
environment and clobber a user-defined variable of the same name, which
is bad.

Localize the prev variable.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/741

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/882
2021-06-08 11:37:03 +02:00
Thomas Haller
9662f24995
all: merge branch 'th/va-args-join'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/881
2021-06-08 08:24:36 +02:00
Thomas Haller
07002f7320
core: remove _nul_sentinel from UuidData struct
The user really must not treat UuidData.bin as a NUL terminated string.
The _nul_sentinel is not necessary. And if by chance the user makes this
fatal mistake, then UuidData.str will still be there to NUL terminate the
buffer, the content is garbage either way.

Remove the sentinel.
2021-06-08 08:24:14 +02:00
Thomas Haller
2b2c818e03
glib-aux/uuid: use NMUuid typed argument for nm_uuid_generate_from_string*()
nm_uuid_generate_from_string*() accepts an optional namespace parameter,
to seed the hashing. This previously was a UUID in string format, so it
first had to be parsed.

Rework the code to pass a NMUuid instance that can be used directly.
Also, as the type_args parameter is always of the same type, change
the argument from a void pointer to "const NMUuid *" pointer.
2021-06-08 08:24:14 +02:00
Thomas Haller
10e5f10f9d
glib-aux/uuid: add NM_UUID_INIT() macro 2021-06-08 08:24:13 +02:00
Thomas Haller
23adeed244
glib-aux: use NM_VA_ARGS_FOREACH() to implement NM_HASH_COMBINE_BOOLS() 2021-06-08 08:24:12 +02:00
Thomas Haller
b7ade9e20d
glib-aux: use NM_VA_ARGS_FOREACH() to implement NM_HASH_COMBINE_VALS() 2021-06-08 08:24:12 +02:00
Thomas Haller
1ccfde7ee6
libnm/tests: add test for NM_NARG() with 120 parameters 2021-06-08 08:24:11 +02:00
Thomas Haller
f98d47f77d
glib-aux: implement varidic macros NM_UTILS_{LOOKUP,ENUM2STR}_DEFINE() with NM_VA_ARGS_JOIN()
The previous implementation of these macros simply relied on the
__VA_ARGS__ to be expended and joined with ','. That make that work
inside the switch statement, the macros expanded to

   switch (val) {
       (void) 0, (void) 0;
   case 0x1:
       s = " ""value" "";
       break;
       (void) 0, (void) 0;
   };

Those NOP statements cause lgtm.com to complain "Dead code due to goto
or break statement".

Implement these macros differently using NM_VA_ARGS_JOIN().
2021-06-08 08:24:11 +02:00
Thomas Haller
0ed95698fd
std-aux: implement NM_IN_SET()/NM_IN_STRSET() via NM_VA_ARGS_FOREACH() 2021-06-08 08:24:11 +02:00
Thomas Haller
34a521e2d6
std-aux: add NM_VA_ARGS_JOIN() helper macro
We have variadic macros like NM_UTILS_ENUM2STR() that create a switch
statement. Their implementation relies on the way how __VA_ARGS__
gets expanded to a comma separated list. But that implementation is
not great. Let's instead add (and later use) NM_VA_ARGS_JOIN() which
can join variadic arguments by a configurable separator.
2021-06-08 08:24:11 +02:00
Thomas Haller
dadaba9ab6
std-aux: add NM_VA_ARGS_FOREACH() helper macro 2021-06-08 08:24:10 +02:00
Thomas Haller
9823ae75e5
std-aux: add _NM_MACRO_IDENTITY(), _NM_MACRO_CALL2(), _NM_MACRO_SELECT_FIRST()
_NM_MACRO_CALL2() is needed, because we cannot call _NM_MACRO_CALL() inside
_NM_MACRO_CALL().
2021-06-08 08:24:10 +02:00
Thomas Haller
2c3abc7bcb
std-aux,glib-aux: move NM_NARG() and _NM_MACRO_CALL() to lib-std-aux 2021-06-08 08:24:10 +02:00
Thomas Haller
bea061affc
glib-aux: extend NM_NARG() macro for more arguments 2021-06-08 08:24:10 +02:00
Thomas Haller
89a10ddf89
std-aux: add NM_BIT() macro 2021-06-08 08:24:10 +02:00
Thomas Haller
4d6edd8419
docs: explain GObject properties in CONTRIBUTING.md 2021-06-07 18:08:23 +02:00
Thomas Haller
ddd6587a6f
libnm: assert initialization in _NM_OBJECT_CLASS_INIT_FIELD_INFO()
_NM_OBJECT_CLASS_INIT_FIELD_INFO() is a bit odd, because it defines a
static variable and initialized it at the moment when being "called".
This is in fact correct, because this code only gets called from inside
the _class_init() function, which is executed at most once.

Add an assertion to ensure that the static variables is not yet
initialized.
2021-06-07 17:33:02 +02:00
Thomas Haller
b92d8f5a2d
release: bump version to 1.33.0 (development) 2021-06-04 18:10:32 +02:00
Thomas Haller
be89b39828
release: bump version to 1.31.90 (1.32-rc1) 2021-06-04 18:03:56 +02:00
Thomas Haller
d18172bb2b
NEWS: update 2021-06-04 17:07:09 +02:00
Thomas Haller
b4a7330629
NEWS: update 2021-06-04 13:52:27 +02:00
Beniamino Galvani
fa832c6590 NEWS: update 2021-06-04 13:43:11 +02:00
Thomas Haller
8d01bf5d80
wifi/iwd: rework warning about invalid state-dir
- always remember priv->last_state_dir that we received via
  D-Bus. Only later, during get_config_path() we will check
  whether the path is valid.

- remember in priv->warned_state_dir the full path for
  which we warned. We want to print a warning for each
  path once, if the path changes, then we also want a new
  warning. A boolean flag cannot express that.
2021-06-04 13:36:38 +02:00
Andrew Zaborowski
cd7213e27c
iwd: Enforce absolute state dir path, print warnings
Validate the state directory path, that we read from the configuration
or from IWD, to be an absolute path.  Print a warning if the value
cannot be used and is not an empty string.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/873
2021-06-04 13:09:54 +02:00
Thomas Haller
96ef5dede9
core: belatedly add [main].firewall-backend config to known options
Otherwise we see a warning:

   <warn>  [1622790097.3601] config: unknown key firewall-backend in section [main] of file /etc/NetworkManager/NetworkManager.conf

Fixes: 1da1ad9c99 ('firewall: make firewall-backend configurable via "NetworkManager.conf"')
2021-06-04 10:27:20 +02:00
Thomas Haller
ebab9a32dc
NEWS: update 2021-06-04 10:11:51 +02:00
Thomas Haller
9784956442
NEWS: update 2021-06-04 10:04:26 +02:00
Peter van der Velde
91f31a2665
vapi: Update NM-1.0.metadata to include WireGuard declarations
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/874
2021-06-04 10:03:13 +02:00
Thomas Haller
0d928c670d
all: merge branch 'th/uuid-normalize'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/880
2021-06-04 09:47:30 +02:00
Thomas Haller
3699c31eb1
libnm/tests: add test for normalizing "connection.secondaries" 2021-06-04 09:42:38 +02:00
Thomas Haller
890df48d14
libnm: verify and normalize "connection.secondaries"
So far, we didn't verify the secondary connections at all.
But these really are supposed to be UUIDs.

As we now also normalize "connection.uuid" to be in a strict
format, the user might have profiles with non-normalized UUIDs.
In that case, the "connection.uuid" would be normalized, but
"connection.secondaries" no longer matches. We can fix that by
also normalizing "connection.secondaries". OK, this is not a very good
reason, because it's unlikely to affect any users in practice ('though
it's easy to reproduce).

A better reason is that the secondary setting really should be well
defined and verified. As we didn't do that so far, we cannot simply
outright reject invalid settings. What this patch does instead, is
silently changing the profile to only contain valid settings.
That has it's own problems, like that the user setting an invalid
value does not get an error nor the desired(?) outcome.
But of all the bad choices, normalizing seems the most sensible
one.

Note that in practice, most client applications don't rely on setting
arbitrary (invalid) "UUIDs". They simply expect to be able to set valid
UUIDs, which they still are. For example, nm-connection-editor presents
a drop down list of VPN profile, and nmcli also resolves connection IDs
to the UUID. That is, clients already have an intimate understanding of
this setting, and don't blindly set arbitrary values. Hence, this
normalization is unlikely to hit users in practice. But what it gives
is the guarantee that a verified connection only contains valid UUIDs.

Now all UUIDs will be normalized, invalid entries removed, and the list
made unique.
2021-06-04 09:29:25 +02:00
Thomas Haller
3acf62f8be
libnm: use GArray to track "connection.secondaries" property instead of GSList
GSList requires an additional allocation for the container struct for each
element. Also, it does not have O(1) direct access. It's a pretty bad
data structure, especially if the underlying data is in form of a strv
array.

Use a GArray instead and the nm_strvarray_*() helpers.
2021-06-04 09:29:24 +02:00
Thomas Haller
92136135ad
libnm: don't reject empty strings in add/remove API
For example for NM_SETTING_CONNECTION_SECONDARIES, the user can set
the GObject property to a string list that includes empty strings.

The C accessors (add/remove-by-value) should also accept any strings that
are accepted otherwise. Asserting against empty strings is wrong. If the
setting wants to reject empty strings, then it should use verify().
2021-06-04 09:29:24 +02:00
Thomas Haller
46533cd15f
libnm: use nm_strvarray_get_strv_non_empty_dup() in "nm-setting-match.c" 2021-06-04 09:29:24 +02:00
Thomas Haller
75c6c4abf8
libnm: use nm_strvarray_get_idx() in "nm-setting-match.c" 2021-06-04 09:29:23 +02:00
Thomas Haller
6f2ae46b37
all: use nm_uuid_is_normalized() for checking valid UUID for "connection.uuid"
"connection.uuid" gets normalized. When we check for a valid UUID, we expect
it to be normalized.
2021-06-04 09:29:23 +02:00
Thomas Haller
423e83b880
keyfile: reject non-normalized UUIDs in nms_keyfile_nmmeta_check_filename()
Since commit 207cf3d5d4 ('libnm: normalize "connection.uuid"') the
"connection.uuid" is normalized to be a valid UUID and all lower case.

That means, if we have .nmmeta files on disk with a previously valid,
but now invalid UUID, the meta file is no longer going to match.

Reject such file outright as invalid. If we really wanted to preserve
backward compatibility, then we would have to also normalize the
filename when we read it. However, that means, that suddenly we might
have any number of compatible .nmmeta files that normalize to the same
UUID, like the files

  71088c75dec54119ab41be71bc10e736aaaabbbb.nmmeta
  F95D40B4-578A-5E68-8597-39392249442B.nmmeta
  f95d40b4-578a-5e68-8597-39392249442b.nmmeta

Having multiple places for the nmmeta file is complicated to handle.

Also, we often have the connection profile (and the normalized UUID)
first, and then check whether it has a .nmmeta file. If we would support
those unnormalized file names, we would have to visit all file names and
try to normalize it, to find those with a matching UUID.

Non-normalized UUIDs really should not be used and they already are not
working anymore for the .nmmeta file. This commit only outright rejects
them. This is a change in behavior, but the behavior change happened
earlier when we started normalizing "connection.uuid".
2021-06-04 09:29:22 +02:00
Thomas Haller
7e8e6836e0
keyfile: fix comparison in nms_keyfile_nmmeta_read()
"uuid" is returned from nms_keyfile_nmmeta_check_filename(),
and contains "$UUID.nmmeta". We must compare only the first
"uuid_len" bytes.

Fixes: 064544cc07 ('settings: support storing "shadowed-storage" to .nmmeta files')
2021-06-04 09:29:22 +02:00
Thomas Haller
25f4d23e13
glib-aux: change nm_uuid_is_valid_full() to nm_uuid_is_normalized_full()
Most of the time, we care about whether we have a normalized UUID.

nm_uuid_is_valid_full() only exists for a particular case where we want
to use the function in a header, without including "nm-uuid.h". In that
case, we actually also care about normalized UUIDs.
2021-06-04 09:29:22 +02:00
Thomas Haller
6ce7b3ca0f
glib-aux: add nm_uuid_is_valid_normalized() helper 2021-06-04 09:29:21 +02:00
Thomas Haller
8c6be1909f
glib-aux: add nm_strvarray_get_strv_non_empty_dup() helper 2021-06-04 09:29:21 +02:00
Thomas Haller
851267b6e7
glib-aux: add nm_strvarray_find_first() helper 2021-06-04 09:29:21 +02:00
Thomas Haller
b0acbe504f
glib-aux: add nm_strvarray_get_idx() helper 2021-06-04 09:29:21 +02:00