Commit Graph

910 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
c47511da7e meson: add version.h as dependency to more targets
version.h can be generated after compilation starts, creating a race condition
between compilation of various .c files and creation of version.h. Let's add it
as a dependency to more build targets that require version.h or build.h.

So far we played whack'a'mole by adding versiondep whenever compilation failed.
In principle any target which includes compilation (i.e. any that has .c
sources directly), could require this. I don't understand why we didn't see
more failures… But it seems reasonable to just add the dependency more widely.
2022-11-08 18:18:34 +01:00
Samuel Thibault
ede5a78f50 shutdown: Add Xen kexec support
In the Xen case, it's the hypervisor which manages kexec. We thus
have to ask it whether a kernel is loaded, instead of relying on
/sys/kernel/kexec_loaded.
2022-11-02 20:47:41 +01:00
Daan De Meyer
1c265fcd59 namespace: Add hidepid/subset support check
Using fsopen()/fsconfig(), we can check if hidepid/subset are supported to
avoid the noisy logs from the kernel if they aren't supported. This works
on centos/redhat 8 as well since they've backported fsopen()/fsconfig().
2022-11-01 16:12:58 +01:00
Zbigniew Jędrzejewski-Szmek
3c3e14a7d8 meson: systemd-repart.standalone
Repart is growing into an important tool on its own, and users might
want to install newer versions on systems that have older systemd. Let's
make this easier by providing a standalone binary.

Related to https://github.com/systemd/mkosi/issues/1228.
2022-10-31 21:12:55 +01:00
Luca Boccassi
034fe54cd5
Merge pull request #24958 from Werkov/meson-generated-directives
Generate dirrectives for fuzzer tests
2022-10-31 21:04:30 +01:00
Zbigniew Jędrzejewski-Szmek
96f8c63601 meson: always use libatomic if found
Semi-quoting https://github.com/systemd/systemd/issues/25057:

clang-16 has made the choice to turn on -Werror=implicit-function-declaration,implicit-int.
(See Gentoo's tracker bug https://bugs.gentoo.org/870412).
Added in commit 132c73b57a, systemd now does a
check to see if libatomic is needed with some compile/link tests with e.g.
__atomic_exchange_1, but the tests don't provide a prototype for
__atomic_exchange_1 so with clang-16 the test fails, breaking the build.

Let's simplify things by linking to libatomic unconditionally if it is found
and seems to work. If actually unneeded, it might be dropped via --as-needed.
This seems to work with gcc and clang.

declare_dependency() is used instead of cc.find_library(), because the latter
picks up a symlink in gcc private directory (e.g.
/usr/lib/gcc/x86_64-redhat-linux/12/libatomic.so), and we don't want that.

Fixes #25057.
2022-10-21 17:40:59 +02:00
Michal Koutný
7e343b530e meson: Generate fuzzer inputs with directives
The lists of directives for fuzzer tests are maintained manually in the
repo. There is a tools/check-directives.sh script that runs during test
phase and reports stale directive lists.
Let's rework the script into a generator so that these directive files
are created on-the-flight and needn't be updated whenever a unit file
directives change. The scripts is rewritten in Python to get rid of gawk
dependency and each generated file is a separate meson target so that
incremental builds refresh what is just necessary (and parallelize
(negligible)).

Note: test/fuzz/fuzz-unit-file/directives-all.slice is kept since there
is not automated way to generate it (it is not covered by the check
script neither).
2022-10-20 14:43:50 +02:00
Daan De Meyer
3f5225d7f3 qrcode-util: Add support for libqrencode 3.0
They didn't actually change API between major versions, so let's
support the previous version as well so we can add CentOS 8 Stream
back to CI.
2022-10-17 08:45:16 +02:00
Michal Koutný
7db5761dda meson: Store fuzz tests in structured way
Put fuzzer tests into dictionary that maps `fuzzer->list of inputs`
instead of the flat list.
This is just refactoring with no intentional .
2022-10-11 09:48:05 +02:00
Daan De Meyer
46fb302f72 Revert "journal: Add --convert= command to journalctl"
This reverts commit 721620e8a3.

This commit was accidentally merged as part of #22998
2022-10-08 03:24:25 +09:00
Luca Boccassi
5791594a0f meson: bump numbers for v252-rc1 2022-10-07 16:37:36 +02:00
Daan De Meyer
721620e8a3 journal: Add --convert= command to journalctl
--convert writes the journal files read by journalctl to the given
location. The location should be specified as a full journal file
path (e.g. /a/b/c/converted.journal). The directory specifies where
the converted journal files will be stored. The filename specifies
the naming convention the converted journal files will follow.
2022-10-07 12:28:09 +02:00
Zbigniew Jędrzejewski-Szmek
c76691d708
Merge pull request #24511 from martinetd/bpf1
libbpf: Add libbpf 1.0.0 compat
2022-10-06 19:01:33 +02:00
Michal Koutný
3286770daa meson: Require TPM2 for measuring utilities
I happened to run build with openssl but no tpm2 and ran into issues
like:

        [313/1382] Compiling C object systemd-measure.p/src_boot_measure.c.o
        FAILED: systemd-measure.p/src_boot_measure.c.o
        cc -Isystemd-measure.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=gnu11 -O0 -g -Wno-missing-field-initializers -Wno-unused-parameter -Wdate-time -Wendif-labels -Werror=format=2 -Werror=format-signedness -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=int-conversion -Werror=overflow -Werror=override-init -Werror=return-type -Werror=shift-count-overflow -Werror=shift-overflow=2 -Werror=undef -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 -Wunused-function -Wwrite-strings -Wno-unused-result -Werror=missing-declarations -Werror=missing-prototypes -fdiagnostics-show-option -fno-common -fno-strict-aliasing -fstack-protector -fstack-protector-strong -fvisibility=hidden --param=ssp-buffer-size=4 -fno-omit-frame-pointer -Werror=shadow -include config.h -DOPENSSL_LOAD_CONF -MD -MQ systemd-measure.p/src_boot_measure.c.o -MF systemd-measure.p/src_boot_measure.c.o.d -o systemd-measure.p/src_boot_measure.c.o -c ../src/boot/measure.c
        ../src/boot/measure.c: In function ‘verb_sign’:
        ../src/boot/measure.c:710:48: error: variable ‘c’ has initializer but incomplete type
          710 |         _cleanup_(tpm2_context_destroy) struct tpm2_context c = {};

        [308/1382] Compiling C object systemd-pcrphase.p/src_boot_pcrphase.c.o
        FAILED: systemd-pcrphase.p/src_boot_pcrphase.c.o
        cc -Isystemd-pcrphase.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=gnu11 -O0 -g -Wno-missing-field-initializers -Wno-unused-parameter -Wdate-time -Wendif-labels -Werror=format=2 -Werror=format-signedness -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=int-conversion -Werror=overflow -Werror=override-init -Werror=return-type -Werror=shift-count-overflow -Werror=shift-overflow=2 -Werror=undef -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 -Wunused-function -Wwrite-strings -Wno-unused-result -Werror=missing-declarations -Werror=missing-prototypes -fdiagnostics-show-option -fno-common -fno-strict-aliasing -fstack-protector -fstack-protector-strong -fvisibility=hidden --param=ssp-buffer-size=4 -fno-omit-frame-pointer -Werror=shadow -include config.h -DOPENSSL_LOAD_CONF -MD -MQ systemd-pcrphase.p/src_boot_pcrphase.c.o -MF systemd-pcrphase.p/src_boot_pcrphase.c.o.d -o systemd-pcrphase.p/src_boot_pcrphase.c.o -c ../src/boot/pcrphase.c
        ../src/boot/pcrphase.c: In function ‘determine_banks’:
        ../src/boot/pcrphase.c:117:24: error: unknown type name ‘TPMI_ALG_HASH’
          117 |         _cleanup_free_ TPMI_ALG_HASH *algs = NULL;

Guarding the utilites with HAVE_TPM2 fixes the issue for me.

This complements #24811.
2022-10-06 22:57:45 +09:00
Dominique Martinet
87e462f713 libbpf: add compat helpers for libbpf down to 0.1.0
- new symbols are available from libbpf 0.6.0 so could be used with
libbpf.so.0, but we're sure the old symbols will be there and this
simplifies code
- detection at runtime should always work, regardless of whether systemd
has been compiled with older or newer libbpf and runs with older or newer
libbpf
2022-10-06 21:33:55 +09:00
Daan De Meyer
e2490f7384 Bump libbpf version to 0.7
We already depend on the skeleton APIs introduced in libbpf 0.7 so
let's bump our minimum version to reflect that.

We don't enforce bpf compilation on mkosi anymore since not all
distros have sufficiently up-to-date libbpf available.
2022-10-06 07:31:20 +09:00
James Hilliard
b88323e4e0 meson: set minimum libbpf/bpftool versions for bpf-gcc
We need the following libbpf commits for bpf-gcc compatibility:
 - 3d484ca473
 - b31ca3fa0e

These are first present in libbpf 1.0.0 and bpftool 7.0.0.
2022-10-01 13:24:37 +09:00
Yu Watanabe
e0f435f935 meson: libfido2 requires openssl
Fixes compile error with -Dopenssl=false.
```
In file included from ../../home/watanabe/git/systemd/src/shared/pkcs11-util.h:12,
                 from ../../home/watanabe/git/systemd/src/cryptenroll/cryptenroll.c:24:
../../home/watanabe/git/systemd/src/shared/openssl-util.h:56:21: error: conflicting types for ‘X509’; have ‘struct X509’
   56 | typedef struct X509 X509;
      |                     ^~~~
In file included from /usr/include/openssl/crypto.h:25,
                 from /usr/include/openssl/bio.h:20,
                 from /usr/include/openssl/asn1.h:16,
                 from /usr/include/openssl/ec.h:17,
                 from /usr/include/fido.h:10,
                 from ../../home/watanabe/git/systemd/src/shared/libfido2-util.h:18,
                 from ../../home/watanabe/git/systemd/src/cryptenroll/cryptenroll-fido2.h:7,
                 from ../../home/watanabe/git/systemd/src/cryptenroll/cryptenroll.c:6:
/usr/include/openssl/ossl_typ.h:123:24: note: previous declaration of ‘X509’ with type ‘X509’ {aka ‘struct x509_st’}
  123 | typedef struct x509_st X509;
      |                        ^~~~
```
2022-09-25 07:53:06 +09:00
Daan De Meyer
b456191d3c repart: Add support for generating verity sig partitions 2022-09-23 16:15:37 +02:00
Lennart Poettering
708d752479 boot: add new pcrphase tool to measure barrier strings into PCR 11 2022-09-22 16:52:06 +02:00
Yu Watanabe
57c15ca357 meson: make several tests run sequentially
Follow-up for f93ba37530.
2022-09-20 02:56:57 +09:00
Heinrich Schuchardt
132c73b57a meson: add libatomic dependency
Building with GCC 12.2 and binutils 2.39 fails on riscv64 Ubuntu Kinetic
with:

FAILED: systemd-oomd
/usr/bin/ld: systemd-oomd.p/src_oom_oomd-util.c.o:
in function `oomd_cgroup_context_acquire':
build/../src/oom/oomd-util.c:415:
undefined reference to `__atomic_exchange_1'

We have to link with -latomic.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-09-15 13:44:11 +01:00
Jan Janssen
a4ea5d19bb meson: Compile with -Werror=format-signedness 2022-08-30 12:03:33 +02:00
Yu Watanabe
2b21522e82 test: merge test-repart.sh and TEST-58-REPART 2022-08-22 17:00:38 +02:00
Frantisek Sumsal
cd7ad0cbde
Merge pull request #24054 from keszybz/initrd-no-reload
Don't do daemon-reload in the initrd
2022-08-18 13:15:14 +00:00
Yu Watanabe
53403091d6 meson: use 'not in'
Follow-ups for 60f97fee2d and
3296334473.
2022-08-09 20:21:30 +01:00
Lennart Poettering
ca1092dc15 measure: add new tool to precalculate PCR values for a kernel image
For now, this simply outputs the PCR hash values expected for a kernel
image, if it's measured like sd-stub would do it.

(Later on, we can extend the tool, to optionally sign these
pre-calculated measurements, in order to implement signed PCR policies
for disk encryption.)
2022-08-02 10:28:49 +02:00
Lennart Poettering
6017eee9ce boot: move unified kernel PE section definitions into 'fundamental' code
Le's share this code between userspace and uefispace. This is useful
later when pre-measuring expected PCRs from userspace.
2022-08-02 10:28:49 +02:00
Eli Schwartz
9e4a50bcdf meson: fix broken boolean kwarg
Everywhere else that `conf.get('ENABLE_*')` is used as a boolean key for
something (for example in if statements) it always checks if == 1, but
in this one case it neglects to do so. This is important because
conf.get yields the same int that was stored, but if statements require
booleans.

So does executable's "install" kwarg, at least according to the
documentation. In actuality, it accepts all types without sanity
checking, then uses python "if bool(var)", so you can actually do
`install: 'do not'` and that's treated identical to `true`. This is a
type-checking bug which Meson will eventually fix.

muon fails on the same code, today.
2022-07-30 13:58:22 +09:00
Eli Schwartz
89cdbe1f08 meson: strip various strings before converting them to integers
"9\n" is not intrinsically a number, although some tools might
auto-strip strings before checking if they are a number. It's not
guaranteed, anyway.
2022-07-30 13:58:22 +09:00
Yu Watanabe
a36be3e57f meson: use 0 for default uids, gids, and time epoch
0 UID and GID are special, and should not be acceptable for the settings.
Hence, we can handle 0 as unset.

Strictly speaking, time epoch with 0 is valid, but I guess no one use
0 as a valid value.
2022-07-30 13:58:12 +09:00
James Hilliard
0a0d489968 journalctl: allow statically linked build
The journalctl tool may be needed on cross compilation hosts in order
to run --update-catalog against a target rootfs.

To avoid reliability issues caused by shared linking allow journalctl
to be linked statically.
2022-07-29 09:22:54 +09:00
asavah
3296334473 meson: fix math flags check 2022-07-27 02:27:43 +09:00
Rudi Heitbaum
3657d3a01c glibc: Remove #include <linux/fs.h> to resolve fsconfig_command/mount_attr conflict with glibc 2.36 2022-07-24 20:52:35 +09:00
Zbigniew Jędrzejewski-Szmek
028a981c00 fstab-generator: add mode to check /sysroot/etc/fstab and maybe do daemon-reload
The idea is that we can peek into /sysroot/etc/fstab and figure out if there's
anything interesting there. We could use a separate binary for this, but we'd
need to duplicate most of the logic that in systemd-fstab-generator. Thus I
think it's nicer to make systemd-fstab-generator work as a multi-call binary.

If called as systemd-sysroot-fstab-check, we look for units that we'd mount and
call daemon-reload and initrd-fs.target/restart, similarly to what we did
before, but in the process itself.
2022-07-23 19:02:39 +02:00
Yu Watanabe
60f97fee2d meson: refuse -ffinite-math-only
Closes #23610.
2022-07-21 09:18:13 +09:00
Yu Watanabe
0925c79c9e
Merge pull request #23881 from keszybz/kernel-install-strikes-yet-again
kernel-install: fix invocation as installkernel, add tests, tweak documentation
2022-07-13 02:44:50 +02:00
Łukasz Stelmach
aa5ae9711e smack: Add DefaultSmackProcessLabel to user.conf and system.conf
DefaultSmackProcessLabel tells systemd what label to assign to its child
process in case SmackProcessLabel is not set in the service file. By
default, when DefaultSmackProcessLabel is not set child processes inherit
label from systemd.

If DefaultSmackProcessLabel is set to "/" (which is an invalid character
for a SMACK label) the DEFAULT_SMACK_PROCESS_LABEL set during compilation
is ignored and systemd act as if the option was unset.
2022-07-12 22:47:32 +01:00
Zbigniew Jędrzejewski-Szmek
f875e6bc39 test-kernel-install: add a simple test that kernel-install copies the files
I opted to tweaking kernel-install to allow overriding config
(with $KERNEL_INSTALL_CONF_ROOT, $KERNEL_INSTALL_PLUGINS). An alternative
would be to build a test environment in test/. We can still do that,
but I think it's nice to have a simple test that is very quick and easy
to debug.

Invocation as installkernel is for #23681.
2022-07-12 09:24:43 +02:00
Zbigniew Jędrzejewski-Szmek
132b63bd31
Merge pull request #15205 from jlebon/pr/preset-all-firstboot
manager: optionally, do a full preset on first boot
2022-07-06 19:11:01 +02:00
Daan De Meyer
c3191c6d4f meson: Assign tests a suite based on their directory
This can be used to run only a subset of tests, e.g.
"meson test -C build --suite journal" to run only the journal
unit tests.
2022-07-04 14:46:30 +02:00
Zbigniew Jędrzejewski-Szmek
b01f31954f Turn mempool_enabled() into a weak symbol
Before we had the following scheme:
mempool_enabled() would check mempool_use_allowed, and
libsystemd-shared would be linked with a .c file that provides mempool_use_allowed=true,
while other things would linked with a different .c file with mempool_use_allowed=false.

In the new scheme, mempool_enabled() itself is a weak symbol. If it's
not found, we assume false. So it only needs to be provided for libsystemd-shared,
where it can return false or true.

test-set-disable-mempool is libshared, so it gets the symbol. But then we
actually disable the mempool via envvar. mempool_enable() is called to check
its return value directly.
2022-06-29 16:51:52 +02:00
Yu Watanabe
88b6f0dee9 meson: show default nspawn locale in summary
Follow-up for a22f518676.
2022-06-27 09:56:13 +02:00
Zbigniew Jędrzejewski-Szmek
107795a759 pkgconfig,rpm: expose vars for user-tmpfiles.d location
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2098553.
2022-06-21 15:49:41 +09:00
Luca Boccassi
039f1673e9 meson: add build targets for libudev, libsystemd and pkg-config
Mirror install tags with the same names and content
2022-06-12 13:13:49 +09:00
Zbigniew Jędrzejewski-Szmek
e538d59367
Merge pull request #23683 from keszybz/status-format
Default to default-status-unit-format=name in developer mode
2022-06-10 14:11:53 +02:00
James Hilliard
76abad4d47 meson: add experimental bpf-gcc compiler support
Not fully working but should make it easier to clean up remaining
issues.
2022-06-10 14:01:19 +02:00
Zbigniew Jędrzejewski-Szmek
819c0dcbf5 meson: use status-unit-format-default=name in developer mode
I think developers are particularly unlikely to find the descriptions
useful, and would benefit from being able to copy&paste unit names.
Let's make this choice automatically.
2022-06-10 13:51:17 +02:00
Zbigniew Jędrzejewski-Szmek
79dec86add meson: add status unit format to summary 2022-06-10 13:51:17 +02:00
Daan De Meyer
8239002226 meson: Build with frame pointers in developer mode
Profiling tools tend to work better when binaries and libraries
are compiled with frame pointers as without them there's no easy
and fast way to get the current stacktrace.
2022-06-09 17:44:26 +01:00