Commit graph

79 commits

Author SHA1 Message Date
Jonas Dreßler
a4b95a9fcd
libnm-core: Don't allow disabling PMF when using WPA3 key management
Modern WPA3 authentication methods like SAE and WPA-EAP-SUITE-B-192 need
to have management frame protection set to required according to the
standard. Since the last commit, we enforce this automatically when
key-mgmt is set to 'owe', 'sae' or 'wpa-eap-suite-b-192', so disabling
it manually should not be possible.

Add a check to the pmf property that makes sure it can't be set to
'disabled' or 'optional' when one of those key-mgmt methods is used.
2021-05-06 22:23:28 +02:00
Jonas Dreßler
e06f9508d1
libnm-core: Rewrite comment of key-mgmt property
The key-mgmt property of NMSettingWirelessSecurity is slightly confusing
when you know there's also a wpa_supplicant configuration option called
"key_mgmt". Our property is not the same as that supplicant option even
though they do have things in common. NMs key-mgmt is not exactly meant
to configure which AKM suites you want to use, but rather which method
of wifi security is being used (so "wpa2+wpa3 personal", "wpa3 personal
only" or "wpa3 enterprise only").

Try to make this a bit clearer in the documentation of the property by
rewriting it and listing those security methods.
2021-05-06 22:23:28 +02:00
Thomas Haller
207cf3d5d4
libnm: normalize "connection.uuid"
For NetworkManager profiles, "connection.uuid" is the identifier of the
profile. It is supposed to be a UUID, however:

- the UUID was not ensured to be all-lower case. We should make sure
  that our UUIDs are in a consistent manner, so that users can rely
  on the format of the string.

- the UUID was never actually interpreted as a UUID. It only was some
  opaque string, that we use as identifier. We had nm_utils_is_uuid()
  which checks that the format is valid, however that did not fully
  validate the format, like it would accept "----7daf444dd78741a59e1ef1b3c8b1c0e8"
  and "549fac10a25f4bcc912d1ae688c2b4987daf444d" (40 hex characters).

Both invalid UUIDs and non-normalized UUID should be normalized. We
don't want to break existing profiles that use such UUIDs, thus we don't
outright reject them. Let's instead mangle them during
nm_connection_normalize().
2021-05-04 15:51:59 +02:00
Thomas Haller
5bd03fd9a3
libnm: use nm_uuid_is_valid_nmlegacy() to implement nm_utils_is_uuid() 2021-05-04 15:51:57 +02:00
Thomas Haller
2fcabf5699
all: only include "libnm-glib-aux/nm-uuid.h" where needed
Don't let "nm-core-internal.h" (which is a very popular header itself)
drag in "nm-uuid.h".
2021-05-04 15:51:51 +02:00
Thomas Haller
995c78245e
glib-aux/trivial: rename NMUuid API 2021-05-04 15:51:49 +02:00
Thomas Haller
78297db721
libnm,glib-aux: move nm_utils_uuid_*() API to libnm-glib-aux 2021-05-04 15:51:47 +02:00
Thomas Haller
c5985db7cf
libnm,glib-aux: move nm_crypto_md5_hash() to "libnm-glib-aux"
This only uses glib's md5 code and has no dependency on our
crypto libraries (gnutls, nss).

Move it to "libnm-glib-aux" so it can be freely used.

Maybe it deserves a better name, but "nm-shared-utils.h" is a heap of
various utility functions, it's hard to name them well.
2021-05-04 15:51:46 +02:00
Thomas Haller
73cfc4097a
libnm,glib-aux: add and use nm_uuid_generate_random_str*() helpers 2021-05-04 15:51:45 +02:00
Thomas Haller
dd1a618745
libnm,glib-aux: move nm_utils_uuid_is_null() to "nm-uuid.h" 2021-05-04 15:51:45 +02:00
Thomas Haller
73b9883c6f
build: don't link libnm/libnm-core against libuuid
We use util-linux's libuuid for handling UUIDs. But UUIDs are
really a trivial thing, at least the portion that we use.

Reimplement the parse/unparse/generate_random() methods and drop
the dependency. Note that no other libraries from our dependency chain
was dragging in libuuid, so thereby we really get rid of the dependency.

We still require libuuid for building, because it is used by an example
program. Maybe that should be changed, to avoid the build dependency.
But that can be done at a later time.
2021-05-04 15:51:44 +02:00
Thomas Haller
7a15144f75
glib-aux: use nm_uuid_generate_random() helper 2021-05-04 15:51:43 +02:00
Thomas Haller
42d67415b4
glib-aux: use nm_uuid_parse() helper 2021-05-04 15:51:42 +02:00
Thomas Haller
596bf4b91b
glib-aux: use nm_uuid_unparse() 2021-05-04 15:51:42 +02:00
Thomas Haller
36d92182a8
libnm-core/tests: add test for connection.uuid of settings 2021-05-04 15:51:41 +02:00
Thomas Haller
21321ac736
clang-format: reformat code with clang 12
The format depends on the version of the tool. Now that Fedora 34 is
released, update to clang 12 (clang-tools-extra-12.0.0-0.3.rc1.fc34.x86_64).
2021-05-04 13:56:26 +02:00
Thomas Haller
d800009552
libnm: add missing "---end---" tag for ifcfg-rh's "dhcp-hostname-flags" doc
This missing tag confuses the parser and it results in an error in
`man nm-settings-ifcfg-rh`.
2021-05-03 10:41:13 +02:00
Jonas Dreßler
aab56adeea libnm-core: Correctly check for "sae" or "none" when wifi mesh is used
A small bug sneaked into commit 3ef3733c81 ('wireless-security: ensure
Mesh networks can't use anything but SAE') during review: Instead of
allowing only "sae" or "none" as key-mgmt, we now disallow "sae" and
"none", but allow anything else. This is obviously not what was
intended, so fix the check.

Also move the valid_key_mgmt check back up to where it was before that
commit, it seems we want to apply that check in all cases.
2021-04-30 07:38:20 +00:00
Jonas Dreßler
97a49430bb libnm-core: Correct an error message
wpa-eap-suite-b-192 is also valid here, so mention it in the error
message.
2021-04-30 07:38:20 +00:00
Thomas Haller
6400c33915
libnm/trivial: add code comment for _peers_dbus_only_synth() handling of allowed-ips 2021-04-29 17:27:32 +02:00
Fernando Fernandez Mancera
d946aa0c50 wired-setting: add support to accept-all-mac-addresses
This patch is introducing the wired setting accept-all-mac-addresses
property. The value corresponds to the kernel flag IFF_PROMISC.

When accept-all-mac-address is enabled, the interface will accept all
the packets without checking the destination mac address.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
2021-04-22 18:57:30 +00:00
Andrew Zaborowski
195c853a80
libnm-core: Drop repeating words in NM_CONNECTION_CHANGED comment 2021-04-19 18:11:10 +02:00
Thomas Haller
80e30f4562
all: use nm_g_variant_new_au() helper 2021-04-16 11:44:20 +02:00
Thomas Haller
f34841e196
all: use nm_g_variant_new_ay() helper 2021-04-16 11:44:19 +02:00
Thomas Haller
4d6f659e13
all: use nm_g_variant_singleton_a*() helpers 2021-04-16 11:44:19 +02:00
Thomas Haller
15fe784180
libnm-core: use _nm_connection_serialize_non_secret() in _nm_utils_hwaddr_cloned_data_synth() 2021-04-01 17:44:57 +02:00
Andrew Zaborowski
f0fe7384e1
all: Replace deprecated NM_CONNECTION_SERIALIZE_* flags
Review and replace usages of the two nm_connection_to_dbus() flags
marked deprecated in commit 84648e562c98 ('libnm: Refactor
NM_CONNECTION_SERIALIZE_* flags'):

NM_CONNECTION_SERIALIZE_NO_SECRETS and
NM_CONNECTION_SERIALIZE_ONLY_SECRETS.
2021-04-01 17:19:15 +02:00
Andrew Zaborowski
34285fec76
libnm: Refactor NM_CONNECTION_SERIALIZE_* flags
nm-settings-connection.c has code similar to this in two places:

    /* FIXME: improve NMConnection API so we can avoid the overhead of cloning the connection,
     *   in particular if there are no secrets to begin with. */

    connection_cloned = nm_simple_connection_new_clone(new);

    /* Clear out unwanted secrets */
    _nm_connection_clear_secrets_by_secret_flags(connection_cloned,
                                                 NM_SETTING_SECRET_FLAG_NOT_SAVED
                                                     | NM_SETTING_SECRET_FLAG_AGENT_OWNED);

    secrets = nm_g_variant_ref_sink(
        nm_connection_to_dbus(connection_cloned, NM_CONNECTION_SERIALIZE_ONLY_SECRETS));

It seems the secrets filtering can be done by nm_connection_to_dbus() if
the NM_CONNECTION_SERIALIZE_* flags are extended.  The current set of
flags contains flags that start with NO, ONLY and WITH prefixes, which
makes it useless for combining the flags because most combinations of
more than one flag don't have a clear interpretation.  So they're mostly
useful when used alone, i.e. you'd need to add a new enum value for
each new subset of settings to be serialized.

To get the most flexibility from a small set of flags they should
either all be of the WITH_* type or NO_* type.  In the former case they
could be combined to extend the subset of properties serialized, in the
latter case each flag would reduce the subset.  After trying both
options I found it's easier to adapt the current set of flags to the
WITH_* schema while keeping binary and source compatibility.  This
commit changes the set of flags in the following way:

NM_CONNECTION_SERIALIZE_ALL is kept for compatibility but is equivalent
to a combination of other flags.

NM_CONNECTION_SERIALIZE_WITH_NON_SECRET is added with the same value as
NM_CONNECTION_SERIALIZE_NO_SECRETS, it implies that non-secret
properties are included but doesn't prevent including other properties.
Since it couldn't be meaningfully combined with any other flag this
change shouldn't break compatibility.

Similarly NM_CONNECTION_SERIALIZE_WITH_SECRETS is added with the same
value as existing NM_CONNECTION_SERIALIZE_ONLY_SECRETS with the same
consideration about compatibility.

NM_CONNECTION_SERIALIZE_WITH_SECRETS_AGENT_OWNED and the new
NM_CONNECTION_SERIALIZE_WITH_SECRETS_SYSTEM_OWNED and
NM_CONNECTION_SERIALIZE_WITH_SECRETS_NOT_SAVED add only subsets of
secrets and can be combined.  For backwards compatibility
NM_CONNECTION_SERIALIZE_ONLY_SECRETS is basically ignored when either of
these three is present, so that the value:
..ONLY_SECRETS | ..AGENT_OWNED works as previously.
2021-04-01 17:19:15 +02:00
Yuri Chornoivan
5ff6cf575a
libnm: don't use defined strings in translated strings in "nm-setting-ip-config.c"
[thaller@redhat.com: reworked patch by Yuri]

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/800
2021-03-30 17:54:26 +02:00
Thomas Haller
5d6532f2d7
ifcfg-rh: always honor "$VLAN_ID" in ifcfg files
initscripts don't support "$VLAN_ID". They actually support "$VID",
which NetworkManager doesn't.

"$VLAN_ID" was introduced by commit 10b32be37b ('ifcfg-rh: various VLAN
cleanups'). It has a comment about "backward compatibility" for the case
where the reader would ignore "$VLAN_ID" if "$DEVICE"'s name contains
a suffix that is parsable as VLAN ID.

That is wrong. If a new feature gets introduce (like NetworkManager
supporting "$VLAN_ID"), then there is no way that an older version of the
tool -- which doesn't know the new feature yet (initscripts) -- supports it.
This is not what backward compatibility means. Backward compatibility
means that if a user has an old ifcfg-file without "$VLAN_ID", then we
continue parsing it as before.

Consider, when a user (or NetworkManager) writes a configuration

  DEVICE=vlan9
  PHYSDEV=eth0
  VLAN_ID=10

then it makes no sense to ignore VLAN_ID=10 and use "9" instead.
Otherwise the user (or NetworkManager) should not have written the
file this way.

Also, NetworkManager profiles support "connection.interface-name=vlan9"
together with "vlan.id=10". Such a configuration is valid and must be
expressible in ifcfg-rh format. The ifcfg-rh writer code did not somehow
restrict the setting of "$VLAN_ID" to account for this odd behavior. Whenever
NetworkManager in the past wrote VLAN_ID variable to file, it really meant
it.

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

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/794
2021-03-29 21:12:47 +02:00
Thomas Haller
8f138e6bc1
libnm/docs: improve wording for documentation of [match] setting options 2021-03-24 16:50:26 +01:00
Thomas Haller
e922404990
libnm,core: support "prohibit"/"blackhole"/"unreachable" type routing rules 2021-03-23 14:19:39 +01:00
Thomas Haller
972d1ba046
libnm,core: support "uidrange" parameter for routing rules 2021-03-23 14:19:38 +01:00
Thomas Haller
ba72d5a7e7
libnm: use binary search to lookup D-Bus info for routing-rules 2021-03-23 14:19:38 +01:00
Thomas Haller
945612cc5d
all: use nm_net_aux_rtnl_rtntype_{n2a,a2n}() helpers 2021-03-23 14:19:38 +01:00
Thomas Haller
cd00b04099
libnm: expose NM_IW_ESSID_MAX_SIZE define 2021-03-18 11:30:56 +01:00
Thomas Haller
bb132cd6de
libnm: verify ethernet.s390-options.bridge_role value
I don't want to fix this for all "ethernet.s390-options" options,
but at least strictly validate the newly introduced option.
2021-03-16 11:56:31 +01:00
Thomas Haller
6e4cdae256
all: split "range" variant of nm_utils_ptrarray_find_binary_search()
nm_utils_ptrarray_find_binary_search() had two additional output
arguments: the first and last index -- in case the sorted list contains
duplicates.

That's nice, and was used in the past. But now, those output arguments
are no longer used.

So drop them from nm_utils_ptrarray_find_binary_search().

Actually, we could now also drop the previous variant
nm_utils_ptrarray_find_binary_search_range(), as it's only used by unit
tests. However, although not rocket science, getting this right is not
entirely trivial, so lets keep the code in case we need it again.
2021-03-16 09:55:49 +01:00
Thomas Haller
7fde244ed2
libnm: don't assert against valid s390-option keys in nm_setting_wired_add_s390_option()
Asserting against user input is not nice, because it always requires the
caller to check the value first. Don't do that.

Also, don't even check. You can set NM_SETTING_WIRED_S390_OPTIONS
property to any values (except duplicated keys). The C add function
should not be more limited than that. This is also right because
we have verify() which checks for valid settings. And it does so beyond
only checking the keys.

So you could set NM_SETTING_WIRED_S390_OPTIONS properties to invalid
keys. And you could use nm_setting_wired_add_s390_option() to set
invalid values. No need to let nm_setting_wired_add_s390_option() check
for valid keys.
2021-03-16 09:55:49 +01:00
Thomas Haller
e25c458b6f
libnm: add _nm_setting_wired_is_valid_s390_option_value() validation function 2021-03-16 09:55:48 +01:00
Thomas Haller
ddc41d427a
libnm: add internal _nm_setting_wired_is_valid_s390_option() helper 2021-03-16 09:55:48 +01:00
Thomas Haller
fb0ac2e700
libnm: cleanup nm_setting_wired_add_s390_option()
- integers are unsigned. Mark the constants as such.

- assert that we don't overflow G_MAXUINT32. Note that
  nm_setting_wired_get_s390_option()'s index argument
  is of type guint32. So with that API you cannot track
  more than G_MAXUINT32 elements.

- use nm_utils_strdup_reset(). It's less code, but it's
  also self-assignment safe (contrary to the previous code).
2021-03-16 09:55:48 +01:00
Thomas Haller
9f93b0495b
libnm: improve error message for verify() failure for ethernet.s390-options 2021-03-16 09:55:48 +01:00
Thomas Haller
1794d80028
libnm: mark option parameters for nm_setting_wired_get_num_s390_options() as (allow-none) 2021-03-16 09:55:48 +01:00
Thomas Haller
dccfe1df34
libnm: use nm_utils_strv_find_binary_search() in valid_s390_opts_check() 2021-03-16 09:55:48 +01:00
Thomas Haller
b9d73cfb2d
libnm: only check once for valid static array in valid_s390_opts_check()
No need to check every time. The buffer is a const global buffer,
so checking it once is enough.
2021-03-16 09:55:48 +01:00
Thomas Haller
80c98b60da
libnm: make list of valid s390s options const
A const global variable is stored in immutable memory.
You thus get a crash trying to modify it, which is desirable.

The user is really not supposed to modify this buffer,
even if nm_setting_wired_get_valid_s390_options() wrongly
returns a non-const pointer.
2021-03-16 09:55:48 +01:00
Thomas Haller
e4aa3f4b2d
libnm: add "bridge_role" option to "ethernet.s390-options"
https://bugzilla.redhat.com/show_bug.cgi?id=1935842
2021-03-16 09:02:07 +01:00
Thomas Haller
4d609dd92f
libnm: fix exporting nm_setting_match_new() symbol 2021-03-11 19:00:34 +01:00
Wen Liang
5e3482caec docs: improve manual page about ETHTOOL_OPTS
Signed-off-by: Wen Liang <liangwen12year@gmail.com>

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/762
2021-03-10 14:25:51 +01:00