1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-02-21 01:57:57 +03:00

57377 Commits

Author SHA1 Message Date
Yu Watanabe
bd1f75d5fb
Merge pull request #23070 from poettering/devnum-split
basic: some devnum handling tweaks and refactorings
2022-04-14 03:45:39 +09:00
Yu Watanabe
f4e357d77f
Merge pull request #22969 from poettering/udevadm-tree
udevadm: add new "udevadm info --tree" command
2022-04-14 03:45:14 +09:00
Lennart Poettering
02b9047edf devnum-util: catch potential stack overruns early 2022-04-13 16:26:31 +02:00
Lennart Poettering
ec61371fe6 devnum-util: define helper macros for formatting devnum major/minor pairs
And port some parts over.
2022-04-13 16:26:31 +02:00
Lennart Poettering
7176f06c9e 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.
2022-04-13 16:26:31 +02:00
Lennart Poettering
2f048ad0fe update TODO 2022-04-13 14:41:05 +02:00
Lennart Poettering
7b6d168376 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()
2022-04-13 14:41:05 +02:00
Lennart Poettering
9117d94b9a udevadm: add new --tree mode to "udevadm info"
sysfs is a tree, hence let's a mode that allows showing it as such.
2022-04-13 14:41:05 +02:00
Lennart Poettering
00dfbf35fd sd-device: include parent devices in enumeration 2022-04-13 14:41:05 +02:00
Lennart Poettering
0b859c9773 sd-device: properly support some corner case syspath 2022-04-13 14:41:05 +02:00
Lennart Poettering
be247835c7 sd-device: add some comments 2022-04-13 14:41:05 +02:00
Lennart Poettering
29a5428f1c 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...
2022-04-13 14:41:04 +02:00
Lennart Poettering
e7c7d79d52 sd-device: split out checking of matches from enumerator_scan_dir_and_add_devices()
No change in behaviour, just some splitting out of code.
2022-04-13 14:41:04 +02:00
Lennart Poettering
5cf0ee31ec 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.
2022-04-13 14:41:03 +02:00
Lennart Poettering
a7910612a5 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.)
2022-04-13 14:40:13 +02:00
Lennart Poettering
1793bb6112 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.
2022-04-13 14:40:09 +02:00
Lennart Poettering
c87c307806
Merge pull request #23065 from poettering/env-var-generator
pid1: pass additional env vars about exec context to generators
2022-04-13 13:44:30 +02:00
Lennart Poettering
cfb5bf23d3 update TODO 2022-04-13 10:44:56 +02:00
Lennart Poettering
5b9d199ab4 man: document new generator env vars 2022-04-13 10:44:56 +02:00
Lennart Poettering
a1d0557440 man: rebreak all paragraphs in systemd.generator(7) 2022-04-13 10:07:46 +02:00
Lennart Poettering
82c5db16cc 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.
2022-04-13 10:07:46 +02:00
Zbigniew Jędrzejewski-Szmek
87d44b6e1a
Merge pull request #23002 from yuwata/udev-use-child-event
udev: use child event source
2022-04-13 08:32:16 +02:00
Lennart Poettering
5e9f594038
Merge pull request #23061 from poettering/chase-symlinks-tweaks,-new
some chase_symlinks() tweaks
2022-04-12 22:57:17 +02:00
Yu Watanabe
5180394b38 core: use assert_se() which takes side-effect
Fixes #23059.
2022-04-12 18:45:20 +02:00
Yu Watanabe
82e0b63183 udev: use child event source to manage workers 2022-04-13 01:08:42 +09:00
Yu Watanabe
a79cba3326 udev: use EventResult type
This also adds EVENT_RESULT_SUCCESS for readability.
2022-04-13 01:00:08 +09:00
Yu Watanabe
fbae50904f sd-event: make inotify event work after the process is forked 2022-04-13 01:00:08 +09:00
Yu Watanabe
86587c93b0 sd-event: do not kill a child process from another child 2022-04-13 01:00:08 +09:00
Yu Watanabe
01e6af7374 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.
2022-04-13 01:00:08 +09:00
Yu Watanabe
54988a27b9 sd-event: set pid to event source after all setup processes finished
Otherwise, the assertion in source_disconnect() may be triggered,
2022-04-13 01:00:08 +09:00
Yu Watanabe
91c700713f sd-event: rebreak comments 2022-04-13 01:00:08 +09:00
Lennart Poettering
57f9ca3aa0 chase-symlinks: prefer path_extract_directory() over dirname() 2022-04-12 17:10:50 +02:00
Lennart Poettering
860f4c6aa6 chase-symlinks: add comment for opaque argument 2022-04-12 17:10:06 +02:00
Lennart Poettering
0ac6cdd6ae chase-symlinks: add missing OOM check 2022-04-12 17:09:21 +02:00
Lennart Poettering
69cf392f8e chase-symlinks: use empty_to_root() where appropriate 2022-04-12 17:08:33 +02:00
Lennart Poettering
7b9be862c7 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.
2022-04-12 17:07:49 +02:00
Lennart Poettering
8f47f880a4 chase-symlinks: use proper typedef for flags argument 2022-04-12 17:06:49 +02:00
Yu Watanabe
d89e18cc38
Merge pull request #23057 from keszybz/various-doc-tweaks
Various doc tweaks
2022-04-12 23:09:51 +09:00
Zbigniew Jędrzejewski-Szmek
52e30c6f81 man: add "internal" to "reference counter" 2022-04-12 15:33:05 +02:00
Zbigniew Jędrzejewski-Szmek
edef9c469a docs/RELEASE: also mention syscall tables 2022-04-12 15:28:39 +02:00
Zbigniew Jędrzejewski-Szmek
3983fc0227 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.
2022-04-12 15:28:33 +02:00
Zbigniew Jędrzejewski-Szmek
e8a688178c 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.)
2022-04-12 12:35:44 +02:00
Zbigniew Jędrzejewski-Szmek
2a1a7910f9 man: add page for sd_device_{ref,unref,unrefp}
Gotta start somewhere.
2022-04-12 12:35:44 +02:00
Zbigniew Jędrzejewski-Szmek
69e6a46970 man: say libudev should not be used for new projects 2022-04-12 12:28:24 +02:00
Zbigniew Jędrzejewski-Szmek
fc6f59aedc 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.
2022-04-12 12:28:24 +02:00
Zbigniew Jędrzejewski-Szmek
ff9412c152 Fix man page links
Based on linkchecker as usual.
2022-04-12 11:02:16 +02:00
Peter Hutterer
bc85f8b51d 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.
2022-04-12 09:24:25 +02:00
Yu Watanabe
e2185ffef8
Merge pull request #23051 from poettering/udev-tweaklets-2
udev: three minor tweaks
2022-04-12 14:06:53 +09:00
Yu Watanabe
68fe012fdf
Merge pull request #23048 from keszybz/Add-more-tests-for-specifiers
Add more tests for specifiers
2022-04-12 14:04:48 +09:00
Zbigniew Jędrzejewski-Szmek
9a5893e9bb 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.
2022-04-11 21:02:34 +02:00