Commit Graph

27768 Commits

Author SHA1 Message Date
Thomas Haller
8f7a2a1ea0 dhcp/nettools: refactor parsing of DHCP lease (wpad) 2021-02-11 09:23:09 +01:00
Thomas Haller
784932550c dhcp/nettools: validate and normalize Host Name Option (12)
The hostname is in the end a string, which means it must be in a known,
sensible encoding (UTF-8). Previously, we would not ensure the encoding,
nor that the hostname was valid.

Fix that. Follow what systemd does with lease_parse_domain().

See-also: https://tools.ietf.org/html/rfc2132#section-3.14
2021-02-11 09:23:09 +01:00
Thomas Haller
67110d1711 dhcp/nettools: refactor parsing of DHCP lease (hostname) 2021-02-11 09:23:08 +01:00
Thomas Haller
89773b8739 dhcp/nettools: refactor parsing of DHCP lease (metered) 2021-02-11 09:23:08 +01:00
Thomas Haller
de14a376ff dhcp/nettools: refactor parsing of DHCP lease (mtu) 2021-02-11 09:23:08 +01:00
Thomas Haller
fc83acbd99 dhcp: add nm_dhcp_option_add_option_in_addr() helper 2021-02-11 09:23:07 +01:00
Thomas Haller
41634d5199 dhcp: add nm_dhcp_option_add_option_utf8safe_escape() helper 2021-02-11 09:23:07 +01:00
Thomas Haller
f0a9268718 dhcp: require options argument for nm_dhcp_option_add_option()
It's not clear why the option argument would be optional.
Also, it's not optional for nm_dhcp_option_take_option().

Add an nm_assert() to catch such wrong uses.
2021-02-11 09:23:07 +01:00
Thomas Haller
1e15ea9dd5 systemd: add nm_sd_dns_name_normalize() accessor 2021-02-11 09:23:07 +01:00
Thomas Haller
e12e4ef849 shared: return NMStrBuf instance from nm_str_buf_reset()
it can be useful for chaining, and it costs nothing to do this
on an inline function.
2021-02-11 09:23:07 +01:00
Thomas Haller
edc7c7204c shared: remove "str" argument from nm_str_buf_reset()
NMStrBuf's API is all about convenience. When you reset the buffer,
is it convenient to immediately append a new string?

It seems not. Make nm_str_buf_reset() simpler by doing only one thing.
2021-02-11 09:23:06 +01:00
Thomas Haller
04e824a256 NEWS: update 2021-02-11 08:48:51 +01:00
Thomas Haller
d27ce97195 cloud-setup: merge branch 'th/cloud-setup-fix-replace-addr'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/747
2021-02-10 19:25:18 +01:00
Thomas Haller
d0552e00d0 cloud-setup/tests: add test for nmcs_setting_ip_replace_ipv4_addresses() 2021-02-10 18:35:13 +01:00
Thomas Haller
7e8809a9c5 cloud-setup/tests: add unit test for nm-cloud-setup 2021-02-10 18:23:44 +01:00
Thomas Haller
bbd36be44a cloud-setup: fix replacing IPv4 addresses during update
If previously the profile would track two addresses ("10.116.1.130/24",
"10.116.1.65/24"), and during an update the second address was removed
(leaving "10.116.1.130/24"), then the addresses of the profile were
wrongly not changed.

The effect is that removing a secondary IP address might not take
effect.

Fix that.

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

Fixes: 69f048bf0c ('cloud-setup: add tool for automatic IP configuration in cloud')
2021-02-10 18:23:44 +01:00
Thomas Haller
94a75c8cd6 cloud-setup: build intermediate library "libnm-cloud-setup-core.a"
Next we'll add unit tests, hence we need to link against the code
but we don't want to compile it twice.
2021-02-10 18:23:44 +01:00
Thomas Haller
8d6bd2f6c0 shared/tests: add nmtst_rand_perm_strv() helper 2021-02-10 18:23:44 +01:00
Thomas Haller
826d4fd7a9 shared/tests: add nmtst_ip_address_new() helper 2021-02-10 18:23:44 +01:00
Thomas Haller
dfddab88ac gitignore: ignore *.a files 2021-02-10 18:23:43 +01:00
Yuri Chornoivan
d24ad0a202 po: update Ukrainian (uk) translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/749
2021-02-10 17:52:06 +01:00
Beniamino Galvani
020a2707c4 dhcp: nettools: export broadcast and server-id options
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/426
2021-02-10 09:13:03 +01:00
Thomas Haller
5e6d6c0764 build/meson: include subdir "libnm" before "src/core"
No big change, but eventually I' like to move all source
directories under src/. That must be done one after the other,
so the first step is to move libnm-core/ into src/. If libnm
gets loaded in between, that causes odd ordering.

"src/core" should not depend on "libnm" and vice versa, so this
should have little effect for now.
2021-02-10 08:27:06 +01:00
Thomas Haller
b9756df2c6 wifi: merge branch 'balrog-kun:write-iwd-configs' (part 1)
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/695
2021-02-09 17:09:43 +01:00
Andrew Zaborowski
9fd0f0c4fa iwd: Match IWD networks to existing OWE and SAE connection
IWD's "open" networks can be either unsecured or use OWE and "psk"
networks may be using WPA2 personal or WPA3 personal so when looking for
an exsiting NMSettingsConnection matching an IWD KnownNetwork, also
check for these connection key_mgmt types.

Add explicit checks for AP and ADHOC connection modes to exclude OWE and
SAE as they're not supported by IWD in those modes and we don't want to
make it appear like a connection of this type was successfully
activated.
In Infrastructure mode there's won't be any way to know whether IWDxi
established an OWE or unsecured connection (or WPA2-PSK vs. SAE)
regardless of what was set in the NMConnection and it's not considered
to be meaningful (also isn't normally exposed in a GUI) although you
could argue OWE vs. unsecured is a big difference.
2021-02-09 17:09:32 +01:00
Andrew Zaborowski
4aea512b15 iwd: Rename NM_IWD_NETWORK_SECURITY_NONE to _OPEN
IWD doesn't expose on D-Bus, or in the network profile files, the
information on whether a network has no security or uses OWE so they
should be the same thing to the iwd backend (similarly WPA2-Personal and
WPA3-Personal/SAE).  But OWE implies some security against some attacks
so the NONE naming could be misleading.
2021-02-09 17:09:32 +01:00
Andrew Zaborowski
ba7a13789f setting-8021x: Fix descriptions for phase2-auth & phase2-autheap
phase2-auth applies for EAP-TTLS and EAP-PEAP but the interpretation is
different for one than for the other, clarify the difference.
phase2-auth is for the non-EAP inner methods of EAP-TTLS but is also for
the EAP inner methods of EAP-PEAP.  EAP-PEAP doesn't use phase2-autheap
and doesn't support any non-EAP methods.

Given how complicated EAP configuration is it's likely that people just
use example configurations rather than look at the docs.  The example
configuration in man/nm-settings-keyfile.xsl is correct in using PEAP
together with phase2-auth=mschapv2.

[thaller@redhat.com: regenerate documentation files]
2021-02-09 17:09:31 +01:00
Thomas Haller
4fcdd1eb48 all: merge branch 'th/nm-default-cleanup'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/746
2021-02-09 15:49:42 +01:00
Thomas Haller
7abac1b89a shared: move redefining G_VARIANT_TYPE() to "nm-glib-aux/nm-default-glib.h"
We redefine G_VARIANT_TYPE() because we don't want to pay a run time
check for what should be a simple cast.

But this is strictly tied to glib, and it must only be done after glib.h
was included. Move it to the right place.
2021-02-09 12:38:19 +01:00
Thomas Haller
318824cb41 libnm: move "nm-version-macros.h" from shared/ to libnm-core/
"nm-version-macros.h" is used directly by libnm-core and indirectly by
libnm and core.

Let's not have it randomly under shared/. Move it closer to where it's
used.
2021-02-09 12:38:19 +01:00
Thomas Haller
a2ef576905 shared: move "nm-gassert-patch.h" to "nm-glib-aux" 2021-02-09 12:38:19 +01:00
Thomas Haller
c971ee2267 libnm: merge libnm-keyfile into libnm-core
Before there was a licensing conflict between the keyfile code
(libnm-keyfile) and libnm. The latter would require LGPL-2.1+ while
keyfile code was GPL-2.0+.

Consequently we were linking libnm-keyfile into the daemon, but not in
libnm.so.

This conflict has been resolved and keyfile API is part of libnm.so.
There is no more need to build a separate (intermediary) library. Merge
them.

This also makes sense because keyfile code needs access to private code
from libnm-core. It is closely tied to libnm-core, so that building them
separate makes no sense (anymore).
2021-02-09 12:38:19 +01:00
Thomas Haller
b13a2b27e9 all: move shared/nm-meta-setting.[hc] to libnm-core and clients
"shared/nm-meta-setting.[hc]" contains meta data about settings.
As such it is similarly used by libnm-core (as internal API) and
by clients (as extension of public API of libnm). However, it must
be compiled twice, because while it defines in both cases a
NMMetaSettingInfo type, these types are different between internal and
public API.
Hence, the files must also be compiled twice (and differently), once
against libnm-core and once against the client helper library.

Previously, the file was under "shared/", but there it's a bit odd
it doesn't clearly belong anywhere.

There are two goals here:

 - copy the file to the two places where it is used. We also have
   a "check-tree" unit test that ensures those files don't diverge in
   the future.

 - we no longer require CFLAGS set during built. Instead, the sources
   should control the build. For that we have new (simple) headers
   "nm-meta-setting-base.h" that define the right behavior for the
   impl files.

There is still an ugliness (among several): the files must be named the
same for libnm-core and clients/common. Preferably, all our sources have
unique names, but that is not possible with this scheme (without
introducing other ugliness). To mitigate that, include the files only at
one exact place.
2021-02-09 12:38:19 +01:00
Thomas Haller
789347e0d6 shared: copy file instead of symlink "nm-ethtool-utils.h"
"nm-ethtool-utils.h" is part of public API in libnm(-core). It is also
used by shared/nm-base, which must have no dependency on libnm-core.

This was previously solved by symlinking the file. I find that error
prone, because the user might edit one file, without realizing that the
other file also changes.

Instead, copy the file and have it twice. Note that we have a unit test
which checks that both files are (and state) the same.

Copy+paste is a valid way of reusing code. By checking that the copy
does not diverge from the original, the downsides of copy+paste are
mitigated.
2021-02-09 12:38:19 +01:00
Thomas Haller
83a97f887b tests: add "tools/check-tree.sh" script for checking consistency of sources
Our source tree also has certain consistency requirements. Since the
source is in git, this is a rather static check. However, we want to
ensure that future changes don't break it by adding a test.
2021-02-09 12:38:18 +01:00
Thomas Haller
fa3ac35031 shared: remove unused "shared/nm-default.h" 2021-02-09 12:38:18 +01:00
Thomas Haller
66eccf7ad7 all: add "nm-default-systemd{,-shared}.h" as replacement for "nm-default.h" 2021-02-09 12:38:18 +01:00
Thomas Haller
dc2afc9b77 all: add "src/core/nm-default-daemon.h" as replacement for "nm-default.h" 2021-02-09 12:38:18 +01:00
Thomas Haller
78629830c8 all: add "libnm-core/nm-default-libnm-core.h" as replacement for "nm-default.h" 2021-02-09 12:38:18 +01:00
Thomas Haller
a38afcb1d9 all: add "libnm/nm-default-libnm.h" as replacement for "nm-default.h" 2021-02-09 12:38:18 +01:00
Thomas Haller
606612ea59 all: add "libnm/nm-default-client.h" as replacement for "nm-default.h" 2021-02-09 12:38:17 +01:00
Thomas Haller
8f4f91b667 all: add "nm-glib-aux/nm-default-glib-i18n-prog.h" as replacement for "nm-default.h" 2021-02-09 12:38:17 +01:00
Thomas Haller
bbb86cc11a all: add "nm-glib-aux/nm-default-glib-i18n-lib.h" as replacement for "nm-default.h" 2021-02-09 12:38:17 +01:00
Thomas Haller
d69f12f9e7 all: add "nm-glib-aux/nm-default-glib.h" as replacement for "nm-default.h" 2021-02-09 12:38:17 +01:00
Thomas Haller
dbdac49b81 all: add "nm-std-aux/nm-default-std.h" as replacement for "nm-default.h"
autotools projects commonly should include "config.h" as first header.
Also, commonly we need more headers, like glib.h or our nm_auto macros.
Hence, almost all our sources should as first include "nm-default.h".

However, as we build different parts, "nm-default.h" gets controlled
by the NETWORKMANAGER_COMPILATION define which autotools/meson needs
to specify in the build options.

That is confusing.

One advantage of that was, that theoretically the same sources can
be built twice, with different behavior. However, we should avoid doing
that altogether and build static libraries (once) that we link multiple
times.

Another advantage was that if NETWORKMANAGER_COMPILATION is for example
set to build a DAEMON source, there is a check that we don't include
private headers from libnm-core. However, that should be better solved
by not having public, internal and private headers in the same
directory.

Instead, introduce different "nm-default-*.h" headers that don't require
special defines and behave in a consistent way. This way, we require
fewer CFLAGS and it's immediately clear by looking at the source alone
which headers are included. Also, you will be easier see when a wrong
nm-default-*.h header gets included.

Introduce the first replacement. The others will follow.
2021-02-09 12:38:17 +01:00
Thomas Haller
021e87c084 shared: add "shared/nm-std-aux/nm-networkmanager-compilation.h" header 2021-02-09 12:38:17 +01:00
Thomas Haller
37075878a7 libnm: compile keyfile code like libnm-core
By now, keyfile code got relicensed as LGPL-2.1+ and is just a regular part
of libnm-core (in particular, because it uses private API of libnm-core).

It should no longer be in a separate directory, but for now, at lead compile
it the same as libnm-core.
2021-02-09 12:38:17 +01:00
Thomas Haller
6cbc2d715f shared/tests: don't include "nm-default.h" in test utils and remove compile check
Remove the check for NETWORKMANAGER_COMPILATION and NETWORKMANAGER_COMPILATION_TEST
define. We will no longer define that, and the check will be wrong.
2021-02-09 12:38:16 +01:00
Thomas Haller
ed9ff9c3df build: remove unused "nm-core-enum-types.[hc].template" files 2021-02-09 12:38:16 +01:00
Thomas Haller
0bcd453e8c initrd/tests: drop special define for test directory
We got rid of all these redundant defines. All we need, is the base
source directory, which we already define in config.h as
NM_BUILD_SRCDIR. Use that.
2021-02-09 12:38:16 +01:00