Commit graph

34212 commits

Author SHA1 Message Date
Thomas Haller
b57167fe74
libnm: merge branch 'th/libnm-core-hide-structs'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/888
2021-06-11 22:35:35 +02:00
Thomas Haller
0206642ec3
NEWS: update 2021-06-11 22:32:25 +02:00
Thomas Haller
860b280248
libnm: hide NMSimpleConnection type from public headers 2021-06-11 22:32:24 +02:00
Thomas Haller
e46d484fae
libnm: hide NMSetting types from public headers
When subclassing a GObject type, the class and object structs
must be available and defined in the header.

For libnm, and in particular for NMSetting classes, we don't want
users to subclass NMSetting. It also doesn't work, because libnm
has internal code that is necessary to hook up the NMSetting class.
You cannot define your own type and make it work together with
libnm.

Having the structs in public headers limits what we can do with them.
For example, we could embed the private data directly in the structures
and avoid the additional indirection.

This is an API break, but for something that most likely nobody cares
about. Or better, nobody should care about. API is not what is
accidentally defined in a header, API was the library provides to
meaningfully use. Subclassing these types is not meaningful and was
only accidentally possible so far.

Only hide the structs for now. More cleanup is possible later. We shall
however aim to keep the padding and struct layout to not also break ABI.
2021-06-11 22:32:24 +02:00
Thomas Haller
0d6c35a6d9
core: avoid accessing opaque NMSetting type
Next, NMSetting will be hidden from public headers and become an opaque type.
We cannot do typeof(*setting) anymore.
2021-06-11 22:32:12 +02:00
Beniamino Galvani
709b497938 device: remove unused variable
Fixes: 620fbb7894 ('device: use nm_device_resolve_address()')
(cherry picked from commit c89ac8f0c7)
2021-06-11 21:59:18 +02:00
Beniamino Galvani
c63edc5881 merge: branch 'bg/resolve-helper'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/877

(cherry picked from commit a68b63a859)
2021-06-11 21:59:12 +02:00
Beniamino Galvani
f468e15248 device: use nm_device_resolve_address()
(cherry picked from commit 620fbb7894)
2021-06-11 21:59:12 +02:00
Beniamino Galvani
b26449a9c7 device: add a nm_device_resolve_address()
The new function resolve an address via DNS, first by using
systemd-resolved (disabling synthesized results) and then by spawning
the daemon helper.

Trying systemd-resolved via D-Bus before spawning the helper is
important to get a correct result. Suppose that resolv.conf points to
the local stub listener at 127.0.0.53; if NM only spawns the helper,
the helper will query the local systemd-resolved which could return a
synthesized result.

Therefore, we first query systemd-resolved with NO_SYNTHESIZE and
then, in case of error, we spawn the helper.

(cherry picked from commit 27eae4043b)
2021-06-11 21:59:11 +02:00
Beniamino Galvani
4f9ff47e2d dns: add function to retrieve the systemd-resolved plugin instance
Now that we have nm_dns_systemd_resolved_resolve_address(), we also
need a way to obtain a reference to the plugin.

(cherry picked from commit 7285bc56a9)
2021-06-11 21:59:11 +02:00
Beniamino Galvani
ffd6c5e3f4 nm-daemon-helper: implement 'resolve-address' operation
Implement a new operation to resolve the hostname from an
address. Note the call to __nss_configure_lookup("hosts", "dns"): this
configures the glibc Name Service Switch (NSS) to only use DNS,
bypassing other modules that might be configured in
/etc/nsswitch.conf. Other modules like 'myhostname' or 'resolve' can
return synthesized names, while we are only interested in real DNS
results.

(cherry picked from commit 648b0848f1)
2021-06-11 21:59:11 +02:00
Beniamino Galvani
00126e57b4 core: add infrastructure for spawning a helper process
(cherry picked from commit 6ac21ba916)
2021-06-11 21:59:11 +02:00
Beniamino Galvani
5e5baa0f05 core,nm-dispatcher: use nm_utils_get_process_exit_status_desc()
(cherry picked from commit 326dde6d53)
2021-06-11 21:59:11 +02:00
Beniamino Galvani
227c5ca305 libnm-glib-aux: add nm_utils_get_process_exit_status_desc()
(cherry picked from commit 517852dccd)
2021-06-11 21:59:11 +02:00
Beniamino Galvani
3c96d4bb59 dns/resolved: fix memory leak
'v_name' must be freed. Pass ownership to the result element.

Fixes: e7b76f6757 ('dns/resolved: add API for ResolveAddress call')
(cherry picked from commit 9e69d921c1)
2021-06-11 21:59:11 +02:00
Thomas Haller
c1b8a03598 shared: add nm_ip_addr_init() helper
(cherry picked from commit 5ccc5e10b9)
2021-06-11 21:59:11 +02:00
Beniamino Galvani
c89ac8f0c7 device: remove unused variable
Fixes: 620fbb7894 ('device: use nm_device_resolve_address()')
2021-06-11 21:58:02 +02:00
Beniamino Galvani
a68b63a859 merge: branch 'bg/resolve-helper'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/877
2021-06-11 21:44:38 +02:00
Beniamino Galvani
620fbb7894 device: use nm_device_resolve_address() 2021-06-11 21:43:12 +02:00
Beniamino Galvani
27eae4043b device: add a nm_device_resolve_address()
The new function resolve an address via DNS, first by using
systemd-resolved (disabling synthesized results) and then by spawning
the daemon helper.

Trying systemd-resolved via D-Bus before spawning the helper is
important to get a correct result. Suppose that resolv.conf points to
the local stub listener at 127.0.0.53; if NM only spawns the helper,
the helper will query the local systemd-resolved which could return a
synthesized result.

Therefore, we first query systemd-resolved with NO_SYNTHESIZE and
then, in case of error, we spawn the helper.
2021-06-11 21:43:12 +02:00
Beniamino Galvani
7285bc56a9 dns: add function to retrieve the systemd-resolved plugin instance
Now that we have nm_dns_systemd_resolved_resolve_address(), we also
need a way to obtain a reference to the plugin.
2021-06-11 21:43:12 +02:00
Beniamino Galvani
648b0848f1 nm-daemon-helper: implement 'resolve-address' operation
Implement a new operation to resolve the hostname from an
address. Note the call to __nss_configure_lookup("hosts", "dns"): this
configures the glibc Name Service Switch (NSS) to only use DNS,
bypassing other modules that might be configured in
/etc/nsswitch.conf. Other modules like 'myhostname' or 'resolve' can
return synthesized names, while we are only interested in real DNS
results.
2021-06-11 21:43:12 +02:00
Beniamino Galvani
6ac21ba916 core: add infrastructure for spawning a helper process 2021-06-11 21:43:12 +02:00
Beniamino Galvani
326dde6d53 core,nm-dispatcher: use nm_utils_get_process_exit_status_desc() 2021-06-11 21:43:11 +02:00
Beniamino Galvani
517852dccd libnm-glib-aux: add nm_utils_get_process_exit_status_desc() 2021-06-11 21:43:11 +02:00
Beniamino Galvani
9e69d921c1 dns/resolved: fix memory leak
'v_name' must be freed. Pass ownership to the result element.

Fixes: e7b76f6757 ('dns/resolved: add API for ResolveAddress call')
2021-06-11 21:43:11 +02:00
Thomas Haller
5ccc5e10b9 shared: add nm_ip_addr_init() helper 2021-06-11 21:43:11 +02:00
Thomas Haller
39d71ee356
contrib: update NM-log script to highlight "enslaving to master" messages 2021-06-11 10:54:15 +02:00
Andrew Zaborowski
a93653336b
iwd: Don't add connection.interface-name by default
This setting can't be handled IWD (e.g. during autoactivations performed
by IWD) and although for manual activations NM will probably check it,
there's no reason for the IWD backend to restrict new profiles to one
interface plus when running IWD the udev permanent interface naming is
likely to be broken.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/886
(cherry picked from commit 35a1d89a96)
2021-06-10 23:32:33 +02:00
Andrew Zaborowski
35a1d89a96
iwd: Don't add connection.interface-name by default
This setting can't be handled IWD (e.g. during autoactivations performed
by IWD) and although for manual activations NM will probably check it,
there's no reason for the IWD backend to restrict new profiles to one
interface plus when running IWD the udev permanent interface naming is
likely to be broken.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/886
2021-06-10 23:30:11 +02:00
Simon McVittie
a90a7b2d5f
libnm: Don't crash if service tells us a new key management mode
The NetworkManager service sometimes adds new key management modes.
If it does, an older client library (perhaps in a container, or loaded
into a pre-existing process before an upgrade) shouldn't crash when
talking to a newer NetworkManager service over D-Bus.

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

Signed-off-by: Simon McVittie <smcv@collabora.com>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/887

Fixes: 4c4f59674a ('2007-10-23  Dan Williams  <dcbw@redhat.com>')

(cherry picked from commit 18c76388f0)
2021-06-10 23:25:50 +02:00
Simon McVittie
18c76388f0
libnm: Don't crash if service tells us a new key management mode
The NetworkManager service sometimes adds new key management modes.
If it does, an older client library (perhaps in a container, or loaded
into a pre-existing process before an upgrade) shouldn't crash when
talking to a newer NetworkManager service over D-Bus.

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

Signed-off-by: Simon McVittie <smcv@collabora.com>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/887
2021-06-10 23:16:59 +02:00
Thomas Haller
a25c577556
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')
(cherry picked from commit 6813a4fe75)
2021-06-10 16:02:25 +02:00
Thomas Haller
80a8a5d16d
supplicant: fix leaking handle in nm_supplicant_manager_create_interface()
Found by valgrind.

Fixes: b83f07916a ('supplicant: large rework of wpa_supplicant handling')
(cherry picked from commit 01df4a5ad0)
2021-06-10 16:02:24 +02:00
Thomas Haller
7d063726c2
libnm/tests: fix compilation error with old gcc not supporting __auto_type
Fixes: 23adeed244 ('glib-aux: use NM_VA_ARGS_FOREACH() to implement NM_HASH_COMBINE_BOOLS()')
2021-06-10 13:28:15 +02:00
Thomas Haller
17be7ea72e
glib-aux: mark result of nm_g_slice_free_fcn() as warn_unused_result
It's tempting to mix up

    nm_g_slice_free(arg)

with

    nm_g_slice_free_fcn(arg)

Use __attribute((__warn_unused_result__)) to catch such bugs.
2021-06-10 11:08:58 +02:00
Thomas Haller
5abf61f53a
glib-aux: fix formatting for _nm_g_slice_free_fcn_define() by adding semicolon 2021-06-10 11:08:57 +02:00
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
1e0252fa8f
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
(cherry picked from commit 5c1181c6f3)
2021-06-08 11:38:45 +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