Commit Graph

14 Commits

Author SHA1 Message Date
Thomas Haller
1e15ea9dd5 systemd: add nm_sd_dns_name_normalize() accessor 2021-02-11 09:23:07 +01:00
Thomas Haller
977ea352a0 all: update deprecated SPDX license identifiers
These SPDX license identifiers are deprecated ([1]). Update them.

[1] https://spdx.org/licenses/

  sed \
     -e '1 s%^/\* SPDX-License-Identifier: \(GPL-2.0\|LGPL-2.1\)+ \*/$%/* SPDX-License-Identifier: \1-or-later */%' \
     -e '1,2 s%^\(--\|#\|//\) SPDX-License-Identifier: \(GPL-2.0\|LGPL-2.1\)+$%\1 SPDX-License-Identifier: \2-or-later%' \
     -i \
     $(git grep -l SPDX-License-Identifier -- \
         ':(exclude)shared/c-*/' \
         ':(exclude)shared/n-*/' \
         ':(exclude)shared/systemd/src' \
         ':(exclude)src/systemd/src')
2021-01-05 09:46:21 +01:00
Thomas Haller
88071abb43 all: unify comment style for SPDX-License-Identifier tag
Our coding style recommends C style comments (/* */) instead of C++
(//). Also, systemd (which we partly fork) uses C style comments for
the SPDX-License-Identifier.

Unify the style.

  $ sed -i '1 s#// SPDX-License-Identifier: \([^ ]\+\)$#/* SPDX-License-Identifier: \1 */#' -- $(git ls-files -- '*.[hc]' '*.[hc]pp')
2020-09-29 16:50:53 +02:00
Thomas Haller
2bc3588c1d all/systemd: reformat ./{shared,src}/systemd/ with new clang-format style
./contrib/scripts/nm-code-format.sh -i
2020-09-28 20:01:29 +02:00
Thomas Haller
61a37bdf13 tests: add nmtst_extract_first_word_all() for testing
We usually don't want to use internal API of systemd for our own
purposes. Here, we will use it to check our implementation against
systemd's. Add an accessor to extract_first_word() for testing.

(cherry picked from commit 2a6ecf2128)
2020-06-24 09:02:17 +02:00
Thomas Haller
dec1678fec dhcp: enforce MUD URL to use "https://" scheme
nm_sd_http_url_is_valid_https() is rather clunky, but it is
this way, because we must not disagree with systemd code
about what makes a valid URL.

RFC 8520 says "MUD URLs MUST use the "https" scheme".

See-also: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/463#note_476190

Fixes: cedcea5ee8 ('libnm: fix verification of connection:mud-url property')
2020-04-24 20:54:13 +02:00
Thomas Haller
468c2e01ab systemd: add nm_sd_http_url_is_valid() to access internal http_url_is_valid() 2020-04-24 10:09:50 +02:00
Beniamino Galvani
38f942e038 shared: export systemd dns and hostname validation functions 2019-10-17 18:04:29 +02:00
Thomas Haller
abff46cacf all: manually drop code comments with file description 2019-10-01 07:50:52 +02:00
Lubomir Rintel
24028a2246 all: SPDX header conversion
$ find * -type f |xargs perl contrib/scripts/spdx.pl
  $ git rm contrib/scripts/spdx.pl
2019-09-10 11:19:56 +02:00
Beniamino Galvani
0280fd1a80 shared: add nm_sd_dns_name_to_wire_format()
Add nm_sd_dns_name_to_wire_format() based on systemd utilities to
convert a name into its wire format according to RFC 1035 section
3.1. It will be used to build the content of the DHCP FQDN option.
2019-07-05 11:04:32 +02:00
Thomas Haller
da4f229805 libnm,shared: bzero secrets on failure in nm_utils_base64secret_decode()
Now that unbase64mem_full() understands a secure flag, we can
get this right.
2019-04-12 07:39:50 +02:00
Thomas Haller
0298d54078 systemd: expose unbase64mem() as nm_sd_utils_unbase64mem()
glib has an base64 implementation, but g_base64_decode() et al. gives
no way to detect invalid encodings. All invalid codes are silently
ignored. That is not suitable for strictly validating user input.

Instead of reimplementing of copy-pasting the code from somewhere,
reuse systemd's unbase64mem().

But don't use "hexdecoct.h" directly. Instead, add a single accessor
function to our "nm-sd-utils-shared.h" gateway. We want to be careful
about which bits from systemd we use, because otherwise re-importing
systemd code becomes fragile as you don't know which relevant parts
changed.
2019-01-02 17:08:41 +01:00
Thomas Haller
2c537b9d21 systemd: move basic systemd library to shared/nm-utils
For better or worse, we already pull in large parts of systemd sources.

I need a base64 decode implementation (because glib's g_base64_decode()
cannot reject invalid encodings). Instead of coming up with my own or
copy-paste if from somewhere, reuse systemd's unbase64mem().

But for that, make systemd's basic bits an independent static library
first because I will need it in libnm-core.

This doesn't really change anything except making "libnm-systemd-core.la"
an indpendent static library that could be used from "libnm-core". We
shall still be mindful about which internal code of systemd we use, and only
access functionality that is exposed via "systemd/nm-sd-utils-shared.h".
2019-01-02 17:07:13 +01:00