]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
3 years agoudev: use child event source to manage workers 23002/head
Yu Watanabe [Wed, 6 Apr 2022 18:00:20 +0000 (03:00 +0900)] 
udev: use child event source to manage workers

3 years agoudev: use EventResult type
Yu Watanabe [Wed, 6 Apr 2022 17:58:43 +0000 (02:58 +0900)] 
udev: use EventResult type

This also adds EVENT_RESULT_SUCCESS for readability.

3 years agosd-event: make inotify event work after the process is forked
Yu Watanabe [Fri, 8 Apr 2022 23:50:44 +0000 (08:50 +0900)] 
sd-event: make inotify event work after the process is forked

3 years agosd-event: do not kill a child process from another child
Yu Watanabe [Fri, 8 Apr 2022 23:50:02 +0000 (08:50 +0900)] 
sd-event: do not kill a child process from another child

3 years agosd-event: do not update signal fd after PID is changed
Yu Watanabe [Fri, 8 Apr 2022 23:28:33 +0000 (08:28 +0900)] 
sd-event: do not update signal fd after PID is changed

Otherwise, child event source will not work after the process is forked
and the event source is unref()ed on the child process.

3 years agosd-event: set pid to event source after all setup processes finished
Yu Watanabe [Thu, 7 Apr 2022 06:21:56 +0000 (15:21 +0900)] 
sd-event: set pid to event source after all setup processes finished

Otherwise, the assertion in source_disconnect() may be triggered,

3 years agosd-event: rebreak comments
Yu Watanabe [Fri, 8 Apr 2022 23:23:50 +0000 (08:23 +0900)] 
sd-event: rebreak comments

3 years agoMerge pull request #23057 from keszybz/various-doc-tweaks
Yu Watanabe [Tue, 12 Apr 2022 14:09:51 +0000 (23:09 +0900)] 
Merge pull request #23057 from keszybz/various-doc-tweaks

Various doc tweaks

3 years agoman: add "internal" to "reference counter" 23057/head
Zbigniew Jędrzejewski-Szmek [Tue, 12 Apr 2022 13:33:05 +0000 (15:33 +0200)] 
man: add "internal" to "reference counter"

3 years agodocs/RELEASE: also mention syscall tables
Zbigniew Jędrzejewski-Szmek [Tue, 12 Apr 2022 10:33:33 +0000 (12:33 +0200)] 
docs/RELEASE: also mention syscall tables

3 years agoREADME: recommend zstd over xz
Zbigniew Jędrzejewski-Szmek [Tue, 12 Apr 2022 10:27:23 +0000 (12:27 +0200)] 
README: recommend zstd over xz

git archive automatically uses gzip when --output=*.tar.gz is used, but
not for other extensions. Thus we need to invoke the compressor separately :(

It's a good pattern to use a variable for the repeating number, so let's
recommend that.

3 years agodocs: stop recommending meson compile
Zbigniew Jędrzejewski-Szmek [Tue, 12 Apr 2022 10:05:53 +0000 (12:05 +0200)] 
docs: stop recommending meson compile

With meson-0.60, meson compile stopped working with some targets:

$ meson compile -C build update-man-rules
ERROR: Can't invoke target `update-man-rules`: ambiguous name. Add target type and/or path: `PATH/NAME:TYPE`

This is obviously a regression in meson, but based on a chat with the
maintainers, it seems that there's some disagreement as to whether 'meson
compile' is useful and how exactly it should work. Since we're already at
meson 0.60.3 and this hasn't been fixed, and people generally don't seem to
consider this an issue, let's return to documenting the usual practice of
'ninja -C build' that just works everywhere.

(Since nobody has raised any fuss in systemd, it means that people are
generally using the shorter form during development too. I only noticed
because I pasted a command from the release docs when preparing -rc1.)

3 years agoman: add page for sd_device_{ref,unref,unrefp}
Zbigniew Jędrzejewski-Szmek [Tue, 12 Apr 2022 09:51:52 +0000 (11:51 +0200)] 
man: add page for sd_device_{ref,unref,unrefp}

Gotta start somewhere.

3 years agoman: say libudev should not be used for new projects
Zbigniew Jędrzejewski-Szmek [Tue, 12 Apr 2022 09:30:28 +0000 (11:30 +0200)] 
man: say libudev should not be used for new projects

3 years agoman: add landing page for sd-device
Zbigniew Jędrzejewski-Szmek [Tue, 12 Apr 2022 09:28:17 +0000 (11:28 +0200)] 
man: add landing page for sd-device

We got documentation for sd-device for the first time with
b51f4eaf7b58f064092215cea9c6fc1c5af5646e, so let's celebrate by adding a
landing page that also explains the relationship with libudev.

3 years agoFix man page links
Zbigniew Jędrzejewski-Szmek [Tue, 12 Apr 2022 09:02:16 +0000 (11:02 +0200)] 
Fix man page links

Based on linkchecker as usual.

3 years agoudev-builtin-input_id: use heuristics to detect joysticks
Peter Hutterer [Fri, 8 Apr 2022 06:21:47 +0000 (16:21 +1000)] 
udev-builtin-input_id: use heuristics to detect joysticks

Several keyboard devices are erroneously tagged with ID_INPUT_JOYSTICK
because of random buttons they set. For example, the LiteOn Lenovo
Calliope USB Keyboard sets BTN_TRIGGER, BTN_TOP2, BTN_PINKIE and
BTN_BASE, see libinput issue 745 for details.

ID_INPUT_JOYSTICK triggers the uaccess rules, making those keyboards
easily accessible. That's not a problem in the LiteOn example since that
event node doesn't contain the normal keys and eavesdropping on volume
keys is probably not very interesting.

Improve the joystick detection by adding heuristics similar to what
libinput 1.20 uses: check for some specific set of keys that are common
on keyboards but very unlikely on joysticks. If enough of those are
present (or the device has less than 2 axes or joysticks), don't tag it
as joystick.

libinput also checks for > 10 keyboard keys, but this is not done here
to be more conservative.

3 years agoMerge pull request #23051 from poettering/udev-tweaklets-2
Yu Watanabe [Tue, 12 Apr 2022 05:06:53 +0000 (14:06 +0900)] 
Merge pull request #23051 from poettering/udev-tweaklets-2

udev: three minor tweaks

3 years agoMerge pull request #23048 from keszybz/Add-more-tests-for-specifiers
Yu Watanabe [Tue, 12 Apr 2022 05:04:48 +0000 (14:04 +0900)] 
Merge pull request #23048 from keszybz/Add-more-tests-for-specifiers

Add more tests for specifiers

3 years agotree-wide: host_name → hostname 23048/head
Zbigniew Jędrzejewski-Szmek [Mon, 11 Apr 2022 11:50:08 +0000 (13:50 +0200)] 
tree-wide: host_name → hostname

We use "hostname" exclusively in docs, and also in a big majority of the
code. Let's use the same spelling in remaining places.

3 years agotest-unit-name: add missing tests for specifiers, fix existing tests
Zbigniew Jędrzejewski-Szmek [Mon, 11 Apr 2022 09:13:31 +0000 (11:13 +0200)] 
test-unit-name: add missing tests for specifiers, fix existing tests

It turns out that in fa3cd7394c227ad38c5c09b2bc2d035e7fb14a76 back
in 2013 I got the test reversed: assert_se(strncmp()) should be
assert_se(strncmp==0). So the tests that were using "*" were not entirely
useful ;) The function was refactored a bunch of times since then, and it
seems nobody noticed.

So let's replace this fragile construct by a simple fnmatch, which also
has the advantage that the glob can be inserted in arbitrary places.

Following up for d0aba07f1ac8d6df2ccfa033fe1e195b1b9e5272: we should have at
least basic tests for all interfaces, even the deprecated ones, so that we
catch obvious errors. This sorts the specifiers the same way that they are
declared in the unit-printf.c, and adds tests for all the specifiers. We
even were setting 'shell', but not using it in a test.

Also, we shouldn't initialize variables in tests. This catches the error fixed
in previous commit.

3 years agocore: update to use new-style sd-bus macros
amarjargal [Mon, 11 Apr 2022 13:29:22 +0000 (21:29 +0800)] 
core: update to use new-style sd-bus macros

Replace old SD_BUS_METHOD_WITH_NAMES and SD_BUS_SIGNAL_WITH_NAMES macros
to the new SD_BUS_METHOD_WITH_ARGS and SD_BUS_SIGNAL_WITH_ARGS macros.

3 years agosd-device: validate devnum parameters in device_set_devnum() 23051/head
Lennart Poettering [Tue, 5 Apr 2022 08:19:20 +0000 (10:19 +0200)] 
sd-device: validate devnum parameters in device_set_devnum()

3 years agosd-device: make device_set_syspath() more defensive
Lennart Poettering [Tue, 5 Apr 2022 08:18:17 +0000 (10:18 +0200)] 
sd-device: make device_set_syspath() more defensive

Simplify generated sysfs paths, since we might get data passed that
includes extra // in the middle.

Also, let's not assume /sys/ prefix without verification.

3 years agosd-device: simplify device_enumerator_scan_devices_and_subsystems() a bit
Lennart Poettering [Tue, 5 Apr 2022 08:17:22 +0000 (10:17 +0200)] 
sd-device: simplify device_enumerator_scan_devices_and_subsystems() a bit

We can use enumerator_scan_devices_all() to shorten the code, and drop
some of the error handling complexities.

3 years agotimedate: update to use new-style sd-bus macros
Sonali Srivastava [Mon, 11 Apr 2022 11:41:29 +0000 (17:11 +0530)] 
timedate: update to use new-style sd-bus macros

3 years agoMerge pull request #22992 from poettering/loop-dissect-tweaks
Yu Watanabe [Mon, 11 Apr 2022 14:08:46 +0000 (23:08 +0900)] 
Merge pull request #22992 from poettering/loop-dissect-tweaks

loop-util/image dissect fixes

3 years agoMerge pull request #23037 from yuwata/sd-device-validate
Yu Watanabe [Mon, 11 Apr 2022 14:04:28 +0000 (23:04 +0900)] 
Merge pull request #23037 from yuwata/sd-device-validate

sd-device: validate input parameter after creating sd-device object

3 years agoMerge pull request #23038 from yuwata/udev-log-once
Zbigniew Jędrzejewski-Szmek [Mon, 11 Apr 2022 12:36:18 +0000 (14:36 +0200)] 
Merge pull request #23038 from yuwata/udev-log-once

udev: log once

3 years agoshared/specifier: make sure we set the output variable even for void answers
Zbigniew Jędrzejewski-Szmek [Mon, 11 Apr 2022 11:44:41 +0000 (13:44 +0200)] 
shared/specifier: make sure we set the output variable even for void answers

This doesn't change anything for real uses, because we'd initialize the
variable to NULL for _cleanup_ anyway, but let's follow our general pattern
of always setting the output on "success". (Even if that success is an empty
answer here.)

3 years agoAdd comments about deprecated specifiers
Zbigniew Jędrzejewski-Szmek [Fri, 8 Apr 2022 18:28:26 +0000 (20:28 +0200)] 
Add comments about deprecated specifiers

Inspired by 9fe20c3234. When the specifier is undocumented, it is really easy
to add a duplicate definition in  a different place.

3 years agoudev: inline loop variable 23038/head
Yu Watanabe [Sun, 10 Apr 2022 15:02:17 +0000 (00:02 +0900)] 
udev: inline loop variable

3 years agoudev: suppress multiple log message about interface naming scheme from workers
Yu Watanabe [Sun, 10 Apr 2022 14:55:06 +0000 (23:55 +0900)] 
udev: suppress multiple log message about interface naming scheme from workers

3 years agoudev/net: cache parsed result of net.ifnames=
Yu Watanabe [Sun, 10 Apr 2022 14:41:34 +0000 (23:41 +0900)] 
udev/net: cache parsed result of net.ifnames=

To make the log message shown only once.

3 years agosd-device: shorten code a bit 23037/head
Yu Watanabe [Sun, 10 Apr 2022 13:36:16 +0000 (22:36 +0900)] 
sd-device: shorten code a bit

3 years agosd-device: minor may be NULL
Yu Watanabe [Sun, 10 Apr 2022 13:36:33 +0000 (22:36 +0900)] 
sd-device: minor may be NULL

3 years agosd-device: validate input parameter after creating sd-device object
Yu Watanabe [Sun, 10 Apr 2022 13:23:34 +0000 (22:23 +0900)] 
sd-device: validate input parameter after creating sd-device object

3 years agonamespace-util: Fix typo
Daan De Meyer [Mon, 11 Apr 2022 09:40:24 +0000 (11:40 +0200)] 
namespace-util: Fix typo

3 years agotimesync: update to use new-style sd-bus macros
Sonali Srivastava [Mon, 11 Apr 2022 03:31:06 +0000 (09:01 +0530)] 
timesync: update to use new-style sd-bus macros

3 years agofix typo
Yu Watanabe [Sun, 10 Apr 2022 17:29:49 +0000 (02:29 +0900)] 
fix typo

3 years agofix typo
Yu Watanabe [Sun, 10 Apr 2022 15:13:16 +0000 (00:13 +0900)] 
fix typo

3 years agorepart: use sd_device_open() 22992/head
Yu Watanabe [Sat, 9 Apr 2022 00:53:01 +0000 (09:53 +0900)] 
repart: use sd_device_open()

Then, we can safely open devices even if symlinks are not yet created by udevd.

3 years agotree-wide: take BSD lock on loopback devices we dissect/mount/operate on
Lennart Poettering [Thu, 7 Apr 2022 14:09:45 +0000 (16:09 +0200)] 
tree-wide: take BSD lock on loopback devices we dissect/mount/operate on

So here's something we should always keep in mind:

systemd-udevd actually does *two* things with BSD file locks on block
devices:

1. While it probes a device it takes a LOCK_SH lock. Thus everyone else
   taking a LOCK_EX lock will temporarily block udev from probing
   devices, which is good when making changes to it.

2. Whenever a device is closed after write (detected via inotify), udevd
   will issue BLKRRPART (requesting the kernel to reread the partition
   table). It does this while holding a LOCK_EX lock on the block
   device. Thus anyone else taking LOCK_SH or LOCK_EX will temporarily
   block udevd from issuing that ioctl. And that's quite relevant, since
   the kernel will temporarily flush out all partitions while re-reading
   the partition table and then create them anew. Thus it is smart to
   take LOCK_SH when dissecting a block device to ensure that no
   BLKRRPART is issued in the background, until we mounted the devices.

3 years agotest-loop-block: reenable test on CI
Lennart Poettering [Wed, 6 Apr 2022 09:57:13 +0000 (11:57 +0200)] 
test-loop-block: reenable test on CI

3 years agoupdate TODO
Lennart Poettering [Wed, 6 Apr 2022 10:44:36 +0000 (12:44 +0200)] 
update TODO

3 years agodissect: rework how we wait for partition block devices
Lennart Poettering [Wed, 6 Apr 2022 09:50:01 +0000 (11:50 +0200)] 
dissect: rework how we wait for partition block devices

This revisits the mess around waiting for partition block devices in
the image dissection code. It implements a nice little trick:

Instead of waiting for the kernel to probe the partition table for us
and generate the block devices from it, we'll just do that ourselves.
How can we do it? Via the BLKPG_ADD_PARTITION ioctl, that the kernel has
supported for a while. This ioctl allows creating partition block
devices off "whole" block devices from userspace, without the partitions
necessarily being present in the partition table at all.

So, whenever we want a partition to be there, we'll just issue
BLKPG_ADD_PARTITION. This can either work, in which case we know the
partition is there, and can use it. Yay. Or it can fail with EBUSY,
which the kernel returns if a partition by the selected partition index
already exists (or if an existing partition overlaps with the new one).
But if that's the case, then that's also OK, because the partition will
already exist.

So, regardless if we win or the kernel wins, for us the outcome is the
same: the partition block device will exist after invoking the ioctl.
Yay.

Net effect: we are not dependent on asynchronous uevent messages to wait
for the devices. Instead we synchronously get what we need. This makes
us independent of the (apparently less than reliable) netlink transport,
and should almost always be quicker.

Hopefully addresses #17469 even on older kernels.

Fixes: #17469
3 years agoEnsure dns_search_domain_unlink_marked removes all marked domains
Ben Efros [Fri, 8 Apr 2022 22:31:09 +0000 (15:31 -0700)] 
Ensure dns_search_domain_unlink_marked removes all marked domains

3 years agotest: always invoke systemd-repart with --no-pager
Yu Watanabe [Fri, 8 Apr 2022 21:50:41 +0000 (06:50 +0900)] 
test: always invoke systemd-repart with --no-pager

Follow-up for 31cf58864d3f437c7e3f0497df0fef85130f159d.

3 years agoudev: add parens for function names in the logs
Yu Watanabe [Fri, 8 Apr 2022 06:47:53 +0000 (15:47 +0900)] 
udev: add parens for function names in the logs

3 years agoMerge pull request #22614 from zonque/timesync/runtime
Yu Watanabe [Sat, 9 Apr 2022 04:27:05 +0000 (13:27 +0900)] 
Merge pull request #22614 from zonque/timesync/runtime

timesyncd: add runtime servers

3 years agonetworkd-test: lazy umount tmp directories
Luca Boccassi [Fri, 8 Apr 2022 22:52:38 +0000 (23:52 +0100)] 
networkd-test: lazy umount tmp directories

In Semaphore CI, for some reason, /run/systemd/resolve is busy so the umount
fails at the end of the test run:

Verify link states with Unmanaged= settings, cold-plug. ... umount: /run/systemd/resolve: target is busy.14:57
ok14:57
ERROR14:57
======================================================================14:57
ERROR: tearDownModule (__main__)14:57
----------------------------------------------------------------------14:57
Traceback (most recent call last):14:57
  File /tmp/autopkgtest-lxc.6islza9t/downtmp/build.A9b/src/test/networkd-test.py, line 94, in tearDownModule14:57
    subprocess.check_call([umount, d])14:57
  File /usr/lib/python3.9/subprocess.py, line 373, in check_call14:57
    raise CalledProcessError(retcode, cmd)14:57
subprocess.CalledProcessError: Command '['umount', '/run/systemd/resolve']' returned non-zero exit status 32.14:57
----------------------------------------------------------------------14:58
Ran 35 tests in 138.868s14:58
FAILED (errors=1, skipped=2)

Use lazy umount to avoid erroring out.

3 years agotimesync: be explicit in the integer check of poll_interval_usec 22614/head
Daniel Mack [Thu, 31 Mar 2022 10:33:38 +0000 (12:33 +0200)] 
timesync: be explicit in the integer check of poll_interval_usec

3 years agotimesyncd: clean up server_name_new()
Daniel Mack [Tue, 22 Mar 2022 17:26:55 +0000 (18:26 +0100)] 
timesyncd: clean up server_name_new()

Use `LIST_APPEND()` in favour of `LIST_FIND_TAIL()` + `LIST_INSERT_AFTER()`.
Also use a switch/case statement instead of if/else if.

3 years agotimesyncd: add address type information to debug log
Daniel Mack [Thu, 24 Feb 2022 16:47:49 +0000 (17:47 +0100)] 
timesyncd: add address type information to debug log

When looking at debug logs, it's helpful to know what type of server
address has been added.

For that, introduce a string lookup table for the ServerType type.

3 years agotimesyncd: add RUNTIME servers
Daniel Mack [Thu, 24 Feb 2022 14:47:35 +0000 (15:47 +0100)] 
timesyncd: add RUNTIME servers

This new server type can only be set at runtime through a D-Bus method
and is exposed for reading through a D-Bus property.

`CAP_NET_ADMIN` and a PolKit acknowledge is required for setting
runtime servers.

Entries submitted that way are used before system and link servers
are being looked at.

3 years agotimesync: export manager_is_connected()
Daniel Mack [Thu, 24 Feb 2022 14:44:48 +0000 (15:44 +0100)] 
timesync: export manager_is_connected()

This function use useful from other files, so let's export it.

3 years agomachine: update to use new-style sd-bus macros (#23012)
Amarjargal [Fri, 8 Apr 2022 20:43:18 +0000 (04:43 +0800)] 
machine: update to use new-style sd-bus macros (#23012)

* machine: update to use new-style sd-bus macros

Replace old SD_BUS_METHOD_WITH_NAMES and SD_BUS_SIGNAL_WITH_NAMES macros to
the new SD_BUS_METHOD_WITH_ARGS and SD_BUS_SIGNAL_WITH_ARGS macros.

Meson test, mkosi test image and running machinectl after build returned
no error. But since I don't have any virtual machines or containers, I'm not
sure how to test the changes thoroughly.

3 years agoupdate TODO
Lennart Poettering [Fri, 8 Apr 2022 20:23:11 +0000 (22:23 +0200)] 
update TODO

3 years agospecifier: use %q for pretty hostname
Lennart Poettering [Fri, 8 Apr 2022 16:09:18 +0000 (18:09 +0200)] 
specifier: use %q for pretty hostname

%R is already used in service manager specifier expansion (cgroup root),
hence use a different char, that was so far not used.

Follow-up for: 6ceb0a4094908dd213a78b9f6d0c59a684831ab0

3 years agosystemd-creds: fix name of env var
Lennart Poettering [Fri, 8 Apr 2022 16:45:47 +0000 (18:45 +0200)] 
systemd-creds: fix name of env var

The env var is called $CREDENTIALS_DIRECTORY, not $CREDENTIALS_PATH. Fix
message about it accordingly.

3 years agoupdate TODO
Lennart Poettering [Fri, 8 Apr 2022 16:59:47 +0000 (18:59 +0200)] 
update TODO

3 years agoupdate TODO
Lennart Poettering [Fri, 8 Apr 2022 16:41:40 +0000 (18:41 +0200)] 
update TODO

3 years agoupdate TODO
Lennart Poettering [Fri, 8 Apr 2022 15:43:48 +0000 (17:43 +0200)] 
update TODO

3 years agomeson: explicitly include coverage tweaks when built w/ --coverage
Frantisek Sumsal [Fri, 8 Apr 2022 11:20:15 +0000 (13:20 +0200)] 
meson: explicitly include coverage tweaks when built w/ --coverage

To make sure we don't miss any _exit() calls let's move the
coverage-related tweaks into a separate header file and include it
explicitly on the compiler command line using -include when a coverage
build is requested.

Follow-up to c6552ad381003a23cde7c3228e7071f30465df35.

3 years agoMerge pull request #23009 from keszybz/fix-detection-of-libsystemd-shared-with-suffix
Lennart Poettering [Fri, 8 Apr 2022 13:43:09 +0000 (15:43 +0200)] 
Merge pull request #23009 from keszybz/fix-detection-of-libsystemd-shared-with-suffix

Fix detection of libsystemd-shared with suffix

3 years agonetwork: ignore errors when CONFIG_NET_SCHED is disabled
Yu Watanabe [Fri, 8 Apr 2022 06:33:42 +0000 (15:33 +0900)] 
network: ignore errors when CONFIG_NET_SCHED is disabled

Follow-ups for 828a81a93783248be15683c9639b85098f331328.

Fixes #23014.

3 years agoMerge pull request #22803 from medhefgo/boot-cflags
Luca Boccassi [Thu, 7 Apr 2022 23:00:54 +0000 (00:00 +0100)] 
Merge pull request #22803 from medhefgo/boot-cflags

meson: Add support for building efi binaries on multilib

3 years agoMerge pull request #23008 from poettering/loop-dissect-tweaks-safe
Luca Boccassi [Thu, 7 Apr 2022 20:42:47 +0000 (21:42 +0100)] 
Merge pull request #23008 from poettering/loop-dissect-tweaks-safe

loop-util tweaks

3 years agodissect: improve debug logging in probe_filesystem() 23008/head
Lennart Poettering [Thu, 7 Apr 2022 12:11:44 +0000 (14:11 +0200)] 
dissect: improve debug logging in probe_filesystem()

3 years agotest-loop-block: conditionalize things on HAVE_BLKID correctly
Lennart Poettering [Wed, 6 Apr 2022 09:57:13 +0000 (11:57 +0200)] 
test-loop-block: conditionalize things on HAVE_BLKID correctly

3 years agotest: allow specifying test threads/iterations/timeouts via cmdline
Lennart Poettering [Wed, 6 Apr 2022 09:49:08 +0000 (11:49 +0200)] 
test: allow specifying test threads/iterations/timeouts via cmdline

That's useful when running tests manually.

3 years agoloop-util: add debug message with details about acquired loopback device
Lennart Poettering [Tue, 5 Apr 2022 21:36:33 +0000 (23:36 +0200)] 
loop-util: add debug message with details about acquired loopback device

3 years agoloop-util: explicitly close loopback block device before sleeping
Lennart Poettering [Tue, 5 Apr 2022 21:34:44 +0000 (23:34 +0200)] 
loop-util: explicitly close loopback block device before sleeping

attach_empty() file takes a BSD file lock on the device, and we really
should release that before going to sleep. hence explicitly close the
block device before the sleep instead of relying on _cleanup_ to close
it after the sleep.

3 years agoloop-util: use ERRNO_IS_DEVICE_ABSENT() macro where appropriate
Lennart Poettering [Tue, 5 Apr 2022 21:34:16 +0000 (23:34 +0200)] 
loop-util: use ERRNO_IS_DEVICE_ABSENT() macro where appropriate

3 years agoloop-util: take a LOCK_EX BSD file lock on control device while we acquire a loopback...
Lennart Poettering [Tue, 5 Apr 2022 16:56:47 +0000 (18:56 +0200)] 
loop-util: take a LOCK_EX BSD file lock on control device while we acquire a loopback device

3 years agotest-loop-block: don't spawn threads in case N_THREADS is 1
Lennart Poettering [Tue, 5 Apr 2022 16:09:10 +0000 (18:09 +0200)] 
test-loop-block: don't spawn threads in case N_THREADS is 1

Let's simplify things if we are only supposed to create a single thread.
Makes it easier to debug things with gdb.

3 years agoloop-util: slightly rework device_has_block_children()
Lennart Poettering [Tue, 5 Apr 2022 15:00:38 +0000 (17:00 +0200)] 
loop-util: slightly rework device_has_block_children()

Let's match by devtype, i.e. the official way to distinguish "whole"
block devices from partitions.

Also add debug logging for devices we thus ignore.

3 years agoloop-util: let's cut trailing whitespace, not trailing lines
Lennart Poettering [Tue, 5 Apr 2022 14:58:32 +0000 (16:58 +0200)] 
loop-util: let's cut trailing whitespace, not trailing lines

This doesn't really make any real difference, given the file should only
contain a single line. But it's conceptually more correct to just remove
the trailing newline/whitespace then the whole lines coming after that.
i.e. if the file actually contains more lines than one, this should
probably be considered an error.

3 years agoci: Add ia32 EFI multilib test 22803/head
Jan Janssen [Wed, 23 Mar 2022 13:40:06 +0000 (14:40 +0100)] 
ci: Add ia32 EFI multilib test

This makes sure that building ia32 EFI binaries on x86_64 works.
We force gnu-efi support to ensure it's not skipped by accident
and provide the lib32 dir manually, because clang does not support
'--print-multi-os-directory', which is used to auto-detect it.

3 years agoboot: Restrict block IO buf size
Jan Janssen [Thu, 24 Mar 2022 09:35:30 +0000 (10:35 +0100)] 
boot: Restrict block IO buf size

3 years agomeson: Add support for building efi binaries on multilib
Jan Janssen [Wed, 2 Feb 2022 10:24:41 +0000 (11:24 +0100)] 
meson: Add support for building efi binaries on multilib

This allows building 32bit versions of efi binaries on x86_64 machines
and vice-versa by passing "-Defi-cflags=-m32" to meson, provided the
32bit gnu-efi and gcc-multilib are available.

It is expected that distros that want to provide both ia32 and x64
versions to use a second build dir to build the non-native version
by adding -m32 to efi-cflags and then running the sd-boot/sd-stub
ninja target directly.

3 years agomeson: Add efi-cflags option
Jan Janssen [Fri, 28 Jan 2022 10:33:23 +0000 (11:33 +0100)] 
meson: Add efi-cflags option

3 years agocore: fix dm-verity auto-discovery in MountImageUnit()
Luca Boccassi [Wed, 6 Apr 2022 16:25:35 +0000 (17:25 +0100)] 
core: fix dm-verity auto-discovery in MountImageUnit()

The implementation of MountImageUnit()/systemctl mount-image was
changed to use a /proc/self/fd path as the source, but that causes
the dm-verity files autodiscovery to fail, as it looks for files
in the same directory as the image.

Use the original file path when setting up dm-verity.

3 years agosyscalls: update syscall definitions 23009/head
Zbigniew Jędrzejewski-Szmek [Thu, 7 Apr 2022 12:53:11 +0000 (14:53 +0200)] 
syscalls: update syscall definitions

3 years agovarious: add missing "#pragma once"
Zbigniew Jędrzejewski-Szmek [Thu, 7 Apr 2022 12:51:55 +0000 (14:51 +0200)] 
various: add missing "#pragma once"

3 years agoMerge parse-socket-bind-item.? into parse-helpers.?
Zbigniew Jędrzejewski-Szmek [Thu, 7 Apr 2022 12:03:26 +0000 (14:03 +0200)] 
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.

3 years agoMove path_simplify_and_warn() to new shared/parse-helpers.c
Zbigniew Jędrzejewski-Szmek [Thu, 7 Apr 2022 11:43:18 +0000 (13:43 +0200)] 
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.

3 years agotest-nspawn-util: fix the test to actually find anything
Zbigniew Jędrzejewski-Szmek [Thu, 7 Apr 2022 10:33:25 +0000 (12:33 +0200)] 
test-nspawn-util: fix the test to actually find anything

We would use a relative path, looking for globs like
'lib/systemd/libsystemd-shared-*.so' under the build directory, and never find
anything.

The test was supposed to find library in the current installation. But we
cannot assume that the right library is installed, so the test only printed the
result for manual inspection. Thus nobody noticed when it broke. I think it
broke in c6134d3e2f1d1d17b32b6e06556cd0c5429bc78a, path-util: get rid of prefix_root().
But that commit doesn't compile because of changes in meson, so this is just
a guess.

Before:
/* test_systemd_installation_has_version */
Current installation has systemd >= 0: no
Current installation has systemd >= 231: no
Current installation has systemd >= 249: no
Current installation has systemd >= 999: no

With the fix:
$ build/test-nspawn-util
/* test_systemd_installation_has_version */
Found libsystemd shared at "/lib/systemd/libsystemd-shared-245.so.so", version 245 (OK).
Current installation has systemd >= 0: yes
Found libsystemd shared at "/lib/systemd/libsystemd-shared-245.so.so", version 245 (OK).
Current installation has systemd >= 231: yes
Found libsystemd shared at "/lib/systemd/libsystemd-shared-245.so.so", version 245 (too old).
Found libsystemd shared at "/lib/systemd/libsystemd-shared-251.so.so", version 251 (OK).
Current installation has systemd >= 251: yes
Found libsystemd shared at "/lib/systemd/libsystemd-shared-245.so.so", version 245 (too old).
Found libsystemd shared at "/lib/systemd/libsystemd-shared-251.so.so", version 251 (too old).
Found libsystemd shared at "/lib/systemd/libsystemd-shared-250.so.so", version 250 (too old).
Found libsystemd shared at "/usr/lib/systemd/libsystemd-shared-245.so.so", version 245 (too old).
Found libsystemd shared at "/usr/lib/systemd/libsystemd-shared-251.so.so", version 251 (too old).
Found libsystemd shared at "/usr/lib/systemd/libsystemd-shared-250.so.so", version 250 (too old).
Current installation has systemd >= 999: no

$ build/test-nspawn-util /var/lib/machines/rawhide
/* test_systemd_installation_has_version */
/* test_systemd_installation_has_version */
Found libsystemd shared at "/var/lib/machines/rawhide/lib/systemd/libsystemd-shared-251-rc1-1.fc37.so.so", version 251 (OK).
/var/lib/machines/rawhide has systemd >= 0: yes
Found libsystemd shared at "/var/lib/machines/rawhide/lib/systemd/libsystemd-shared-251-rc1-1.fc37.so.so", version 251 (OK).
/var/lib/machines/rawhide has systemd >= 231: yes
Found libsystemd shared at "/var/lib/machines/rawhide/lib/systemd/libsystemd-shared-251-rc1-1.fc37.so.so", version 251 (OK).
/var/lib/machines/rawhide has systemd >= 251: yes
Found libsystemd shared at "/var/lib/machines/rawhide/lib/systemd/libsystemd-shared-251-rc1-1.fc37.so.so", version 251 (too old).
Found libsystemd shared at "/var/lib/machines/rawhide/usr/lib/systemd/libsystemd-shared-251-rc1-1.fc37.so.so", version 251 (too old).
/var/lib/machines/rawhide has systemd >= 999: no

While at it, NULSTR_FOREACH → FOREACH_STRING.

3 years agonspawn: fix comparisons of versions with non-numerical suffixes
Zbigniew Jędrzejewski-Szmek [Thu, 7 Apr 2022 10:15:04 +0000 (12:15 +0200)] 
nspawn: fix comparisons of versions with non-numerical suffixes

See a2b0cd3f5ab3f450e74e2085ad20372a05451c74. When -Dshared-lib-tag is used,
libsystemd-shared.so and libsystemd-core.so get a suffix which breaks the
parsing done by systemd_installation_has_version(). We can assume that the
tag will be something like "251-rc1-1.fc37" that is currently used in Fedora.
(Anything that does *not* start with the version would be completely crazy.)
By switching to strverscmp_improved() we simplify the code and fix comparisons
with such versions.

$ build/test-nspawn-util /var/lib/machines/rawhide
...
Found libsystemd shared at "/var/lib/machines/rawhide/lib/systemd/libsystemd-shared-251-rc1-1.fc37.so.so", version 251-rc1-1.fc37 (OK).
/var/lib/machines/rawhide has systemd >= 251: yes
...

I noticed this when I started a systemd-nspawn container with Redora rawhide
and got the message "Not running with unified cgroup hierarchy, LSM BPF is not
supported". I thought the message is in error, but it was actually correct:
nspawn was misdetecting that the container does not sport new-enough systemd
to support cgroups-v2.

3 years agoMove systemd_installation_has_version() to src/nspawn/
Zbigniew Jędrzejewski-Szmek [Thu, 7 Apr 2022 09:51:52 +0000 (11:51 +0200)] 
Move systemd_installation_has_version() to src/nspawn/

This function implements a heuristic that is only used by nspawn. It doesn't
belong in basic. I opted for a new file "nspawn-utils.c", because it seems
likely that we'll need some other new utilities like that in the future.

No functional change.

3 years agocalendarspec: fix possibly skips next elapse
Gibeom Gwon [Sun, 6 Mar 2022 00:45:38 +0000 (09:45 +0900)] 
calendarspec: fix possibly skips next elapse

If the time unit changes after adding the repetition value, the
timer may skip the next elapse. This patch reset sub time units
to minimum value when upper unit is changed.

Fixes #22665.

3 years agoMerge pull request #21795 from Werkov/bfq-io-weight-2
Zbigniew Jędrzejewski-Szmek [Thu, 7 Apr 2022 15:23:16 +0000 (17:23 +0200)] 
Merge pull request #21795 from Werkov/bfq-io-weight-2

IODeviceWeight= configures bfq.io.weight  too

3 years agoMerge pull request #23000 from mrc0mmand/coverage__exit
Frantisek Sumsal [Thu, 7 Apr 2022 13:08:55 +0000 (13:08 +0000)] 
Merge pull request #23000 from mrc0mmand/coverage__exit

macro: call __gcov_dump() before _exit() w/ coverage enabled

3 years agotest: ignore missing coverage in TEST-02 23000/head
Frantisek Sumsal [Thu, 7 Apr 2022 10:45:13 +0000 (12:45 +0200)] 
test: ignore missing coverage in TEST-02

Since c6552ad we now try to collect coverage even in situations where
it's basically impossible (like in test-mount-util where the whole / is
mounted as read-only). As dealing with this is not worth the trouble,
let's ignore the missing coverage errors thrown by gcov in such cases.

3 years agoREADME: add one more kernel-version line
Zbigniew Jędrzejewski-Szmek [Thu, 7 Apr 2022 09:23:32 +0000 (11:23 +0200)] 
README: add one more kernel-version line

I want to add as many as possible to show people that each kernel version
has something nice to entice them to keep moving up ;)

3 years agocore: inline an iterator variable
Zbigniew Jędrzejewski-Szmek [Thu, 7 Apr 2022 09:22:08 +0000 (11:22 +0200)] 
core: inline an iterator variable

3 years agomacro: call __gcov_dump() before _exit() w/ coverage enabled
Frantisek Sumsal [Wed, 6 Apr 2022 17:41:01 +0000 (19:41 +0200)] 
macro: call __gcov_dump() before _exit() w/ coverage enabled

_exit() skips at-exit hooks, causing lost coverage from processes
utilizing it.

Hopefully resolves systemd/systemd-centos-ci#482

3 years agosd-ipv4acd: actually drop the arp packet from one of the host interface
Yu Watanabe [Wed, 6 Apr 2022 18:38:56 +0000 (03:38 +0900)] 
sd-ipv4acd: actually drop the arp packet from one of the host interface

Fixes a bug in 7f77917c0effe92d5fed52503bceddabcb4667ba.

Fixes #23001.

3 years agosemaphoreci: re-enable rebooting tests
Luca Boccassi [Thu, 7 Apr 2022 00:18:53 +0000 (01:18 +0100)] 
semaphoreci: re-enable rebooting tests

Fixed by https://salsa.debian.org/systemd-team/systemd/-/commit/5738b62f5544d040550a018dcd02701bac4feec8

Fixes https://github.com/systemd/systemd/issues/22991

3 years agoMerge pull request #22965 from enr0n/oomd-used-memory-calc
Anita Zhang [Wed, 6 Apr 2022 23:42:46 +0000 (16:42 -0700)] 
Merge pull request #22965 from enr0n/oomd-used-memory-calc

oomd: calculate 'used' memory with MemAvailable instead of MemFree