Commit Graph

228 Commits

Author SHA1 Message Date
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
Lennart Poettering
8a8b4a8784 shared: move uid-alloc-range.[ch] from src/shared/ → src/basic/
This way we can use it in libsystemd
2023-06-08 09:32:04 +02:00
Zbigniew Jędrzejewski-Szmek
1e473c2ebb meson: use "cpp -E -dM" to process header file
This was requested in review:
https://github.com/systemd/systemd/pull/27846#discussion_r1210383265

I kept this as separate commit because the change would impact both of
the previous commits and splitting it up seems like unnecessary work.
The result is unchanged.

v2:
- use universal_newlines=True to keep compat with Python 3.6 on C8S.
2023-06-07 10:48:36 +02:00
Lennart Poettering
af4e8e86ec battery-util: split out code that checks AC power state into its own .c/.h pair
No code change, just some splitting out of the relevant code from
udev-util.[ch].

This makes sense on its own, but is also prepartion to move the code
that checks for low battery state into battery-util.[ch], too.
2023-06-05 12:18:21 +02:00
Daan De Meyer
0690160e2c label: Rename to label-util.h 2023-05-30 14:50:56 +02:00
Zbigniew Jędrzejewski-Szmek
c18dde32e5 man: generate link mode list dynamically
The entries are sorted by speed. Some fields are left empty when there is no
clear value to use. The table is much longer now, but I think it's better to
document the allowed values, even if some are not terribly useful.

Fixes #26256.
2023-05-30 13:05:33 +02:00
Zbigniew Jędrzejewski-Szmek
6049ddcca2 shared/ethtool-util: autogenerate table of link mode names
We updated this table manually, but the kernel adds new modes periodically
and we forget to do that. So let that happen automatically whenever we import
new kernel headers.

C.f. 72dda93acb.

Effectively, this adds:
        [ETHTOOL_LINK_MODE_10baseT1L_Full_BIT]             = "10baset1l-full",
        [ETHTOOL_LINK_MODE_800000baseCR8_Full_BIT]         = "800000basecr8-full",
        [ETHTOOL_LINK_MODE_800000baseKR8_Full_BIT]         = "800000basekr8-full",
        [ETHTOOL_LINK_MODE_800000baseDR8_Full_BIT]         = "800000basedr8-full",
        [ETHTOOL_LINK_MODE_800000baseDR8_2_Full_BIT]       = "800000basedr8-2-full",
        [ETHTOOL_LINK_MODE_800000baseSR8_Full_BIT]         = "800000basesr8-full",
        [ETHTOOL_LINK_MODE_800000baseVR8_Full_BIT]         = "800000basevr8-full",

N_ADVERTISE needed to be increased because we need more bits.
2023-05-30 13:05:33 +02:00
Wolfgang Müller
38fc5e0314 cryptsetup-fido2: Depend on libcryptsetup
crypsetup-fido2 always depended on both libfido2 and libcryptsetup, but
0a8e026e82 forgot to make the then
implicit dependency on libcryptsetup explicit when moving it from
cryptsetup/ to shared/. This breaks builds when libfido2 is autodetected
but the system is missing libcryptsetup.

Introduce an explicit check for HAVE_LIBCRYPTSETUP such that
cryptsetup-fido2 is only built when both libraries are available.

Fixes #27374.
2023-04-25 02:00:16 +01:00
Lennart Poettering
b3a062cb80 lsm-util: move detection of support of LSMs into a new lsm-util.[ch] helper
This makes the bpf LSM check generic, so that we can use it elsewhere.
it also drops the caching inside it, given that bpf-lsm code in PID1
will cache it a second time a stack frame further up when it checks for
various other bpf functionality.
2023-04-18 08:22:21 +02:00
Lennart Poettering
d452335aa4 dissect: add image dissection policy framework 2023-04-05 20:44:36 +02:00
Luca Boccassi
d51f8eb366 rename extension-release.[c|h] -> extension-util.[c|h]
It will be used for other extension DDI validation, not just for extension-release
validation
2023-03-30 11:25:17 +01:00
Yu Watanabe
9e43296fd2 bootctl: split-out entry token related definitions into boot-entry.[ch]
No functional change, just preparation for later commits.
These can be used in kernel-install later.

Note, unlike the our usual coding style, the arguments for
boot_entry_token_ensure() and parse_boot_entry_token_type() are
referenced, updated, and may freed, hence, always pass initialized
values. That's why they are not named as 'ret_xyz'.
2023-03-27 09:51:18 +02:00
Yu Watanabe
5689e161cf util: rename uki-util.[ch] -> kernel-image.[ch]
As the file contains functions not only for UKI.
2023-03-21 16:49:26 +09:00
Yu Watanabe
16af02cd97 uki-util: move functions for inspecting kernel to uki-util.[ch] 2023-03-17 20:40:34 +09:00
Yu Watanabe
c9501b03cd Merge pull request #26641 from medhefgo/boot-elf2efi
boot: Drop gnu-efi / Add elf2efi.py
2023-03-11 17:15:01 +09:00
Mike Yuan
a01c4bc9af shared: extract edit-util from systemctl-edit 2023-03-11 01:38:52 +08:00
Daan De Meyer
4dd888dc92 lock-util: Move to src/basic 2023-03-10 11:57:43 +01:00
Jan Janssen
9214828313 meson: Introduce userspace dep
This will help in a later commit to separate userspace from EFI builds.
2023-03-10 11:40:14 +01:00
Daan De Meyer
64e89f56a9 lockfile-util: Rename to lock-util 2023-03-10 10:14:43 +01:00
Lennart Poettering
9b2c161481 shared: add a common SIGRTMIN-18 handler 2023-03-01 09:43:23 +01:00
Lennart Poettering
d499fdbcf0 shared: move psi-util.[ch] to basic/ so that we can use it in sd-event 2023-02-17 23:46:19 +00:00
Jan Janssen
4a7ee0a521 meson: Do not include headers in source lists
Meson+ninja+compiler do this for us and are better at it.

https://mesonbuild.com/FAQ.html#do-i-need-to-add-my-headers-to-the-sources-list-like-in-autotools
2023-01-24 22:04:03 +01:00
Richard Phibel
cd48e23f6a core: add OpenFile setting 2023-01-10 15:16:26 +01:00
Peter Cai
0a8e026e82 cryptsetup-fido2: Relocate to libsystemd-shared 2022-12-22 08:43:50 -05:00
Luca Boccassi
da035a3a24 p11kit: switch to dlopen() 2022-12-19 14:49:01 +01:00
Lennart Poettering
f8cf3d19d2 fdisk: introduce common fdisk_new_context_fd() helper
We do the same thing over and over again and it's a bit ugly, hence
let's unify the code for it at one common place.
2022-11-26 11:28:05 +09:00
Zbigniew Jędrzejewski-Szmek
08221c5743 shared: make libmount_parse() non-inline
Back in e2857b3d87 I added this function
as static inline in order to avoid linking libmount into libshared.
Nevertheless, a dependency on libmount was added to libbasic in
9e7f941acb, and later moved to libshared
in 77c772f227. So the shenanigan with an
inline function is not useful, let's make it a normal function.
2022-11-09 09:20:34 +01:00
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
Yu Watanabe
a2ea44b7db meson: sort libraries
Except for 'threads'.

Follow-up for ede5a78f50.
2022-11-04 11:32:22 +09: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
Anita Zhang
008798e90c core: serialize/deserialize varlink sockets for pid1
Fixes #20330
2022-10-14 09:54:05 -07:00
Yu Watanabe
a30d3c0134 uid-range: move to src/basic/
To make the functions defined in the files usable by libsystemd library.
2022-09-08 11:08:43 +09:00
Lennart Poettering
a8835c1190 condition: split out order operator enum
Let's move the operator enum into its own .c/.h file, so that we can
reuse it elsewhere, in particular systemd-analyze's compare-versions
logic.

Let's rename the concept CompareOperator, since it is nowadays
genericlaly about both order *and* fnmatch comparisons, hence just
naming it "order" is misleading.
2022-09-01 23:12:34 +02:00
Yu Watanabe
50e23ac667 daemon-util: introduce several helper functions for fd store 2022-08-16 21:49:00 +09:00
Yu Watanabe
3d36b5d7e7 locale-setup: merge locale handling in PID1 and localed 2022-06-14 20:56:23 +09:00
Daan De Meyer
db6f9b02a7 Merge pull request #23645 from DaanDeMeyer/journalctl-static-destructor
journalctl: Use STATIC_DESTRUCTOR_REGISTER()
2022-06-07 12:28:37 +01:00
Michael Biebl
5fb225615b meson: install libsystemd-shared into rootpkglibdir
Introduce rootpkglibdir for installing libsystemd-{shared,core}.so.
The benefit over using rootlibexecdir is that this path can be
multiarch aware, i.e. this path can be architecture qualified.

This is something we'd like to make use of in Debian/Ubuntu to make
libsystemd-shared co-installable, e.g. for i386 the path would be
/usr/lib/i386-linux-gnu/systemd/libsystemd-shared-*.so and for amd64
/usr/lib/x86_64-linux-gnu/systemd/libsystemd-shared-*.so.
This will allow for example to install and run systemd-boot/i386 on an
amd64 host. It also simplifies/enables cross-building/bootstrapping.

For more infos about Multi-Arch see https://wiki.debian.org/Multiarch.

See also https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=990547
2022-06-07 10:04:43 +02:00
Daan De Meyer
e30c1d01b6 shared: Rename pcre2-dlopen.h/c to pcre2-util.h/c
We already store the dlopen() stuff for other libraries in util headers
as well so let's do the same for pcre2. We also move the definition of
some trivial cleanup functions from journalctl.c to pcre2-util.h
2022-06-06 16:01:20 +02:00
Zbigniew Jędrzejewski-Szmek
af72f975fe Move basic/recovery-key.* to shared/
No particular reason to have it in basic/. We should let homectl
and other users share the single copy through libsystemd-shared.
2022-06-02 13:09:09 +09:00
Zbigniew Jędrzejewski-Szmek
3fb72d6388 Merge parse-socket-bind-item.? into parse-helpers.?
That file only exported one function, and it fits nicely within the scope of
"parse helpers". Let's move it there to reduce the file count a bit.

No functional change.
2022-04-07 18:25:55 +02:00
Zbigniew Jędrzejewski-Szmek
c3eaba2d3d Move path_simplify_and_warn() to new shared/parse-helpers.c
This is a high-level function, and it belongs in libsystemd-shared. This way we
don't end up linking a separate copy into various binaries. It would even end
up in libsystemd, where it is not needed. (Maybe it'd be removed in some
optimization phase, but it's better to not rely on that.)

$ grep -l -r -a 'path is not absolute%s' build/
build/libnss_systemd.so.2
build/pam_systemd_home.so
build/test-dlopen
build/src/basic/libbasic.a.p/path-util.c.o
build/src/basic/libbasic.a
build/src/shared/libsystemd-shared-249.so
build/test-bus-error
build/libnss_mymachines.so.2
build/pam_systemd.so
build/libnss_resolve.so.2
build/libnss_myhostname.so.2
build/libsystemd.so.0.32.0
build/libudev.so.1.7.2

$ grep -l -r -a 'path is not absolute%s' build/
build/src/shared/libsystemd-shared-251.a.p/parse-helpers.c.o
build/src/shared/libsystemd-shared-251.a
build/src/shared/libsystemd-shared-251.so

No functional change.
2022-04-07 18:25:55 +02:00
Lennart Poettering
7be4b23649 efi-loader: split efi-api.[ch] from efi-loader.[ch]
Some refactoring: split efi-loader.[ch] in two: isolate the calls that
implement out boot loader interface spec, and those which implement
access to upstream UEFI firmware features.

They are quite different in nature and behaviour, and even semantically
it makes to keep these two separate. At the very least because the
previous name "efi-loader.[ch]" suggests all was about loader-specific
APIs, but much of it is generic uefi stuff...

While we are at it, I renamed a bunch of return parameters to follow our
usual ret_xyz naming. But besides renaming no real code changes.
2022-03-24 15:21:09 +01:00
Lennart Poettering
b7df2c78ea meson: sort shared source file list again 2022-03-18 12:01:45 +01:00
Lennart Poettering
e94830c0a1 shared: split out ESP/XBOOTLDR search stuff from bootspec.c
The code is quite different from the rest of bootspec.c, with different
deps and stuff. There's even a /***/ line to separate the two parts.
Given how large the file already is, let#s just split it into two.

No code changes, just some splitting out.
2022-03-18 12:01:45 +01:00
Zbigniew Jędrzejewski-Szmek
2f492a739c meson: move files' closing brace to separate line 2022-03-03 12:14:13 +01:00
Zbigniew Jędrzejewski-Szmek
f1b98127ff meson: do not use split() in file lists
The approach to use '''…'''.split() instead of a list of strings was initially
used when converting from automake because it allowed identical blocks of lines
to be used for both, making the conversion easier.

But over the years we have been using normal lists more and more, especially
when there were just a few filenames listed. This converts the rest.

No functional change.
2022-03-02 14:49:32 +01:00
Daan De Meyer
ee48779e05 shared: Add more dlopen() tests
Add dlopen_dw(), dlopen_elf() and dlopen_pcre2() to the dlopen test.
To enable adding dlopen_pcre2(), we move pcre2-dlopen.h/c from
src/journal to src/shared.
2022-03-01 21:07:17 +00:00
Yu Watanabe
b4fd34d81c network: move SR-IOV related functions to src/shared/netif-sriov.[ch] 2022-01-19 14:57:59 +09:00
Zbigniew Jędrzejewski-Szmek
a2b0cd3f5a meson: allow specifying a custom "tag" for the private shared libaries
We have /usr/lib/systemd/libsystemd-{shared,core}-nnn.so. With this
path the 'nnn' part can be changed to something different. The idea
is that during a package build this will be set to the package version.

This way during in-place upgrades with the same major version both
the new and old libraries can cooexit. This should fix the issue
when systemd programs are called during package upgrades and fail
to exec because the expect different symbols in the library they
are linked to.

This should fix https://bugzilla.redhat.com/show_bug.cgi?id=1906010.
2021-12-25 15:18:50 +09:00
Zbigniew Jędrzejewski-Szmek
4287c85589 meson: create new libsystemd-core.so private shared library
The scheme is very similar to libsystemd-shared.so: instead of building a
static library, we build a shared library from the same objects and link the
two users to it. Both systemd and systemd-analyze consist mostly of the fairly
big code in libcore, so we save a bit on the installation:

(-0g, no strip)
-rwxr-xr-x 5238864 Dec 14 12:52 /var/tmp/inst1/usr/lib/systemd/systemd
-rwxr-xr-x 5399600 Dec 14 12:52 /var/tmp/inst1/usr/bin/systemd-analyze
-rwxr-xr-x  244912 Dec 14 13:17 /var/tmp/inst2/usr/lib/systemd/systemd
-rwxr-xr-x  461224 Dec 14 13:17 /var/tmp/inst2/usr/bin/systemd-analyze
-rwxr-xr-x 5271568 Dec 14 13:17 /var/tmp/inst2/usr/lib/systemd/libsystemd-core-250.so

(-0g, strip)
-rwxr-xr-x 2522080 Dec 14 13:19 /var/tmp/inst1/usr/lib/systemd/systemd
-rwxr-xr-x 2604160 Dec 14 13:19 /var/tmp/inst1/usr/bin/systemd-analyze
-rwxr-xr-x  113304 Dec 14 13:19 /var/tmp/inst2/usr/lib/systemd/systemd
-rwxr-xr-x  207656 Dec 14 13:19 /var/tmp/inst2/usr/bin/systemd-analyze
-rwxr-xr-x 2648520 Dec 14 13:19 /var/tmp/inst2/usr/lib/systemd/libsystemd-core-250.so

So for systemd itself we grow a bit (2522080 → 2648520+113304=2761824), but
overall we save. The most is saved on all the test files that link to libcore,
if they are installed, because there's 15 of them:

$ du -s /var/tmp/inst?
220096	/var/tmp/inst1
122960	/var/tmp/inst2

I also considered making systemd-analyze a symlink to /usr/lib/systemd/systemd
and turning systemd into a multicall binary. We did something like this with
udevd and udevadm. But that solution doesn't fit well in this case.
systemd-analyze has a bunch of functionality that is not used in systemd,
so the systemd binary would need to grow quite a bit. And we're likely to
add new types of verification or introspection features in analyze, and this
baggage would only grow. In addition, there are the test binaries which also
benefit from this.
2021-12-25 15:18:47 +09:00