Commit graph

743 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 7e8facb36b port string_hashsum from libgcrypt to openssl^gcrypt
This allows resolved and importd to be built without libgcrypt.

Note that we now say either 'cryptographic library' or 'cryptolib'.

Co-authored-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
2021-12-01 12:36:57 +01:00
Kevin Kuehler 0351cbb9e4 resolve: Port dnssec verify from gcrypt to openssl^gcrypt
Co-authored-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
2021-11-30 23:00:21 +01:00
Zbigniew Jędrzejewski-Szmek 6214d42bd2 import: port importd from libgcrypt to openssl^gcrypt
This is heavily based on Kevin Kuehler's work, but the logic is also
significantly changed: instead of a straighforward port to openssl, both
versions of the code are kept, and at compile time we pick one or the other.

The code is purposefully kept "dumb" — the idea is that the libgcrypt codepaths
are only temporary and will be removed after everybody upgrades to openssl 3.
Thus, a separate abstraction layer is not introduced. Instead, very simple
ifdefs are used to select one or the other. If we added an abstraction layer,
we'd have to remove it again afterwards, and it don't think it makes sense to
do that for a temporary solution.

Co-authored-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>

# Conflicts:
#	meson.build
2021-11-30 23:00:21 +01:00
Zbigniew Jędrzejewski-Szmek 57633d2376 meson: add config setting to select between openssl and gcrypt
This is not pretty, but it is supposed to be only a temporary measure.
2021-11-30 23:00:21 +01:00
Zbigniew Jędrzejewski-Szmek 48c67fdfb1 meson: upgrade warning about bad init values to an error
We never expect to get this warning, it is most likely to occur if
somebody messes up enumeration values.
2021-11-29 11:16:23 +01:00
Lennart Poettering d357b80d33 homed: add automatic grow/shrink ("rebalancing") 2021-11-25 18:28:44 +01:00
Zbigniew Jędrzejewski-Szmek e92777d275 meson: add check:true/false to all run_command() invocations
meson-0.59.4-1.fc35.noarch says:
WARNING: You should add the boolean check kwarg to the run_command call.
         It currently defaults to false,
         but it will default to true in future releases of meson.
         See also: https://github.com/mesonbuild/meson/issues/9300
2021-11-18 09:19:23 +01:00
Daan De Meyer 054ed43075 meson: Downgrade unused function from error to warning in local builds
When working on systemd, it's often useful to be able to comment out
a function to see how a build behaves without it. Currently, when doing
this with a static function that's only used once, the build fails because
the function then becomes unused. As such, Let's downgrade the unused
function error to a warning in local builds.
2021-11-16 16:57:36 +01:00
Lennart Poettering 394ac84df9 meson: drop -ffast-math
After reading https://simonbyrne.github.io/notes/fastmath/ I think we
should drop -ffast-math. The JSON code actually looks for NaN, so the
fact it becomes unreliable kinda sucks.

Moreover, we don't do any number crunching. We use floating point fields
only sporadical for trivial math. Hence the optimization is entirely
unnecessary.
2021-11-15 22:24:33 +01:00
Jan Janssen 4cf8a6092e meson: Use fs module
Turns out that meson provides a fs module since 0.53.0, making it unnecessary
to call out to test.
2021-11-14 13:54:27 +09:00
Jan Janssen 9cf75222f2 meson: Rework gnu-efi detection
Moving all of the gnu-efi detection into src/boot/efi/meson.build makes
more sense than having it partially split.

And thanks to subdir_done() we can simplify the code a lot.

Fixes: #21258
2021-11-10 18:25:19 +00:00
Jan Janssen 42e3bb357c meson: Add --warn-common and --fatal-warnings to link flags 2021-11-09 08:57:29 +09:00
Alexander Kanavin bfa0ade9f2 meson: use partial_dependency() to get include directory
Getting the variable directly from pkg-config (without
adding the sysroot prefix) is prone to host contamination
when building in sysroots as the compiler starts looking for the
headers on the host in addition to the sysroot.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
2021-10-19 08:46:29 +02:00
Tony Asleson 1f1a2243c0 Add stand-alone dm-integrity support
This adds support for dm integrity targets and an associated
/etc/integritytab file which is required as the dm integrity device
super block doesn't include all of the required metadata to bring up
the device correctly.  See integritytab man page for details.
2021-10-15 10:19:54 -05:00
Lennart Poettering aab35b1e59 missing: add getdents64() syscall wrapper
glibc 2.30 (Aug 2019) added a wrapper for getdents64(). For older
versions let's define our own.

(This syscall exists since Linux 2.4, hence should be safe to use for
us)
2021-10-11 14:31:34 +02:00
Luca Boccassi 9c6e32a294 Add all other applicable licenses under LICENSES/
License texts copied from:

https://github.com/spdx/license-list-data/blob/master/text/
2021-10-01 17:27:34 +01:00
Zbigniew Jędrzejewski-Szmek 681cb84a63 meson: allow extra net naming schemes to be defined during configuration
In upstream, we have a linearly-growing list of net-naming-scheme defines;
we add a new one for every release where we make user-visible changes to the
naming scheme.

But the general idea was that downstream distributions could define their
own combinations (or even just their own names for existing combinations),
so provide stability for their users. So far this required patching of the
netif-naming-scheme.c and .h files to add the new lines.

With this patch, patching is not required:

$ meson configure build \
  -Dextra-net-naming-schemes=gargoyle=v238+npar_ari+allow_rerenames,gargoyle2=gargoyle+nspawn_long_hash \
  -Ddefault-net-naming-scheme=gargoyle2

or even

$ meson configure build \
  -Dextra-net-naming-schemes=gargoyle=v238+npar_ari+allow_rerenames,gargoyle2=gargoyle+nspawn_long_hash,latest=v249 \
  -Ddefault-net-naming-scheme=gargoyle2

The syntax is a comma-separated list of NAME=name+name+…
This syntax is a bit scary, but any typos result in compilation errors,
so I think it should be OK in practice.

With this approach, we don't allow users to define arbitrary combinations:
what is allowed is still defined at compilation time, so it's up to the
distribution maintainers to provide reasonable combinations. In this regard,
the only difference from status quo is that it's much easier to do (and harder
to do incorrectly, for example by forgetting to add a name to one of the
maps).
2021-09-28 14:22:40 +02:00
Zbigniew Jędrzejewski-Szmek 77faadfdd3 meson: drop the list of valid net naming schemes
We used 'combo' type for the scheme list. For a while we forgot to add
new names, and recently aa0a23ec86 added v241, v243, v245, and v247.
I want to allow defining new values during configuration, which means
that we can't use meson to verify the list of options. So any value is
allowed, but then two tests are added: one that will fail compilation if some
invalid name is given (other than "latest"), and one that converts
DEFAULT_NET_NAMING_SCHEME to a NamingScheme pointer.
2021-09-28 14:22:37 +02:00
Yu Watanabe ebbb1e364b meson: refuse implicit int <-> pointer conversion
Before:
```
Compiling C object src/libsystemd-network/libsystemd-network.a.p/dhcp6-option.c.o
../src/libsystemd-network/dhcp6-option.c: In function ‘dhcp6_option_parse_ia’:
../src/libsystemd-network/dhcp6-option.c:633:70: warning: passing argument 3 of ‘dhcp6_option_parse’ makes pointer from integer without a cast [-Wint-conversion]
  633 |                 r = dhcp6_option_parse(option_data, option_data_len, offset, &subopt, &subdata_len, &subdata);
      |                                                                      ^~~~~~
      |                                                                      |
      |                                                                      size_t {aka long unsigned int}
../src/libsystemd-network/dhcp6-option.c:358:25: note: expected ‘size_t *’ {aka ‘long unsigned int *’} but argument is of type ‘size_t’ {aka ‘long unsigned int’}
  358 |                 size_t *offset,
      |                 ~~~~~~~~^~~~~~
```

After:
```
../src/libsystemd-network/dhcp6-option.c: In function ‘dhcp6_option_parse_ia’:
../src/libsystemd-network/dhcp6-option.c:633:70: error: passing argument 3 of ‘dhcp6_option_parse’ makes pointer from integer without a cast [-Werror=int-conversion]
  633 |                 r = dhcp6_option_parse(option_data, option_data_len, offset, &subopt, &subdata_len, &subdata);
      |                                                                      ^~~~~~
      |                                                                      |
      |                                                                      size_t {aka long unsigned int}
../src/libsystemd-network/dhcp6-option.c:358:25: note: expected ‘size_t *’ {aka ‘long unsigned int *’} but argument is of type ‘size_t’ {aka ‘long unsigned int’}
  358 |                 size_t *offset,
      |                 ~~~~~~~~^~~~~~
cc1: some warnings being treated as errors
```
2021-09-25 07:11:13 +09:00
Lennart Poettering faacf1807e boot: stop making TPM PCR to measure kernel command line into configurable
Everyone appears to use PCR 8 for this, hence I think it's safe to
hardcode that in systemd too.

It's also documented, like here:

https://www.gnu.org/software/grub/manual/grub/html_node/Measured-Boot.html

or here:

https://github.com/rhboot/shim/blob/main/README.tpm

(And the previous name was a bit confusing, since we don't actually just
measure one thing anymore, but mutliple things into multiple PCRs...)
2021-09-23 17:24:09 +02:00
Zbigniew Jędrzejewski-Szmek 51fe206fb3 Define ioprio_{get,set} the same as other compat syscalls 2021-09-22 12:58:47 +02:00
Zbigniew Jędrzejewski-Szmek 465a6f1544
Merge pull request #20767 from bluca/portable_extract_selinux
portable: copy SELinux label when extracting units from images
2021-09-22 12:57:30 +02:00
Zbigniew Jędrzejewski-Szmek 07b382cc2b meson: ignore -Dsmack-run-label= if -Dsmack=false
Compilation would fail because we could have HAVE_SMACK_RUN_LABEL without
HAVE_SMACK. This doesn't make much sense, so let's just make -Dsmack=false
completely disable smack.

Also, the logic in smack-setup.c seems dubious: '#ifdef SMACK_RUN_LABEL'
would evaluate to true even if -Dsmack-run-label='' is used. I think
this was introduced in the conversion to meson:
8b197c3a8a added

AC_ARG_WITH(smack-run-label,
AS_HELP_STRING([--with-smack-run-label=STRING],
        [run systemd --system with a specific SMACK label]),
        [AC_DEFINE_UNQUOTED(SMACK_RUN_LABEL, ["$withval"], [Run with a smack label])],
        [])

i.e. it really was undefined if not specified. And it was same
still in 72cdb3e783 when configure.ac
was dropped.

So let's use the single conditional HAVE_SMACK_RUN_LABEL everywhere.
2021-09-21 20:13:37 +02:00
Michal Sekletar 3435754559 boot: don't build bootctl when -Dgnu-efi=false is set 2021-09-20 17:41:23 +02:00
Luca Boccassi 409f4cf1f2 portable: copy SELinux label when extracting units from images
Units are copied out via sendmsg datafd from images, but that means
the SELinux labels get lost in transit. Extract them and copy them over.

Given recvmsg cannot use multiple IOV transparently when the sizes are
variable, use a '\0' as a separator between the filename and the label.
2021-09-20 14:23:55 +01:00
Antonio Alvarez Feijoo aff870ef61 meson: add missing include directory when using xkbcommon
Otherwise the build fails:

FAILED: systemd-localed.p/src_locale_localed.c.o
cc -Isystemd-localed.p -I. -I.. -Isrc/basic -I../src/basic -Isrc/fundamental -I../src/fundamental -Isrc/systemd -I../src/systemd -I../src/libsystemd/sd-bus -I../src/libsystemd/sd-device -I../src/libsystemd/sd-event -I../src/libsystemd/sd-hwdb -I../src/libsystemd/sd-id128 -I../src/libsystemd/sd-journal -I../src/libsystemd/sd-netlink -I../src/libsystemd/sd-network -I../src/libsystemd/sd-resolve -Isrc/shared -I../src/shared -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu99 -g -Wno-format-signedness -Wno-missing-field-initializers -Wno-unused-parameter -Wdate-time -Wendif-labels -Werror=format=2 -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=overflow -Werror=return-type -Werror=shift-count-overflow -Werror=shift-overflow=2 -Werror=undef -Werror=unused-function -Wfloat-equal -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-aliasing=2 -Wstrict-prototypes -Wsuggest-attribute=noreturn -Wwrite-strings -Wno-unused-result -Werror=missing-declarations -Werror=missing-prototypes -fdiagnostics-show-option -ffast-math -fno-common -fno-strict-aliasing -fstack-protector -fstack-protector-strong -fvisibility=hidden --param=ssp-buffer-size=4 -Werror=shadow -include config.h -MD -MQ systemd-localed.p/src_locale_localed.c.o -MF systemd-localed.p/src_locale_localed.c.o.d -o systemd-localed.p/src_locale_localed.c.o -c ../src/locale/localed.c
../src/locale/localed.c:9:10: fatal error: xkbcommon/xkbcommon.h: No such file or directory
    9 | #include <xkbcommon/xkbcommon.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
2021-09-15 11:38:47 +02:00
Dan Streetman c29537f39e meson.build: change operator combining bools from + to and
upstream meson stopped allowing combining boolean with the plus
operator, and now requires using the logical and operator

reference:
43302d3296

Fixes: #20632
2021-09-04 09:09:32 +09:00
Zbigniew Jędrzejewski-Szmek f064b40ec9 meson: capitalize the last instance of "efi"
All the others in this section use "EFI"…
2021-08-24 15:39:17 +02:00
Ondrej Kozina 8186022c9d Add support for systemd-pkcs11 libcryptsetup plugin.
Add support for systemd-pkcs11 based LUKS2 device activation
via libcryptsetup plugin. This make the feature (pkcs11 sealed
LUKS2 keyslot passphrase) usable from both systemd utilities
and cryptsetup cli.

The feature is configured via -Dlibcryptsetup-plugins combo
with default value set to 'auto'. It get's enabled automatically
when cryptsetup 2.4.0 or later is installed in build system.
2021-08-19 13:58:10 +02:00
Ondrej Kozina 351716e111 Add support for systemd-fido2 libcryptsetup plugin.
Add support for systemd-fido2 based LUKS2 device activation
via libcryptsetup plugin. This make the feature (fido2 sealed
LUKS2 keyslot passphrase) usable from both systemd utilities
and cryptsetup cli.

The feature is configured via -Dlibcryptsetup-plugins combo
with default value set to 'auto'. It get's enabled automatically
when cryptsetup 2.4.0 or later is installed in build system.
2021-08-19 13:58:10 +02:00
Jan Janssen 702d40270a meson: Make unused-function an error 2021-08-13 09:23:45 +02:00
Egor Ignatov b10abe4bba time-set: adjust system clock if rtc is far in future 2021-08-02 20:33:01 +01:00
Luca Boccassi a8d1a8e96d
Merge pull request #20326 from keszybz/meson-0.53.2
Use some more new meson features
2021-07-28 13:30:37 +01:00
Zbigniew Jędrzejewski-Szmek 12085ebb40 meson: use meson's summary()
The output is similar to our hand-crafted status message, but it's nice to use
the built-in functionality. After all, it was amended during development to
support our use case.
2021-07-28 10:04:06 +02:00
Luca Boccassi c1597f07bf
Merge pull request #20319 from keszybz/meson-0.53.2
Bump required meson version to 0.53.2
2021-07-27 23:15:18 +01:00
Zbigniew Jędrzejewski-Szmek f12c5d36a9 meson: use alias_target for doc update commands
This undoes part of 4c890ad3cc: the
implementations of update-dbus-docs and update-man-rules are moved back to
man/meson.build, and alias_target() is used to keep the visible target names
unchanged.

The rules for man pages are reworked so that it's possible to invoke the
targets even if xstlproc is not available. After all, xsltproc is only needed
for the final formatted output, and not other processing.
2021-07-27 20:34:40 +02:00
Zbigniew Jędrzejewski-Szmek 6839ce3318 meson: use alias_target in one place
It was added in meson 0.52.0, and fits very nicely here.
See https://mesonbuild.com/Release-notes-for-0-52-0.html#alias_target.
2021-07-27 19:58:55 +02:00
Zbigniew Jędrzejewski-Szmek fce9abb227 meson: use a/b instead of join_paths(a,b)
It is nicer and shorter.
2021-07-27 19:32:35 +02:00
Zbigniew Jędrzejewski-Szmek 68e101da7a meson: adjust comment about find_program() usage
The FIXME was not correct: with 'dirs' we'd put the fixed path first
(see the docs for find_program()).
2021-07-27 18:53:31 +02:00
Zbigniew Jędrzejewski-Szmek 9247df5a88 meson: require 0.53.2 and drop some workarounds for old meson
Ubuntu Bionic 18.04 has 0.45, so it was below the previously required
minimum version already. Focal 20.04 has 0.53.2. Let's require that
and use various features that are available.
2021-07-27 16:46:46 +02:00
Frantisek Sumsal 99c645b81a meson: add a missing versiondep to libcryptsetup-plugins target
Otherwise the build sometimes fails in a racy way:

```
[274/1850] Compiling C object src/cryptsetup/cryptsetup-tokens/libcryptsetup-token-systemd-tpm2_static.a.p/cryptsetup-token-systemd-tpm2.c.o
FAILED: src/cryptsetup/cryptsetup-tokens/libcryptsetup-token-systemd-tpm2_static.a.p/cryptsetup-token-systemd-tpm2.c.o
cc -Isrc/cryptsetup/cryptsetup-tokens/libcryptsetup-token-systemd-tpm2_static.a.p (...) -c ../build/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-tpm2.c
../build/src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-tpm2.c:12:10: fatal error: version.h: No such file or directory
   12 | #include "version.h"
         |          ^~~~~~~~~~~
         compilation terminated.
```

Follow-up to d1ae38d85a.
2021-07-27 14:44:30 +01:00
Ondrej Kozina d1ae38d85a Add support for systemd-tpm2 libcryptsetup plugin.
Add support for systemd-tpm2 based LUKS2 device activation
via libcryptsetup plugin. This make the feature (tpm2 sealed
LUKS2 keyslot passphrase) usable from both systemd utilities
and cryptsetup cli.

The feature is configured via -Dlibcryptsetup-plugins combo
with default value set to 'auto'. It get's enabled automatically
when cryptsetup 2.4.0 or later is installed in build system.
2021-07-26 15:15:16 +02:00
Luca Boccassi c5a421b3b9
Merge pull request #20276 from keszybz/rpm-restart-wip
Reload user daemons and restart user services at the end of the rpm transaction
2021-07-26 11:02:37 +01:00
Zbigniew Jędrzejewski-Szmek 36d55958cc rpm: restart user services at the end of the transaction
This closes an important gap: so far we would reexecute the system manager and
restart system services that were configured to do so, but we wouldn't do the
same for user managers or user services.

The scheme used for user managers is very similar to the system one, except
that there can be multiple user managers running, so we query the system
manager to get a list of them, and then tell each one to do the equivalent
operations: daemon-reload, disable --now, set-property Markers=+needs-restart,
reload-or-restart --marked.

The total time that can be spend on this is bounded: we execute the commands in
parallel over user managers and units, and additionally set SYSTEMD_BUS_TIMEOUT
to a lower value (15 s by default). User managers should not have too many
units running, and they should be able to do all those operations very
quickly (<< 1s). The final restart operation may take longer, but it's done
asynchronously, so we only wait for the queuing to happen.

The advantage of doing this synchronously is that we can wait for each step to
happen, and for example daemon-reloads can finish before we execute the service
restarts, etc. We can also order various steps wrt. to the phases in the rpm
transaction.

When this was initially proposed, we discussed a more relaxed scheme with bus
property notifications. Such an approach would be more complex because a bunch
of infrastructure would have to be added to system manager to propagate
appropriate notifications to the user managers, and then the user managers
would have to wait for them. Instead, now there is no new code in the managers,
all new functionality is contained in src/rpm/. The ability to call 'systemctl
--user user@' makes this approach very easy. Also, it would be very hard to
order the user manager steps and the rpm transaction steps.

Note: 'systemctl --user disable' is only called for a user managers that are
running. I don't see a nice way around this, and it shouldn't matter too much:
we'll just leave a dangling symlink in the case where the user enabled the
service manually.

A follow-up for https://bugzilla.redhat.com/show_bug.cgi?id=1792468 and
fa97d2fcf6.
2021-07-24 11:53:31 +02:00
Zbigniew Jędrzejewski-Szmek 6d825ab2d4 rpm: use a helper script to actually invoke systemctl commands
Instead of embedding the commands to invoke directly in the macros,
let's use a helper script as indirection. This has a couple of advantages:

- the macro language is awkward, we need to suffix most commands by "|| :"
  and "\", which is easy to get wrong. In the new scheme, the macro becomes
  a single simple command.
- in the script we can use normal syntax highlighting, shellcheck, etc.
- it's also easier to test the invoked commands by invoking the helper
  manually.
- most importantly, the logic is contained in the helper, i.e. we can
  update systemd rpm and everything uses the new helper. Before, we would
  have to rebuild all packages to update the macro definition.

This raises the question whether it makes sense to use the lua scriptlets when
the real work is done in a bash script. I think it's OK: we still have the
efficient lua scripts that do the short scripts, and we use a single shared
implementation in bash to do the more complex stuff.

The meson version is raised to 0.47 because that's needed for install_mode.
We were planning to raise the required version anyway…
2021-07-24 11:46:23 +02:00
Luca BRUNO 6fe23ff31c docs: move /var/log/README to a tmpfiles.d symlink
This moves the /var/log/README content out of /var and into the
docs location, replacing the previous file with a symlink
created through a tmpfiles.d entry.
2021-07-21 17:29:06 +02:00
James Hilliard e5d86ebed5 Add meson option to disable urlify.
Useful for systems that don't use a version of less with hyperlink
support.
2021-07-19 11:57:51 +02:00
Zbigniew Jędrzejewski-Szmek bc2a4af25f meson: re-enable -Wunused-result with clang
We disabled it in f73fb7b742 in response to an
apparent gcc bug. It seems that depending on the combination of optimization
options, gcc still ignores (void). But this seems to work fine with clang, so
let's re-enable the warning conditionally.
2021-07-09 11:11:25 +02:00
Lennart Poettering 5945640e2a creds: add a new tool for listing/showing/encrypting/decrypting credentials 2021-07-08 09:30:45 +02:00
Lennart Poettering 011d129cf4 sd-id128: make sure sd_id128_get_machine_app_specific() logic also works without "khash"
So, as it turns out AF_ALG is turned off in a lot of kernels/container
environments, including our CI. Hence, if we link against OpenSSL
anyway, let's just use that client side. It's also faster.

One of those days we should drop the khash code, and ust use OpenSSL,
once the licensing issues are resolved.
2021-07-08 09:28:28 +02:00