Commit Graph

1252 Commits

Author SHA1 Message Date
Frantisek Sumsal
b59bce308d meson: disable -Wnonnull-compare
This gets enabled by default in gcc-14 and complains everywhere where we
use assert() on an expression that is always true (i.e. using
`int x[static 2]` in function declaration, etc.):

[153/2414] Compiling C object src/basic/libbasic.a.p/fs-util.c.o
In file included from ../src/basic/macro.h:13,
                 from ../src/basic/alloc-util.h:10,
                 from ../src/basic/fs-util.c:11:
../src/basic/fd-util.h: In function ‘format_proc_fd_path’:
../src/fundamental/macro-fundamental.h:74:41: warning: ‘nonnull’ argument ‘buf’ compared to NULL [-Wnonnull-compare]
   74 | #define _unlikely_(x) (__builtin_expect(!!(x), 0))
      |                                         ^~~~~
../src/basic/macro.h:150:21: note: in expansion of macro ‘_unlikely_’
  150 |                 if (_unlikely_(!(expr)))                                \
      |                     ^~~~~~~~~~
../src/basic/macro.h:167:22: note: in expansion of macro ‘assert_message_se’
  167 | #define assert(expr) assert_message_se(expr, #expr)
      |                      ^~~~~~~~~~~~~~~~~
../src/basic/fd-util.h:129:9: note: in expansion of macro ‘assert’
  129 |         assert(buf);
      |         ^~~~~~

Disabling this selectively only for asserts is a bit painful, since the
option is not available in all compilers, and it'd need to be handled in
the EFI stuff as well.
2024-01-17 12:45:39 +01:00
Lennart Poettering
0abd510f7f ssh-proxy: add ssh ProxyCommand tool that can connect to AF_UNIX + AF_VSOCK sockets
This adds a tiny binary that is hooked into SSH client config via
ProxyCommand and which simply connects to an AF_UNIX or AF_VSOCK socket
of choice.

The syntax is as simple as this:

     ssh unix/some/path     # (this connects to AF_UNIX socket /some/path)

or:

     ssh vsock/4711

I used "/" as separator of the protocol ID and the value since ":" is
already taken by SSH itself when doing sftp. And "@" is already taken
for separating the user name.
2024-01-11 16:05:20 +01:00
Lennart Poettering
0e3220684c ssh-generator: add simple new generator 2024-01-11 16:05:20 +01:00
Lennart Poettering
9e61ed1115 vpick: add new tool "systemd-vpick" which exposes vpick on the command line
Usecase:

    $ du $(systemd-vpick /srv/myimages.v/foo___.raw)

In order to determine size of newest image in /srv/myimages.v/
2024-01-03 18:38:46 +01:00
Luca Boccassi
85915f312c meson: check for pefile dependency before enabling ukify
ukify (and all the tests, including the autogenerated check-version-ukify)
does not work unless pefile is available, so track it as a dependency
in meson to avoid unit test failures later
2023-12-24 06:54:41 +09:00
Diego Viola
e6267e832b meson: make lines more consistent 2023-12-16 13:43:44 +01:00
Lennart Poettering
eb981a5b9b mime: register confext/sysext images in shared-mime-info
This make them recognized by file managers and stuff. Maybe one day we
should properly register mime types in the "vnd." namespace with IANA,
but I am too lazy to deal with the bureaucracy for that, hence let's
stick with the x. namespace for now.

This defines confext/sysext DDIs as subtype of:

https://www.iana.org/assignments/media-types/application/vnd.efi.img

Which is what everyone appears to use for raw disk images, in particular
if they contain a GPT partition table.
2023-12-06 22:11:21 +01:00
Lennart Poettering
7e3607996a userdbctl: enable ssh-authorized-keys logic by default
sshd now supports config file drop-ins, hence let's install one to hook
up "userdb ssh-authorized-keys", so that things just work.

We put the drop-in relatively early, so that other drop-ins generally
will override this.

Ideally sshd would support such drop-ins in /usr/ rather than /etc/, but
let's take what we can get. It's not that sshd's upstream was
particularly open to weird ideas from Linux people.
2023-12-06 22:11:04 +01:00
Lennart Poettering
1a292659f2
Merge pull request #29995 from keszybz/voidify-timestamp-getters
Rename and voidify timestamp getters
2023-11-13 14:41:42 +01:00
Zbigniew Jędrzejewski-Szmek
2233035275 meson: fix printing of first-boot-full-preset
The meson summary logic checks for ENABLE_* and HAVE_*, but we used a define
with no prefix. Let's make it ENABLE_… for consistency with other config
options. Obviously this also fixes the summary output.
2023-11-13 13:27:31 +00:00
Zbigniew Jędrzejewski-Szmek
cee60fc36f tree-wide: use the usual spelling of "cannot"
(There's a bunch more in src/basic/linux/, but those files are copied from the
kernel and should not be modified.)
2023-11-13 13:27:36 +01:00
Zbigniew Jędrzejewski-Szmek
2b84d62869 meson: enable vmspawn by default in developer mode
This should also implicitly enabled vmspawn in CI. It wasn't passing even the
basic tests, which we didn't see, because it needs to be explicitly enabled.
2023-11-07 21:56:57 +01:00
Luca Boccassi
8d04721507
Merge pull request #28891 from poettering/pcrlock
new pcrlock tool for generating signed PCR policies for PCR 0, 1, 4, …
2023-11-03 16:07:43 +00:00
Luca Boccassi
1af46aecf5
Merge pull request #29508 from CodethinkLabs/systemd-vmspawn-pr
systemd-vmspawn implementation that only supports disk images
2023-11-03 16:04:38 +00:00
Lennart Poettering
8e35338d09 pcrlock: add pre-defined pcrlock files
These cover well-known measurements done by the UEFI firmware or
systemd.
2023-11-03 11:24:31 +01:00
Lennart Poettering
a434270139 pcrlock: add new pcrlock tool 2023-11-03 11:23:54 +01:00
Lennart Poettering
5b5f8f8b9a firewall: make libiptc dependency a dlopen() one 2023-11-03 09:30:24 +01:00
Lennart Poettering
2bdd7a8ac9 meson: make sure we never actually link to libxenctrl
We don't make use of any of its symbols, we just want the headers, hence
make sure we never try to link against it.
2023-11-02 17:27:07 +00:00
Sam Leonard
9de3cc1484
vmspawn: added initial code for vmspawn
vmspawn-settings.c is currently empty but this will be used in future to
house code for parsing settings from a file
2023-11-02 16:21:40 +00:00
Lennart Poettering
1761066b13 storagetm: add new systemd-storagetm component
This implements a "storage target mode", similar to what MacOS provides
since a long time as "Target Disk Mode":

        https://en.wikipedia.org/wiki/Target_Disk_Mode

This implementation is relatively simple:

1. a new generic target "storage-target-mode.target" is added, which
   when booted into defines the target mode.

2. a small tool and service "systemd-storagetm.service" is added which
   exposes a specific device or all devices as NVMe-TCP devices over the
   network.  NVMe-TCP appears to be hot shit right now how to expose
   block devices over the network. And it's really simple to set up via
   configs, hence our code is relatively short and neat.

The idea is that systemd-storagetm.target can be extended sooner or
later, for example to expose block devices also as USB mass storage
devices and similar, in case the system has "dual mode" USB controller
that can also work as device, not just as host. (And people could also
plug in sharing as NBD, iSCSI, whatever they want.)

How to use this? Boot into your system with a kernel cmdline of
"rd.systemd.unit=storage-target-mode.target ip=link-local", and you'll see on
screen the precise "nvme connect" command line to make the relevant
block devices available locally on some other machine. This all requires
that the target mode stuff is included in the initrd of course. And the
system will the stay in the initrd forever.

Why bother? Primarily three use-cases:

1. Debug a broken system: with very few dependencies during boot get
   access to the raw block device of a broken machine.

2. Migrate from system to another system, by dd'ing the old to the new
   directly.

3. Installing an OS remotely on some device (for example via Thunderbolt
   networking)

(And there might be more, for example the ability to boot from a
laptop's disk on another system)

Limitations:

1. There's no authentication/encryption. Hence: use this on local links
   only.

2. NVMe target mode on Linux supports r/w operation only. Ideally, we'd
   have a read-only mode, for security reasons, and default to it.

Future love:

1. We should have another mode, where we simply expose the homed LUKS
   home dirs like that.

2. Some lightweight hookup with plymouth, to display a (shortened)
   version of the info we write to the console.

To test all this, just run:

    mkosi --kernel-command-line-extra="rd.systemd.unit=storage-target-mode.target" qemu
2023-11-02 14:19:32 +01:00
Luca Boccassi
79e1f7091f
Merge pull request #29816 from bluca/rel
Busywork for RC1
2023-11-01 20:14:11 +00:00
Arseny Maslennikov
c21566d90b
basic/missing_syscall: add missing_fchmodat2()
Follow-up for 8b45281daa
and preparation for later commits.

Since libcs are more interested in the POSIX `fchmodat(3)`, they are
unlikely to provide a direct wrapper for this syscall. Thus, the headers
we examine to set `HAVE_*` are picked somewhat arbitrarily.

Also, hook up `try_fchmodat2()` in `test-seccomp.c`. (Also, correct that
function's prototype, despite the fact that mistake would not matter in
practice)

Co-authored-by: Mike Yuan <me@yhndnzj.com>
2023-11-02 00:23:12 +08:00
Luca Boccassi
e37f3a12b2 meson: bump versions for v255-rc1 2023-11-01 14:07:54 +00:00
Franck Bui
6495361c7d meson: add build option for install path of main config files
This allows distros to install configuration file templates in /usr/lib/systemd
for example.

Currently we install "empty" config files in /etc/systemd/. They serve two
purposes:

- The file contains commented-out values that show the default settings.
- It is easier to edit the right file if it is already there, the user doesn't
  have to type in the path correctly, and the basic file structure is already in
  place so it's easier to edit.

Things that have happened since this approach was put in place:

- We started supporting drop-ins for config files, and drop-ins are the
  recommended way to create local configuration overrides.
- We have systemd-analyze cat-config which takes care of iterating over
  all possible locations (/etc, /run, /usr, /usr/local) and figuring out
  the right file.
- Because of the first two points, systemd-analyze cat-config is much better,
  because it takes care of finding all the drop-ins and figuring out the
  precedence. Looking at files manually is still possible of course, but not
  very convenient.

The disadvantages of the current approach with "empty" files in /etc:

- We clutter up /etc so it's harder to see what the local configuration actually is.
- If a user edits the file, package updates will not override the file (e.g.
  systemd.rpm uses %config(noreplace). This means that the "documented defaults"
  will become stale over time, if the user ever edits the main config file.

Thus, I think that it's reasonable to:

- Install the main config file to /usr/lib so that it serves as reference for
  syntax and option names and default values and is properly updated on package
  upgrades.
- Recommend to users to always use drop-ins for configuration and
  systemd-analyze cat-config to view the documentation.

This setting makes this change opt-in.

Fixes #18420.

[zjs: add more text to the description]
2023-10-17 18:57:45 +02:00
Yu Watanabe
dced8fe402
Merge pull request #29588 from keszybz/net-naming-scheme-255
Untangle the net-naming-scheme mess with SR-IOV-R "representor" information
2023-10-17 19:18:29 +09:00
Jan Janssen
79f4870384 meson: Fix unused format parameter warning 2023-10-17 12:15:07 +08:00
Zbigniew Jędrzejewski-Szmek
386256e699 test: make sure that the default naming scheme name maps back to itself
We were testing the that C constant is defined, but we weren't actually testing
that the string name maps back to itself. This would catch the issue fixed by
the grandparent commit.

The test for the default name is moved to the test file to keep the tests
together. The define is renamed to not have "_TEST" in the name. The issue here
is complicated by the fact that we allow downstreams to inject additional
fields, so we don't know the name of the default scheme if it not set with
-Ddefault-net-naming-scheme=, so _DEFAULT_NET_NAMING_SCHEME[_TEST] is not
defined in all cases, but at least in principle it could be used in other
places. If it exists, it is fully valid.
2023-10-16 21:21:54 +02:00
Luca Boccassi
bb5232b6a3 core: add systemd-executor binary
Currently we spawn services by forking a child process, doing a bunch
of work, and then exec'ing the service executable.

There are some advantages to this approach:

- quick: we immediately have access to all the enourmous amount of
  state simply by virtue of sharing the memory with the parent
- easy to refactor and add features
- part of the same binary, will never be out of sync

There are however significant drawbacks:

- doing work after fork and before exec is against glibc's supported
  case for several APIs we call
- copy-on-write trap: anytime any memory is touched in either parent
  or child, a copy of that page will be triggered
- memory footprint of the child process will be memory footprint of
  PID1, but using the cgroup memory limits of the unit

The last issue is especially problematic on resource constrained
systems where hard memory caps are enforced and swap is not allowed.
As soon as PID1 is under load, with no page out due to no swap, and a
service with a low MemoryMax= tries to start, hilarity ensues.

Add a new systemd-executor binary, that is able to receive all the
required state via memfd, deserialize it, prepare the appropriate
data structures and call exec_child.

Use posix_spawn which uses CLONE_VM + CLONE_VFORK, to ensure there is
no copy-on-write (same address space will be used, and parent process
will be frozen, until exec).
The sd-executor binary is pinned by FD on startup, so that we can
guarantee there will be no incompatibilities during upgrades.
2023-10-12 15:01:51 +01:00
Jordan Williams
465104b4d4 Revert "Revert "meson: use c_args in generator scripts (#10289)""
This reverts commit 0e3cc902fa.

Fixes #10288.
I have confirmed that this does now fix cross-compilation.
It appears that changes upstream in Meson, probably mesonbuild/meson#5263, have made the original MR, #10289, work now.

This needs to be tested to ensure that it doesn't break Travis CI like when it was reverted in #10361.
2023-10-12 12:24:57 +02:00
Abderrahim Kitouni
3c1f396f69 man: support multiple versions of the documentation on the website
This changes the doc-sync meson target from a simple rsync command to a
script that:

* puts the documentation in a subdirectory according to the version
* injects a bit of javascript to add a drop-down to switch between versions
* updates an index.json file with the newly uploaded version
* keeps the latest/ directory up to date with the latest version
* supports a --no-latest switch to be used when uploading older versions
2023-10-09 11:16:20 +01:00
Lennart Poettering
d408a53f78 varlinkctl: add new varlinkctl tool 2023-10-06 11:49:38 +02:00
Lennart Poettering
a121b331e3 repart: make it easy to generate DDIs
This adds --make-ddi=confext, --make-ddi=sysext, --make-ddi=portable, to
make it really easiy to generate DDIs of the specified class. It
it's ultimately just a fancy wrapper around some defaults and in
particular --definitions=.

This makes it very easy to generate a confext:

 $ systemd-repart -C --private-key=privkey.pem --certificate=cert.crt -s mytree/ mytree.confext.raw
2023-10-05 19:08:11 +02:00
Daan De Meyer
180d5aeaa7
Merge pull request #29403 from yuwata/journal-decouple-journald-and-journal-remote
journal: drop ManagedJournalFile and decouple journald and journal-remote
2023-10-04 07:55:52 +02:00
Yu Watanabe
f7b349e88d journal-remote: drop dependencies to journald
Now journal-remote can be built without libjournal_core.
2023-10-02 10:52:45 +09:00
Abderrahim Kitouni
3691e7fce7 man: add checks for missing version information
This adds a new script tools/check-version-history.py and a corresponding
test when building in developer mode. It checks manpages (except dbus
documentation which is handled by update-dbus-docs) for missing version
history information.

It also adds ignore lists based on version 183 (the version that our version
annotations go back to). These can be augmented if we want to ignore other
elements if it doesn't make sense for them to have version annotations.
2023-10-01 11:54:29 +01:00
Luca Boccassi
69f99d1e4e
Merge pull request #29363 from medhefgo/elf2efi
elf2efi: Rework to allow using any linker
2023-09-29 23:01:53 +01:00
Lennart Poettering
2e64cb71b9 tpm2-setup: add new early boot tool for initializing the SRK
This adds an explicit service for initializing the TPM2 SRK. This is
implicitly also done by systemd-cryptsetup, hence strictly speaking
redundant, but doing this early has the benefit that we can parallelize
this in a nicer way. This also write a copy of the SRK public key in PEM
format to /run/ + /var/lib/, thus pinning the disk image to the TPM.
Making the SRK public key is also useful for allowing easy offline
encryption for a specific TPM.

Sooner or later we should probably grow what this service does, the
above is just the first step. For example, the service should probably
offer the ability to reset the TPM (clear the owner hierarchy?) on a
factory reset, if such a policy is needed. And we might want to install
some default AK (?).

Fixes: #27986
Also see: #22637
2023-09-29 19:36:04 +02:00
Jan Janssen
142f0c61a3 elf2efi: Rework ELF section conversion
The main reason we need to apply a whole lot of logic to the section
conversion logic is because PE sections have to be aligned to the page
size (although, currently not even EDK2 enforces this). The process of
achieving this with a linker script is fraught with errors, they are a
pain to set up correctly and suck in general. They are also not
supported by mold, which requires us to forcibly use bfd, which also
means that linker feature detection is easily at odds as meson has a
differnt idea of what linker is in use.

Instead of forcing a manual ELF segment layout with a linker script we
just let the linker do its thing. We then simply copy/concatenate the
sections while observing proper page boundaries.
Note that we could just copy the ELF load *segments* directly and
achieve the same result. Doing this manually allows us to strip sections
we don't need at runtime like the dynamic linking information (the
elf2efi conversion is effectively the dynamic loader).

Important sections like .sbat that we emit directly from code will
currently *not* be exposed as individual PE sections as they are
contained within the ELF segments. A future commit will fix this.
2023-09-29 16:56:30 +02:00
Luca Boccassi
578840bdf9
Merge pull request #29296 from keszybz/make-cryptsetup-offical-and-add-docs
Make cryptsetup offical and add docs
2023-09-27 13:31:11 +01:00
Jan Janssen
90461ef56f meson: Fix version script handling
Build targets should have a link dependency on the version scripts they
use. This also uses absolute paths in anticipation for meson 1.3
needlessly deprecating file to string conversions.
2023-09-26 19:41:53 +02:00
Zbigniew Jędrzejewski-Szmek
a1ca52c2da meson: add comments to compat symlinks 2023-09-26 17:03:26 +02:00
Zbigniew Jędrzejewski-Szmek
fb8d67cd34 meson: move systemd-cryptsetup to /usr/bin
This was requested, though I think an issue was never filed. If people are
supposed to invoke it, even for testing, then it's reasonable to make it
"public".
2023-09-26 17:03:26 +02:00
Lennart Poettering
32295fa08f pcrphase: rename binary to pcrextend
The tool initially just measured the boot phase, but was subsequently
extended to measure file system and machine IDs, too. At AllSystemsGo
there were request to add more, and make the tool generically
accessible.

Hence, let's rename the binary (but not the pcrphase services), to make
clear the tool is not just measureing the boot phase, but a lot of other
things too.

The tool is located in /usr/lib/ and still relatively new, hence let's
just rename the binary and be done with it, while keeping the unit names
stable.

While we are at it, also move the tool out of src/boot/ and into its own
src/pcrextend/ dir, since it's not really doing boot related stuff
anymore.
2023-09-25 17:17:20 +02:00
Luca Boccassi
8ae3c292e3 meson: relax ukify requirements
Installing ukify.py doesn't require a working UEFI architecture, but
only that the bootloader option is enabled (and python3). On Debian
Arch: all packages (like python scripts) can theorethically be built
on any builder with any architecture, so there's no guarantee that
it will actually be an EFI-enabled architecture to do that package build.

Relax the requirement to check only for the ukify config option.
2023-09-21 18:15:57 +02:00
Zbigniew Jędrzejewski-Szmek
1a71ac07ad meson: restore tools/meson-vcs-tag.sh
This conceptually reverts e95acdfe1d,
but the actual contents of the script are taken from the command invocation
in meson with all the updates that happened in the meantime.

One small change is that I replaced () by {}: this avoids one subprocess spawn.
People were worried about the cost of vcs_tag(), and this microoptimization may
help a bit. I measured the speed on machine, and noop rebuilds are still about
100–120 ms.

The logic is entirely moved to the script. This makes the meson config simpler
and also makes it easier to use it externally.

The script is needed for in-place rpm builds, see README.build-in-place.md [1],
where it is invoked from the spec file to determine the project version.

[1] https://src.fedoraproject.org/rpms/systemd/blob/rawhide/f/README.build-in-place.md
2023-09-18 14:37:09 +02:00
Zbigniew Jędrzejewski-Szmek
f933f75295 meson: disallow fuzz test names above 60 characters
The name is created as "systemd:fuzz / fuzz-<fuzzer_name>_<sample_name>"
and if that's very long, output gets wrapped when 'meson test' is run, and
this is rather annoying.

Disallow filenames above 45 characters, which leads a 60 char names.
2023-09-02 17:32:19 +03:00
Luca Boccassi
de6906b1c1
Merge pull request #28999 from keszybz/two-man-ukify-fixe
Make ukify non-experimental
2023-08-29 16:08:49 +01:00
Zbigniew Jędrzejewski-Szmek
f65aa477d9 ukify: move to /usr/bin and mark as non non-experimental
The notice in the man page is removed and the tool is moved into the $PATH.
A compat symlink is provided.

It is fairly widely used now, and realistically we need to keep backwards
compat or people will be very unhappy.
2023-08-29 15:16:35 +03:00
Jan Janssen
29c2f6ac4b meson: Fix version script
Apparently, the `|` has a higher priority…
2023-08-29 01:08:38 +01:00
Zbigniew Jędrzejewski-Szmek
56a0b9065e meson: restore specifications of dependency on version_h
This partially reverts 3c1eee5bed.
I thought that it is not necessary, but
https://mesonbuild.com/Reference-manual_functions.html#vcs_tag says:

> This method returns a custom_tgt should be used to signal dependencies if
> other targets use the file outputted by this.
>
> For example, if you generate a header with this and want to use that in a
> build target, you must add the return value to the sources of that build
> target. Without that, Meson will not know the order in which to build the
> targets.

We can use version_h directly, since we already have it.

Hopefully fixes https://github.com/systemd/systemd/issues/28994.
2023-08-28 14:06:23 +01:00
Zbigniew Jędrzejewski-Szmek
3c1eee5bed meson: drop "versiondep" object
It was added to make sure that the version tag was built early
enough. Now that we use vcs_tag, meson should take care of building
it early enough.
2023-08-26 17:16:59 +02:00
Zbigniew Jędrzejewski-Szmek
1671799bee meson: simplify version_tag handling
Let's also use vcs_tag() when we're doing a non-git build. In those scenarios,
the build would normally be done just once in a given copy, so doing an extra
call does not matter. We can save a few lines of meson config.

The special path was added in 064b8e2c99, with
the justifaction that vcs_tag() is slow and -Dversion-tag=foo can be used to
fix the version tag and speed up partial rebuilds. I think the justification
for this is weak: having an accurate version tag is particularly useful when
developing the code. Shaving of a fraction of a second at the cost of having to
manually update the version seems iffy.

Secondly, with vcs_tag() we can be pretty sure that meson will build the
version file first and that it'll be available to all build steps. Because we
didn't use version tag, we had to manually specify the dependency on version.h
in various places. It seems nicer to use vcs_tag() and not have to deal with
this problem at all.

Finally, the savings in time seem much smaller than back when
064b8e2c99 was made. It reported a change
from 94 ms to 521 ms. But now the difference seems to be about 50 ms:

Before this patch:
$ time ninja -C build
ninja: Entering directory `build'
ninja: no work to do.
ninja -C build  0.04s user 0.02s system 97% cpu 0.057 total
ninja -C build  0.03s user 0.01s system 97% cpu 0.049 total
ninja -C build  0.03s user 0.02s system 96% cpu 0.051 total
ninja -C build  0.03s user 0.01s system 96% cpu 0.049 total
ninja -C build  0.03s user 0.01s system 97% cpu 0.046 total

With the two patches in this PR:
systemd-stable [drop-versiondep] time ninja -C build
ninja: Entering directory `build'
[1/669] Generating version.h with a custom command
ninja -C build  0.08s user 0.03s system 98% cpu 0.106 total
ninja -C build  0.08s user 0.03s system 98% cpu 0.104 total
ninja -C build  0.09s user 0.02s system 98% cpu 0.116 total
ninja -C build  0.08s user 0.02s system 97% cpu 0.108 total

Overall, I think the tiny time savings are not worth the complexity.
2023-08-26 17:09:10 +02:00
Jan Janssen
c78b611e48 meson: Bring back use of vcs_tag
The use of vcs_tag was dropped in #28567, which results in builds having
stale version information once new commit are made.

This also fixes a case where CI builds would have no version information
because they are checked out without any tags for git-describe to use.

Additionally, use `--git-dir` now, as that particular issues seems to
have been fixed by now.
2023-08-26 13:53:42 +09:00
Zbigniew Jędrzejewski-Szmek
c9c4e599fc
Merge pull request #24175 from medhefgo/meson-feature
meson: Use feature options
2023-08-24 11:19:55 +02:00
Zbigniew Jędrzejewski-Szmek
c31ba5cfe9 meson: use 'sh' variable everywhere
We went back-and-forth a bit on this. Very old meson would print a message
about detecting the program if a quoted argument was used, leading to a lot of
noise. So we started to convert various places to use the variable, but then it
turned out that meson < 0.56.2 doesn't handle this correctly and we reverted to
using strings everywhere in 7c22f07cbd. Then at
some point we stopped supporting old meson and over time we started using the
variable in various places again, somewhat inconsistently. Then most calls to
'sh' were removed in 9289e093ae when
install_emptydir() builtin started being used.

Now meson allows either the string or variable to be used, and doesn't print a
message if the string is used. Let's use the variable everywhere. For 'sh', we
could do either, but for other variables, we _do_ want the detection to happen,
for example for git, find, awk, which might not be installed and we want to
detect that early, before we start the build. It would be ugly to use quotes
for some programs, but not for others. Also, a string is still refused for
test(), so we couldn't use the string version even if we didn't care about
detection.
2023-08-24 11:17:50 +02:00
Jan Janssen
7f9a0d6d74 meson: Drop skip-deps option
Now that we use meson feature options for our dependencies, we can just
rely on '--auto-features=disabled' to do the same. One benefit of this
is that specific features can still be force-enabled by overriding it
with the appropriate '-Dfeature=enabled' flag.

The two remaining uses for skip-deps can simply rely on their default
logic that sets the value to 'no' when the dependency is disabled.
2023-08-23 14:57:49 +02:00
Jan Janssen
1e73a64a7a meson: Convert more options to meson features
The semantics for libidn2 and pwquality have changed slightly: We will
pick a preferred one if both are enabled instead of making it an error.
2023-08-23 14:45:02 +02:00
Jan Janssen
847e5585b6 meson: Convert bpf-framework to meson feature 2023-08-23 14:45:02 +02:00
Jan Janssen
40e9c4e45d meson: Convert options to meson features (require)
These options use requre() to conveniently express their dependency
requirements.
2023-08-23 14:45:02 +02:00
Jan Janssen
101b59433b meson: Convert dbus to meson feature
Also, there is no need to conditionalize the get_variable() calls
because not-found dependencies will just return the passed default value
if provided.
2023-08-23 14:45:02 +02:00
Jan Janssen
a0c9ac9ae4 meson: Convert options to meson features (find_library fallback)
This uses a two-step approach to make sure we can fall back to
find_library(), while also skipping the detection if the features are
explicitly disabled.
2023-08-23 14:45:02 +02:00
Jan Janssen
9ee80846f8 meson: Convert fidsk to meson feature
By making this a disabler dependency, we can slightly simplify the code
and it als fixes the build for -Dfdisk=disabled as we failed to create a
fallback empty libshared_fdisk variable.
2023-08-23 14:45:02 +02:00
Jan Janssen
43abc59a27 meson: Use feature options
By using meson features we can replace the handcrafted dependency
auto-detection by just passing the value from get_option directly to the
required arg for dependency, find_library etc.
'auto' features make the dependency optional, 'enabled' requires it
while 'disabled' features will skip detection entirely.

Any skipped or not found dependency will just be a no-op when passed to
build steps and therefore we can also skip the creation of empty vars.

The use of skip_deps for these is dropped here as meson provides a way
to disable all optional features in one go by passing
'-Dauto_features=disabled'.
2023-08-23 14:45:02 +02:00
Lennart Poettering
bf77d59772 vconsole-setup: use "@kernel" rather than "kernel" as special string to leave keymap untouched
This is a magic string, and we should avoid stepping into the territory
of normal keymap names with that, given that users can pick names
otherwise freely.

Hence, prefix the name with a special char to avoid any namespace
issues.

Follow-up for: #28660
2023-08-11 04:17:57 +09:00
Yu Watanabe
9289e093ae meson: use install_emptydir() and drop meson-make-symlink.sh
The script is mostly equivalent to 'mkdir -p' and 'ln -sfr'.
Let's replace it with install_emptydir() builtin function and
inline meson call.
2023-08-08 22:11:34 +01:00
Mike Yuan
ef7f5baae8 vconsole: support KEYMAP=kernel for preserving kernel keymap
Follow-up for #26089 and #28505

Currently, if default-keymap is not empty, there's no way
to ask vconsole-setup to retain the kernel keymap. Let's
accept a special value "kernel" for that purpose.

Addresses the problem mentioned in https://github.com/systemd/systemd/pull/28505#issuecomment-1663681665
2023-08-04 02:20:39 +09:00
Yu Watanabe
dc4a00555a meson: set suite for all tests, and adjust suite for some tests 2023-08-03 20:37:16 +09:00
Yu Watanabe
cbc55c4cce meson: also merge declarations of fuzzers with other executables 2023-08-03 20:37:16 +09:00
Yu Watanabe
130c87b16a meson: merge declarations of normal and test executables 2023-08-03 20:37:16 +09:00
Yu Watanabe
09fa0a0721 test: rename udev-rule-runner -> test-udev-rule-runner
This partially revert 0454cf05d3.
The executable actually does not work with itself, but needs to be
combined with test-udev.py. But, even so, the executable is for testing.

In the next commit, test and normal executables are declared in the same
way, and naming of the executable becomes essential to classify them.
Let's rename the executable and prefix with 'test-'.
2023-08-03 20:37:16 +09:00
Yu Watanabe
12b4cffdae meson: introduce HAVE_DMI flag
The condition is used at several places. Let's introduce a simple flag
for that.
2023-08-03 20:37:16 +09:00
Yu Watanabe
e5cc6d107c meson: move several test declarations
One of the notable change is that previously test-sysusers.sh was installed
unconditionally, but now it is installed only when sysusers is enabled.

Another change is that test-sysv-generator is now re-introduced which
was mistakenly dropped by 6c713961ab.
2023-08-03 20:33:52 +09:00
Yu Watanabe
87e7979de4 meson: move declarations of kernel-install and sulogin-shell 2023-08-01 21:37:31 +09:00
Yu Watanabe
7be6a143da meson: move declarations of networkd and friends 2023-08-01 21:37:31 +09:00
Yu Watanabe
eb51c09d13 meson: move declarations of modules-load, nspawn, update-done, and update-utmp 2023-08-01 21:37:31 +09:00
Yu Watanabe
5371c26933 meson: move declarations of socket-proxy, udevadm, quotacheck, and shutdown 2023-08-01 21:37:31 +09:00
Yu Watanabe
6fab49e4ff meson: move declarations of hwdb, sysusers, and tmpfiles 2023-08-01 21:37:31 +09:00
Yu Watanabe
5c707c8cdb meson: move declarations of busctl, stdio-bridge, and run 2023-08-01 21:37:31 +09:00
Yu Watanabe
9f907d305f meson: move declarations of cgls, cgtop, initctl, and systemd-mount 2023-08-01 21:37:31 +09:00
Yu Watanabe
cb9356254a meson: move declarations of ask-password and friends 2023-08-01 21:37:31 +09:00
Yu Watanabe
e2bdf00a22 meson: move declarations of cgroups-agent, id128, volatile-root, and path 2023-08-01 15:54:45 +09:00
Yu Watanabe
98e39a5561 meson: move declarations of delta, escape, notify, creds, and battery-check 2023-08-01 15:54:45 +09:00
Yu Watanabe
16b081d6ac meson: move declarations of ac-power, detect-virt, sysctl, and sleep 2023-08-01 15:54:45 +09:00
Yu Watanabe
0d6b90b95e meson: move declarations of repart and friends 2023-08-01 15:54:45 +09:00
Yu Watanabe
df490fc79b meson: move declarations of fsck, firstboot, machine-id-setup, and remount-fs 2023-08-01 15:54:45 +09:00
Yu Watanabe
c8c7877167 meson: move declarations of random-seed, vconsole, and sysupdate 2023-08-01 15:54:45 +09:00
Yu Watanabe
2c2c3daa1a meson: move declarations of pstore, oomd, and binfmt 2023-08-01 15:54:45 +09:00
Yu Watanabe
6872ee2a2c meson: move declarations of coredumpd and friends 2023-08-01 15:54:45 +09:00
Yu Watanabe
c26c97af26 meson: move declarations of journal-remote and friends 2023-08-01 15:54:45 +09:00
Yu Watanabe
19361deaea meson: move declarations of machined and friends 2023-08-01 15:54:45 +09:00
Yu Watanabe
269ab341e6 meson: move declarations of timedated and friends 2023-08-01 05:52:50 +09:00
Yu Watanabe
069e7e04ec meson: move declarations of localed and hostnamed 2023-08-01 05:52:50 +09:00
Yu Watanabe
6c713961ab meson: move declarations of several generators 2023-08-01 05:52:50 +09:00
Yu Watanabe
81fe141ba3 meson: move declarations of cryptsetup and friends 2023-08-01 05:52:50 +09:00
Yu Watanabe
7e6ca26fe5 meson: move declarations of backlight, rfkill, and sysupdate-generator 2023-08-01 05:52:50 +09:00
Yu Watanabe
bab54d1fde meson: move declarations of homed and friends 2023-08-01 05:52:50 +09:00
Yu Watanabe
250e597fe7 meson: move declarations of userdbd and friends 2023-08-01 05:52:50 +09:00
Yu Watanabe
8c75dfdd40 meson: move declaration of sysext 2023-08-01 05:52:50 +09:00
Yu Watanabe
f1d95540ef meson: move declarations of portabled and friends 2023-08-01 05:52:50 +09:00
Yu Watanabe
c212163086 meson: move declaration of systemctl 2023-08-01 05:52:50 +09:00
Yu Watanabe
22f37744ca meson: move declaration of socket-activate 2023-08-01 02:31:36 +09:00
Yu Watanabe
bd31a348bf meson: move declarations of bootctl and friends
This also drops unnecessary dependency on libblkid from
systemd-boot-check-no-failures.
2023-08-01 02:31:36 +09:00
Yu Watanabe
dbab4fb9e5 meson: move declaration of user-sessions 2023-08-01 02:31:36 +09:00
Yu Watanabe
b8ed1bf8ee meson: move declarations of logind and friends 2023-08-01 02:31:36 +09:00
Yu Watanabe
c19cd86542 meson: move declarations of resolved and friends 2023-08-01 02:31:36 +09:00
Yu Watanabe
ec57a4ea49 meson: move declarations of dissect and friends 2023-08-01 02:31:36 +09:00
Yu Watanabe
7409342236 meson: move declarations of hibernate-resume 2023-08-01 02:31:36 +09:00
Yu Watanabe
2a4566203e meson: move declarations of several generators 2023-08-01 02:31:36 +09:00
Yu Watanabe
dd1f738e40 meson: move declarations of journald and friends 2023-08-01 02:31:36 +09:00
Yu Watanabe
f727f3b963 meson: move declaration of systemd-analyze 2023-08-01 02:31:36 +09:00
Yu Watanabe
6d06af80d0 meson: move declaration of PID1 2023-07-31 22:17:34 +09:00
Yu Watanabe
2080c0978d meson: move declarations of nss modules 2023-07-31 22:17:34 +09:00
Yu Watanabe
07e43306b3 meson: move declaration of cryptsetup token modules 2023-07-31 22:17:34 +09:00
Yu Watanabe
c335921e13 meson: introduce infra to build executables and shared libraries by using dictionary
That is not used yet. It will be used later.
2023-07-31 22:17:34 +09:00
Yu Watanabe
1d21a7bd99 meson: move declarations of arrays 2023-07-31 22:17:34 +09:00
Yu Watanabe
40c7d3c713 meson: unconditionally add version dependency for all executables and libraries
Otherwise, we can easily forget the dependency.
No functional change, just refactoring.
2023-07-30 05:36:22 +09:00
Yu Watanabe
e95acdfe1d meson: drop short script to generate vcs tag 2023-07-30 04:54:03 +09:00
Luca Boccassi
b0d3095fd6 Drop split-usr and unmerged-usr support
As previously announced, execute order 66:

https://lists.freedesktop.org/archives/systemd-devel/2022-September/048352.html

The meson options split-usr, rootlibdir and rootprefix become no-ops
that print a warning if they are set to anything other than the
default values. We can remove them in a future release.
2023-07-28 19:34:03 +01:00
Daan De Meyer
09444a2e76 elf2efi: Make compatible with python 3.6 again
CentOS 8 ships python 3.6 so let's try and stay compatible with that
since the only feature we're using that requires python 3.9 is the
streamlined type annotations which are trivial to convert back to
the older stuff to stay compatible with python 3.6.
2023-07-14 14:41:19 +02:00
Luca Boccassi
e290bdb77b test-fstab-generator: use test_env
When running from the build directory systemd-detect-virt might not be installed,
so tell meson to set up the PATH accordingly to point to the build directory.

Fixes https://github.com/systemd/systemd/issues/28316
2023-07-10 15:29:38 +01:00
Jan Janssen
7ea44f1733 boot: Fix build for x32
When building on a x32 system we need to explicitly pass `-m64` to get
the right ABI as the kernel and EFI are still 64bit. For this to
actually work, a suitable multilib compiler, 32bit libc headers and
libgcc need to be installed (similar to ia32 builds on x86_64).
2023-07-10 11:09:28 +01:00
Luca Boccassi
4729e84e01 efi: skip libefitest if 'bootloader' is explicitly set to false
On x32 efi_arch will be set as the kernel architecture is just x86_64,
but there's no userland support to build the EFI ABI. When -Dbootloader=false
is set, skip libefitest too.
2023-07-10 00:13:42 +01:00
Yu Watanabe
555737878f meson: allow to fallback to use libxcrypt.pc or glibc's libcrypt
Some distributions still use glibc's libcrypt. In that case, libcrypt.pc
does not exist and dependency() will fail.
Also, even if libxcrypt is used, there may not be a symlink
from libcrypt.pc to libxcrypt.pc. So, let's add a secondary name.

Follow-up for d625f717db.

Fixes #28289.
2023-07-07 12:32:12 +01:00
Luca Boccassi
eed3d044cd meson: bump versions for v254-rc1 2023-07-06 20:57:13 +01:00
Egor Ignatov
1d8aae4327 shared: add libpasswdqc support
Co-authored-by: Dmitry V. Levin <ldv@altlinux.org>
Resolves: #15055
2023-07-06 10:59:41 +00:00
Yu Watanabe
d625f717db meson: first try dependency(), then fallback to find_library()
This also drops the fallback for libacl, libcap, libcrypt, and libgcrypt,
as recent Ubuntu (at least, 20.04 LTS and newer) and Debian (at least, buster
and newer) have relevant .pc files.

Fixes #28161.
2023-06-29 15:38:53 +09:00
Lennart Poettering
5e4c66450c
Merge pull request #27830 from 1awesomeJ/initrd
PID1: Detect battery level in initrd and if low refuse continuing to …
2023-06-28 19:18:03 +02:00
Dmitry V. Levin
51c425dc93 pwquality: remove old built-in cracklib dictionary workaround
The first version of libpwquality with the required change was 1.4.1
released in 2019.
2023-06-28 15:56:38 +02:00
OMOJOLA JOSHUA
e3d4148d50 PID1: detect battery level in initrd and if low refuse continuing to boot, print message and shut down. 2023-06-28 14:48:54 +01:00
Yu Watanabe
16e1e4b3e7 meson: drop doubled empty line 2023-06-27 22:34:25 -06:00
Lennart Poettering
031d21bc45
Merge pull request #27843 from yuwata/usleep_safe
time-util: introduce usleep_safe()
2023-06-23 23:03:15 +02:00
Yu Watanabe
84d953e87a meson: sort types 2023-06-22 15:24:57 +09:00
Yu Watanabe
c20d291416 meson: fix test dependency
Follow-up for daf4e78e48.
2023-06-22 14:37:45 +09:00
Yu Watanabe
1782534bb1 meson: shorten code a bit 2023-06-22 14:37:24 +09:00
Yu Watanabe
e04e42312d meson: drop wrong and redundant assignment
Follow-up for b62ee354dd.
2023-06-22 14:20:32 +09:00
Yu Watanabe
d37dee7450 meson: also build symbol tests for static-libsystemd=no-pic 2023-06-22 14:20:32 +09:00
Yu Watanabe
67b1c943cb meson: add dependency for udev runner to test 2023-06-22 14:20:32 +09:00
Yu Watanabe
35c035a1a7 meson: bump required version to 0.60.0
To suppress warning about install_tag argument.
2023-06-16 10:43:06 +09:00
Yu Watanabe
ff5becf585 meson: bump required version to 0.59.0
fs.stemp() and fs.name() can take File object since 0.59.0.
2023-06-16 10:43:06 +09:00
Yu Watanabe
d1b0d8415c meson: drop redundant spaces 2023-06-16 10:43:06 +09:00
Luca Boccassi
4dad6101fd
Merge pull request #28038 from mrc0mmand/cleanups
A couple of cleanups
2023-06-14 23:18:04 +01:00
Frantisek Sumsal
7f4544c9bc activate: rename to socket-activate
To make the naming consistent with the rest of the utils, i.e. binary
name minus the systemd- prefix.
2023-06-14 20:39:10 +02:00
Jan Janssen
739a62bb40 meson: Use fs module in more places 2023-06-14 16:05:52 +02:00
Lennart Poettering
5bc4570fd4
Merge pull request #26728 from keszybz/meson-update
Meson version update
2023-06-13 23:38:41 +02:00
Lennart Poettering
18cad4ebda
Merge pull request #27846 from keszybz/link-mode-generation
Autogenerate list of link modes
2023-06-13 23:03:51 +02:00
Yu Watanabe
80dc9ad98c meson: bump required version to 0.56.0 2023-06-12 11:01:58 +02:00
Yu Watanabe
573c0dc134 meson: bump required version to 0.55.0 2023-06-12 11:01:58 +02:00
Yu Watanabe
daf4e78e48 meson: bump required version to 0.54.0 2023-06-12 11:01:58 +02:00
Zbigniew Jędrzejewski-Szmek
78103450b4 meson: define _GNU_SOURCE as '1'
This changes the generated config.h file thusly:
-#define _GNU_SOURCE
+#define _GNU_SOURCE 1

Canonically, _GNU_SOURCE is just defined, without any value, but g++ defines
_GNU_SOURCE implicitly [1]. This causes a warning about a redefinition during
complilation of C++ programs after '-include config.h'. Our config attempts to
inject this (and a bunch of other arguments) into all compliations. But before
meson 0.54, flags for dependencies were not propagated correctly (*), and the C++
compilation was done without various flags (**). Once that was fixed, we started
getting a warning.

[1] http://gcc.gnu.org/onlinedocs/libstdc++/faq.html#faq.predefined
(*) Actually, the changelog doesn't say anything. But it mentions various work
    related to dependency propagation, and apparently this changes as a side
    effect.
(**) -fno-strict-aliasing
    -fstrict-flex-arrays=1
    -fvisibility=hidden
    -fno-omit-frame-pointer
    -include config.h

This could be solved in various ways, but it'd require either making the
compilation command line longer, which we want to avoid for readability of the
build logs, or splitting the logic to define the args for C++ progs separately,
which would make our meson.build files more complicated. Changing the
definition to '1' also solves the issue (because apparently now we match the
implicit definition), and shouldn't have other effects. I checked compilation
with gcc and clang. Maybe on other systems this could cause problems. We can
revisit if people report issues.
2023-06-12 10:59:45 +02:00
Luca Boccassi
d30d9bf0ac meson: add systemd.pc and udev.pc to 'devel' target/tag
Same as the other pkg-config files, it is useful to install these in a specific
target that doesn't require compiling anything
2023-06-12 14:45:42 +09:00