]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
2 years agoMerge pull request #22759 from msekletar/issue-18077-long-sysfs-paths-hashing
Lennart Poettering [Wed, 13 Apr 2022 20:21:38 +0000 (22:21 +0200)] 
Merge pull request #22759 from msekletar/issue-18077-long-sysfs-paths-hashing

Create "hashed" unit names from long paths

2 years agoMerge pull request #23070 from poettering/devnum-split
Yu Watanabe [Wed, 13 Apr 2022 18:45:39 +0000 (03:45 +0900)] 
Merge pull request #23070 from poettering/devnum-split

basic: some devnum handling tweaks and refactorings

2 years agoMerge pull request #22969 from poettering/udevadm-tree
Yu Watanabe [Wed, 13 Apr 2022 18:45:14 +0000 (03:45 +0900)] 
Merge pull request #22969 from poettering/udevadm-tree

udevadm: add new "udevadm info --tree" command

2 years agotests: reflect that we can now handle devices with very long sysfs paths 22759/head
Michal Sekletar [Thu, 24 Mar 2022 18:24:16 +0000 (19:24 +0100)] 
tests: reflect that we can now handle devices with very long sysfs paths

2 years agodevnum-util: catch potential stack overruns early 23070/head
Lennart Poettering [Wed, 13 Apr 2022 14:25:32 +0000 (16:25 +0200)] 
devnum-util: catch potential stack overruns early

2 years agodevnum-util: define helper macros for formatting devnum major/minor pairs
Lennart Poettering [Wed, 13 Apr 2022 14:13:10 +0000 (16:13 +0200)] 
devnum-util: define helper macros for formatting devnum major/minor pairs

And port some parts over.

2 years agobasic: split out dev_t related calls into new devno-util.[ch]
Lennart Poettering [Wed, 13 Apr 2022 13:38:21 +0000 (15:38 +0200)] 
basic: split out dev_t related calls into new devno-util.[ch]

No actual code changes, just splitting out of some dev_t handling
related calls from stat-util.[ch], they are quite a number already, and
deserve their own module now I think.

Also, try to settle on the name "devnum" as the name for the concept,
instead of "devno" or "dev" or "devid". "devnum" is the name exported in
udev APIs, hence probably best to stick to that. (this just renames a
few symbols to "devum", local variables are left untouched, to make the
patch not too invasive)

No actual code changes.

2 years agoupdate TODO 22969/head
Lennart Poettering [Tue, 5 Apr 2022 08:21:14 +0000 (10:21 +0200)] 
update TODO

2 years agoudevadm: use xopendirat() where appropriate
Lennart Poettering [Tue, 12 Apr 2022 16:30:49 +0000 (18:30 +0200)] 
udevadm: use xopendirat() where appropriate

And while we are at it, let's use more appropriate open flags.

O_NONBLOCk is pointless in combination with O_NOFOLLOW.

O_NOFOLLOW makes a ton of sense otoh, since the inode is supposed to be
a dir, we just checked.

THe other flags are implied by xopendirat()

2 years agoudevadm: add new --tree mode to "udevadm info"
Lennart Poettering [Tue, 5 Apr 2022 08:20:18 +0000 (10:20 +0200)] 
udevadm: add new --tree mode to "udevadm info"

sysfs is a tree, hence let's a mode that allows showing it as such.

2 years agosd-device: include parent devices in enumeration
Lennart Poettering [Mon, 11 Apr 2022 21:13:40 +0000 (23:13 +0200)] 
sd-device: include parent devices in enumeration

2 years agosd-device: properly support some corner case syspath
Lennart Poettering [Tue, 12 Apr 2022 13:45:48 +0000 (15:45 +0200)] 
sd-device: properly support some corner case syspath

2 years agosd-device: add some comments
Lennart Poettering [Tue, 12 Apr 2022 13:45:07 +0000 (15:45 +0200)] 
sd-device: add some comments

2 years agosd-device: filter regular files when enumerating
Lennart Poettering [Tue, 12 Apr 2022 09:25:00 +0000 (11:25 +0200)] 
sd-device: filter regular files when enumerating

Currently if enumerating with debug logging you'll likely see something
like this:

sd-device: the syspath "/sys/class/devcoredump/disabled" is not a directory.
sd-device: the syspath "/sys/class/firmware/timeout" is not a directory.
sd-device: the syspath "/sys/class/zram-control/hot_remove" is not a directory.
sd-device: the syspath "/sys/class/zram-control/hot_add" is not a directory.
sd-device: the syspath "/sys/class/drm/version" is not a directory.

This is because these sysfs classes place regular files in these
directories, which we so far didn't expect.

Let's filter them early, and only bother with enumerated inodes if they
actually are dirs or symlinks, i.e. can be kobject dirs. Regular file
definitely never are kobject dirs...

2 years agosd-device: split out checking of matches from enumerator_scan_dir_and_add_devices()
Lennart Poettering [Mon, 11 Apr 2022 21:00:52 +0000 (23:00 +0200)] 
sd-device: split out checking of matches from enumerator_scan_dir_and_add_devices()

No change in behaviour, just some splitting out of code.

2 years agosd-device: generate e better error code when trying to allocate sd_device for non-dir
Lennart Poettering [Tue, 12 Apr 2022 09:42:30 +0000 (11:42 +0200)] 
sd-device: generate e better error code when trying to allocate sd_device for non-dir

Currently, for sysfs paths outside of /sys/devices/ we do better
checking if something is a suitable path: we check if it's actually a
directory, and if not return ENODEV.

Let's make the codepath for nodes *inside* of /sys/device/ similar:
let's also return ENODEV if the path supplied is not a directory.

Previously, we'd return ENOTDIR in that case, which is quite confusing I
think.

2 years agosd-device: don't accept non-sysfs paths
Lennart Poettering [Mon, 11 Apr 2022 20:04:06 +0000 (22:04 +0200)] 
sd-device: don't accept non-sysfs paths

There are some file systems mounted below /sys/ that are not actually
sysfs, i.e. are not arranged in a sysfs/kobject style. Let's refuse
those early. (Example, /sys/fs/cgroup/ and similar.)

(Also, let's add an env var for this, so that it can be turned off for
test cases.)

2 years agosd-device: use chase_symlinks() O_PATH fd
Lennart Poettering [Mon, 11 Apr 2022 20:02:23 +0000 (22:02 +0200)] 
sd-device: use chase_symlinks() O_PATH fd

chase_symlinks() can return its last O_PATH fd to us. Let's use that and
make the access() check a bit tighter by going via faccessat() on the
O_PATH fd.

This doesn't really change too much, but is nice in context of the next
commit, which uses the O_PATH fd in one other way.

2 years agoMerge pull request #23065 from poettering/env-var-generator
Lennart Poettering [Wed, 13 Apr 2022 11:44:30 +0000 (13:44 +0200)] 
Merge pull request #23065 from poettering/env-var-generator

pid1: pass additional env vars about exec context to generators

2 years agoupdate TODO 23065/head
Lennart Poettering [Tue, 12 Apr 2022 21:47:07 +0000 (23:47 +0200)] 
update TODO

2 years agoman: document new generator env vars
Lennart Poettering [Tue, 12 Apr 2022 21:29:36 +0000 (23:29 +0200)] 
man: document new generator env vars

2 years agoman: rebreak all paragraphs in systemd.generator(7)
Lennart Poettering [Tue, 12 Apr 2022 21:00:45 +0000 (23:00 +0200)] 
man: rebreak all paragraphs in systemd.generator(7)

2 years agopid1: pass useful env vars to generators
Lennart Poettering [Tue, 12 Apr 2022 13:44:46 +0000 (15:44 +0200)] 
pid1: pass useful env vars to generators

This is inspired by this:

    https://github.com/systemd/zram-generator/blob/main/src/generator.rs#L29

Given it's easy for PID 1 to pass this to generators, I thin we should.
All generators not written by us likely want to know these things so
that the can adjust to the execution environment.

2 years agoMerge pull request #23002 from yuwata/udev-use-child-event
Zbigniew Jędrzejewski-Szmek [Wed, 13 Apr 2022 06:32:16 +0000 (08:32 +0200)] 
Merge pull request #23002 from yuwata/udev-use-child-event

udev: use child event source

2 years agoMerge pull request #23061 from poettering/chase-symlinks-tweaks,-new
Lennart Poettering [Tue, 12 Apr 2022 20:57:17 +0000 (22:57 +0200)] 
Merge pull request #23061 from poettering/chase-symlinks-tweaks,-new

some chase_symlinks() tweaks

2 years agocore: use assert_se() which takes side-effect
Yu Watanabe [Tue, 12 Apr 2022 14:52:22 +0000 (23:52 +0900)] 
core: use assert_se() which takes side-effect

Fixes #23059.

2 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

2 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.

2 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

2 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

2 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.

2 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,

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

2 years agochase-symlinks: prefer path_extract_directory() over dirname() 23061/head
Lennart Poettering [Tue, 12 Apr 2022 13:44:02 +0000 (15:44 +0200)] 
chase-symlinks: prefer path_extract_directory() over dirname()

2 years agochase-symlinks: add comment for opaque argument
Lennart Poettering [Tue, 12 Apr 2022 13:43:39 +0000 (15:43 +0200)] 
chase-symlinks: add comment for opaque argument

2 years agochase-symlinks: add missing OOM check
Lennart Poettering [Tue, 12 Apr 2022 13:43:23 +0000 (15:43 +0200)] 
chase-symlinks: add missing OOM check

2 years agochase-symlinks: use empty_to_root() where appropriate
Lennart Poettering [Tue, 12 Apr 2022 13:43:13 +0000 (15:43 +0200)] 
chase-symlinks: use empty_to_root() where appropriate

2 years agochase-symlinks: avoid using stack allocation for potentially huge paths
Lennart Poettering [Tue, 12 Apr 2022 13:41:48 +0000 (15:41 +0200)] 
chase-symlinks: avoid using stack allocation for potentially huge paths

let's better be safe and use heap allocation for paths which might be
unbounded.

In particular as previously we copied the stack memory to heap anyway,
via a noop path_make_absolute_cwd() call.

2 years agochase-symlinks: use proper typedef for flags argument
Lennart Poettering [Tue, 12 Apr 2022 13:41:09 +0000 (15:41 +0200)] 
chase-symlinks: use proper typedef for flags argument

2 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

2 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"

2 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

2 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.

2 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.)

2 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.

2 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

2 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.

2 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.

2 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.

2 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

2 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

2 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.

2 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.

2 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.

2 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()

2 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.

2 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.

2 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

2 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

2 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

2 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

2 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.)

2 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.

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

2 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

2 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.

2 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

2 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

2 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

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

2 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

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

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

2 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.

2 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.

2 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

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

2 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
2 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

2 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.

2 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

2 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

2 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.

2 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

2 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.

2 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.

2 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.

2 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.

2 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.

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

2 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

2 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.

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

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

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

2 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.

2 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

2 years agotests: add test case for long unit names
Michal Sekletar [Wed, 23 Mar 2022 12:35:44 +0000 (13:35 +0100)] 
tests: add test case for long unit names

2 years agocore: shorten long unit names that are based on paths and append path hash at the end
Michal Sekletar [Tue, 15 Mar 2022 18:02:05 +0000 (19:02 +0100)] 
core: shorten long unit names that are based on paths and append path hash at the end

Fixes #18077

2 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.