Commit graph

769 commits

Author SHA1 Message Date
Evgeny Vereshchagin d2c3f14fed meson: make it compatible with AFL and honggfuzz again
afl-clang and hufzz-clang try to instrument the code and the
underlying compilers don't like it. It should probably be
fixed in both afl and honggfuzz eventually but until then
let's just use "raw" clang to build bpf-skeletons.

It's a follow-up to https://github.com/systemd/systemd/pull/21607
2021-12-22 15:03:18 +00:00
Yu Watanabe 3112d756a3 meson: fix cross compiling 2021-12-21 14:19:00 +00:00
Mike Gilbert 9a723ed6e8 basic: add a size check to format timex members properly
As of glibc-2.34, the size of members in struct timex varies depending on
the _TIME_BITS macro.

Fixes: https://github.com/systemd/systemd/issues/21826
2021-12-20 12:36:59 +09:00
наб 641e2124de kernel-install: replace 00-entry-directory with K_I_LAYOUT in k-i
341890de86 made "bootctl install" create
ESP\MID, in preparation of cf73f65089 that
followed it and created 00-entry-directory.install to make ESP\MID\KVER
if ESP\MID existed ‒ this meant that "bootctl install" followed by
"kernel-install $(uname -r) /boot/vml*$(uname -r) /boot/ini*$(uname -r)"
actually installed the kernel correctly.

Later, 31e57550b5 reverted the first
commit, meaning, that now running those two commands first installs
sd-boot, but then does nothing. Everything appears to work right,
nothing errors out, but no changes are actually done. To the untrained
eye (all of them), even running with -v appears to work:
all the hooks are run, as is depmod, but, again, nothing happens.

This is horrible. Nothing in either manpage suggests what to do
(nor should it, really), but the user is left with a bootloader that
appears fully funxional, since nothing suggests a failure in the output,
but with an unbootable machine, /no way to boot it/, even if they drop
to an EFI shell, since the boot bundle isn't present on the ESP,
and no real recourse even if they boot into a recovery system,
apart from installing like GRUB or whatever.

00- is purely instrumentation for 90-,
and separating one from the other has led to downstream dissatisfaxion
(indeed, the last mentioned commit cited cited exactly that as the
 reversion reason), while creating $ENTRY_DIR_ABS is only required
for bootloaders using the BLS, and shouldn't itself toggle anything.

To that end, introduce an /{e,l}/k/install.conf file that allows
overriding the detected layout, and detect it as "bls" if
$BOOT_ROOT/$MACHINE_ID ($ENTRY_DIR_ABS/..) exists, otherwise "other" ‒
if a user wishes to select a different bootloader,
like GRUB, they (or, indeed, the postinst script) can specify
layout=grub. This disables 90- and $ENTRY_DIR_ABS manipulation.
2021-12-17 14:57:56 +01:00
Yu Watanabe d9338387d9
Merge pull request #21786 from keszybz/dirent-work
Make FOREACH_DIRENT and FOREACH_DIRENT_ALL declare the iterator variables
2021-12-17 04:07:35 +09:00
Zbigniew Jędrzejewski-Szmek c01543fdd5 meson: drop three more single-use convenience libraries
The way that the cryptsetup plugins were built was unnecessarilly complicated.
We would build three static libraries that would then be linked into dynamic
libraries. No need to do this.

While at it, let's use a convenience library to avoid compiling the shared code
more than once.

We want the output .so files to be located in the main build directory,
like with all consumable build artifacts, so we need to maintain the split
between src/cryptsetup/cryptsetup-token/meson.build and the main meson.build
file.

AFAICT, the build artifacts are the same: exported and undefined symbols are
identical. There is a tiny difference in size, but I think it might be caused
by a different build directory name.
2021-12-16 11:51:40 +01:00
Zbigniew Jędrzejewski-Szmek b93f018f57 meson: don't compile import sources four times
Use a 'convenience library' to do the compilation once and then link the
objects into all the files that need it. Those files are small, so this probably
doesn't matter too much for speed, but has the advantage that we don't get the
same error four times if something goes wrong.

The library is conditionalized in the same way importd itself, because we
cannot build it without the deps.
2021-12-16 10:54:46 +01:00
Yu Watanabe 987dd89c77 meson: build network-generator unconditionally
The service also generates .link files for udevd.
2021-12-16 01:55:20 +09:00
Robert Scheck 7964702007 boot, meson: allow statically linked build
Build option "link-boot-shared" to build a statically linked bootctl and
systemd-bless-boot by using

  -Dlink-boot-shared=false

on systems with full systemd stack except bootctl and systemd-bless-boot,
such as CentOS/RHEL 9.
2021-12-14 09:58:27 +09:00
igo95862 2e081f18d6 Disable exporting D-Bus Introspection XML if cross-compiling
This is a soft disable. Passing `dbus-interfaces-dir` build option
will with path or 'yes' enable exports again even when cross
compiling. (maybe your environment will allow to execute
cross compiled binaries)
2021-12-12 16:51:03 +00:00
Jan Janssen db7f5ab68f test: Add BCD unit test 2021-12-11 21:32:29 +01:00
Jan Janssen 1ad2c76d5d meson: Auto detect efi-ld 2021-12-11 11:29:30 +01:00
igo95862 9ff2b35f87 Export systemd-networkd D-Bus XML introspection 2021-12-11 00:42:39 +00:00
igo95862 e3c6892455 Export D-Bus interfaces to /usr/share/dbus-1/interfaces
Pass -Ddbus-interfaces-dir=no to meson to disable export

Interfaces from:
org.freedesktop.home1
org.freedesktop.hostname1
org.freedesktop.import1
org.freedesktop.locale1
org.freedesktop.LogControl1
org.freedesktop.login1
org.freedesktop.machine1
org.freedesktop.oom1
org.freedesktop.portable1
org.freedesktop.resolve1
org.freedesktop.systemd1
org.freedesktop.timedate1
2021-12-10 08:51:58 +01:00
Zbigniew Jędrzejewski-Szmek 831167f9b4 meson: bump numbers for v250-rc1 2021-12-09 13:33:39 +01:00
James Hilliard d40ce01814 bpf: refactor skeleton generation
This should hopefully fix cross compilation for the bpf programs.
2021-12-07 18:37:17 +01:00
Daan De Meyer 035b0f8fe8 journal: Introduce journald-file.c for journal file write related logic
Currently, all the logic related to writing journal files lives in
journal-file.c which is part of libsystemd (sd-journal). Because it's
part of libsystemd, we can't depend on any code from src/shared.

To allow using code from src/shared when writing journal files, let's
gradually move the write related logic from journal-file.c to
journald-file.c in src/journal. This directory is not part of libsystemd
and as such can use code from src/shared.

We can safely remove any journal write related logic from libsystemd as
it's not used by any public APIs in libsystemd.

This commit introduces the new file along with the JournaldFile struct
which wraps an instance of JournalFile. The goal is to gradually move
more functions from journal-file.c and fields from JournalFile to
journald-file.c and JournaldFile respectively.

This commit also modifies all call sites that write journal files to
use JournaldFile instead of JournalFile. All sd-journal tests that
write journal files are moved to src/journal so they can make use of
journald-file.c.

Because the deferred closes logic is only used by journald, we move it
out of journal-file.c as well. In journal_file_open(), we would wait for
any remaining deferred closes for the file we're about to open to complete
before continuing if the file was not newly created. In journald_file_open(),
we call this logic unconditionally since it stands that if a file is newly
created, it can't have any outstanding deferred closes.

No changes in behavior are introduced aside from the earlier execution
of waiting for any deferred closes to complete when opening a new journal
file.
2021-12-06 22:17:38 +01:00
Zbigniew Jędrzejewski-Szmek ec1574cd8e
Merge pull request #21454 from bluca/inspect_elf
analyze: add inspect-elf verb to parse package metadata
2021-12-06 12:45:25 +01:00
Luca Boccassi 6b12086e1f meson: remove openssl dependency from repart
No longer needed since ade99252e2
2021-12-06 16:09:45 +09:00
Frantisek Sumsal 6108ab163e meson: support versioned llvm binaries in BPF detection 2021-12-03 16:22:52 +01:00
Zbigniew Jędrzejewski-Szmek 939387bdc6
Merge pull request #21170 from keszybz/delibgcryptify
Allow systemd-resolved and systemd-importd to use libgcrypt or libopenssl
2021-12-03 13:44:53 +01:00
Frantisek Sumsal ff7e7c2b3a meson: correctly display enabled features
In 9cf75222f2 the conf.get() statements for `bpf-framework` and
`valgrind` were dropped, which causes the respective features to always
show as disabled (since they don't follow the "standard" naming scheme
with HAVE_/ENABLE_ prefixes).
2021-12-02 22:41:32 +00:00
Zbigniew Jędrzejewski-Szmek e37ad765c8 meson: disallow the combination of cryptolib=openssl and dns-over-tls=gnutls
It could work, but it doesn't make much sense. If we already have openssl as
the cryptolib that provides the necessary support, let's not bring in another
library. Disallowing this simplifies things and reduces our support matrix.
2021-12-02 11:31:20 +01:00
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
Luca Boccassi d48c2721b6 elf-util: add function to parse metadata out of ELF objects
Parse the packaging metadata from an ELF object, if any, and
print a pretty table following the spec defined at:
https://systemd.io/COREDUMP_PACKAGE_METADATA/
2021-11-30 23:14:07 +00: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
Luca Boccassi 5361f62d6d meson: remove libdw dependency from pstore
systemd-pstore does not use any symbol from libdw, and never did,
but the dependency was listed since the beginning
2021-11-30 16:49:59 +00:00
Luca Boccassi ea680f0524 coredump: move elf parsing utilities to src/shared/elf-util 2021-11-30 16:49:59 +00: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