Commit Graph

2627 Commits

Author SHA1 Message Date
我超厉害
8a86e15f07 udev: even if a device is a zac device, scsi-$ID_SERIAL will be reserved for it (#30459)
Co-authored-by: wangyuhang <wangyuhang27@huawei.com>
2024-01-16 14:57:07 +09:00
chenjiayi
204594ecf1 udev: distinguish host-managed zoned block in scsi_id
According to SPC4, the value of 0x14 is reserved to distinguish
host managed zoned block, e.g., some SMR (Shingled Magnetic Recording)
disks.

Other utilities such as sg3_utils can successfully recognize such
kind of disks. This patch implements the same ability.
2024-01-12 15:52:38 +00:00
Yu Watanabe
967cd1712c Merge pull request #30867 from dtardon/udev-conf-dropins
Allow dropins for udev.conf
2024-01-12 06:37:23 +09:00
David Tardon
09dd8e77fc udev: factor out config parser call into function
... which is then called from both places. This makes sure that the
configuration is parsed by udevd and other tools in exactly the same
way.
2024-01-12 05:12:42 +09:00
David Tardon
343c8514c1 udevd: use config. parser to parse udev.conf
This adds support for the usual config. file hierarchy (including
dropins).

Fixes #30460.
2024-01-12 05:08:18 +09:00
Rose
aa9ff6c28d tree-wide: replace string functions with fundamental functions 2024-01-11 13:36:25 +09:00
Yu Watanabe
046286e863 udev/net: introduce [Link] Property=, ImportProperty=, and UnsetProperty= settings
The applied order is equivalent to Environment=, PassEnvironment=, and
UnsetEnvironment= for [Service] or so.
2024-01-10 04:33:51 +09:00
Yu Watanabe
513ca8b6f0 udev: split out check that udev property can be updated 2024-01-10 04:27:41 +09:00
Yu Watanabe
3e00171dcd udev/net: split out udev property assignment logic
No functional change, just refactoring.
2024-01-10 04:27:41 +09:00
Yu Watanabe
0c3af33e19 udev/net: do not set unapplied .link file name to ID_NET_LINK_FILE
Instead, import already assigned value from the udev database.
Then, return the builtin earlier.
2024-01-10 04:27:41 +09:00
Yu Watanabe
ac36406277 udev-builtin-path_id: drop redundant debugging logs
The function udev_builtin_add_property() internally logs the failure.
2024-01-10 04:27:26 +09:00
Yu Watanabe
50a0379d5d udev/builtin: introduce udev_builtin_import_property() helper function
This is not used in this commit, but will be used later commits.
2024-01-10 04:11:08 +09:00
Yu Watanabe
7ba3e44651 udevadm: allow to override the default log level by environment variable
Previously, there was no way to override the log level for test and
test-builtin commands. Let's re-parse environment after setting the log
level to debug. Then, we can control the log level through environment
variable.
2024-01-06 08:30:58 +09:00
Luca Boccassi
5af0f171f9 udev: add upper bound of 5 hours to SYSTEMD_UDEV_EXTRA_TIMEOUT_SEC=
Follow-up for b16c6076cb

CID#1533111
2024-01-04 14:30:20 +01:00
Yu Watanabe
124c712692 Merge pull request #30532 from yuwata/udev-extend-timeout-kill-worker
udev: extend timeout to prevent kill worker
2024-01-04 05:21:50 +09:00
Yu Watanabe
e0feaedbd9 udev/dmi-memory-id: update table with latest SMBIOS specification
Closes #30699.
2024-01-03 08:43:17 +09:00
Yu Watanabe
b16c6076cb udev: wait for an extra time before the manager kills workers
Otherwise, udev workers cannot detect slow programs invoked by
IMPORT{program}=, PROGRAM=, or RUN=, and whole worker process may be
killed.

Fixes #30436.

Co-authored-by: sushmbha <sushmita.bhattacharya@oracle.com>
2024-01-03 04:23:22 +09:00
Yu Watanabe
11706971e8 udev-spawn: skip executing RUN= if exec_delay= is too long
To prevent the worker process killed by the manager.
2024-01-03 04:23:18 +09:00
Yu Watanabe
406c96e329 udev-spawn: refuse to spawn commands if the event already takes too long
Also, calculate the timeout for warning based on the remaining time for
the timeout of the event, rather than the timeout itself.

Currently, udev manager kills the worker if the timeout exceeds. So,
this does not change anything except for the timing of the warning.

Just refactoring and preparation for later commits.
2024-01-03 04:23:12 +09:00
Luca Boccassi
86b8b66675 Merge pull request #30591 from yuwata/device-util
device-util: introduce device_in_subsystem() and device_is_devtype() helper functions
2024-01-01 19:26:39 +01:00
Luca Boccassi
e191de6947 Merge pull request #30614 from yuwata/udev-event-take-worker
udev: make UdevEvent take UdevWorker object
2024-01-01 19:18:07 +01:00
Joakim Nohlgård
ba340e2a75 udevadm: Propagate return code from verb result
udevadm lock did not propagate the return code from the child process
because all positive values were treated as success.

v2:
Now 'udevadm test-builtin' ignores all positive return values from the
builtin commands. Otherwise, as the hwdb builtin returns an positive value
when a matching entry found, 'udevadm test-builtin hwdb' will fail.

v3:
Initialize partition table before calling 'sfdisk --delete'.

Co-authored-by: Yu Watanabe <watanabe.yu+github@gmail.com>
2023-12-30 05:26:59 +09:00
Yu Watanabe
fe3fcb9492 Merge pull request #30633 from mrc0mmand/cocci-shenanigans
coccinelle: rework how we run the Coccinelle transformations
2023-12-26 05:45:58 +09:00
Frantisek Sumsal
78bc04cf12 tree-wide: use strndupa_safe() in a couple more cases 2023-12-25 18:26:59 +01:00
Yu Watanabe
1d03d970a1 tree-wide: insert space after for and switch 2023-12-25 01:29:38 +09:00
Yu Watanabe
eb1a51b869 udev: make UdevEvent take reference to UdevWorker
Many functions take timeout_usec and friends, but those are equivalent
to the Worker elements.
No functional change, just refactoring.
2023-12-24 17:20:23 +09:00
Yu Watanabe
0df87a4037 udev: call udev_watch_end() before udev_event_execute_rules()
No functional change, just refactoring.
2023-12-24 17:20:23 +09:00
Luca Boccassi
d6fe382122 Merge pull request #30594 from yuwata/udev-timeout-cleanups
udev: several cleanups for timeout settings
2023-12-24 00:26:13 +01:00
Yu Watanabe
60d52f219e udev: use SD_EVENT_SIGNAL_PROCMASK 2023-12-23 00:32:48 +01:00
Yu Watanabe
5d64eb5593 udev-spawn: slightly adjust logs about timed out commands
- Add full stop to the messages.
- Do not kill commands before logging "killing", but do after.
2023-12-23 04:31:39 +09:00
Yu Watanabe
9cceb0be21 udev: refuse too short timeout value
Setting zero or too short timeout for each uevent is meaningless, and
causes the system fails to boot. Let's refuse such values.

Also, delaying execution of RUN= commands too long also makes many
uevents enter the failed state. So, let's refuse such misconfiguration.
2023-12-23 04:30:32 +09:00
Yu Watanabe
aff70e1388 udev: handle event_timeout=infinity correctly
This is a paranoia, as even USEC_INFINITY / 3 is finite, it is still so large
in general.
2023-12-23 04:30:32 +09:00
Yu Watanabe
7ca31a91de udev-manager: use ASSERT_PTR() 2023-12-23 04:30:32 +09:00
Yu Watanabe
fb53ee0a64 tree-wide: use device_in_subsystem() and device_is_devtype() 2023-12-23 03:52:21 +09:00
Daan De Meyer
a412a1b92a test: Skip various tests when /sys is not mounted
When running tests in a container, /sys might not be mounted, so
let's make sure we skip tests that depend on /sys in this case.
2023-12-19 16:38:57 +01:00
Lukas Nykryn
3b2e7dc5a2 udev: allow/denylist for reading sysfs attributes when composing a NIC name
Users can currently pick specific versions of NIC naming, but that
does not guarantee that NIC names won't change after the kernel adds
a new sysfs attribute.

This patch allows for an allow/deny list of sysfs attributes
that could be used when composing the name.

These lists can be supplied as an hwdb entry in the form of
/etc/udev/hwdb.d/50-net-naming-allowlist.hwdb
net:naming:drvirtio_net
  ID_NET_NAME_ALLOW=0
  ID_NET_NAME_ALLOW_ACPI_INDEX=1
  ID_NET_NAME_ALLOW_ADDR_ASSIGN_TYPE=1
  ID_NET_NAME_ALLOW_ADDRESS=1
  ID_NET_NAME_ALLOW_ARI_ENABLED=1
  ID_NET_NAME_ALLOW_DEV_PORT=1
  ID_NET_NAME_ALLOW_FUNCTION_ID=1
  ID_NET_NAME_ALLOW_IFLINK=1
  ID_NET_NAME_ALLOW_INDEX=1
  ID_NET_NAME_ALLOW_LABEL=1
  ID_NET_NAME_ALLOW_PHYS_PORT_NAME=1
  ID_NET_NAME_ALLOW_TYPE=1
2023-12-19 19:15:52 +09:00
Daan De Meyer
3d11b46bf7 Add $SYSTEMD_HWDB_UPDATE_BYPASS (#30463)
Same as $KERNEL_INSTALL_BYPASS, but for hwdb. This will speed up
cross architecture image builds in mkosi as I can disable package
managers from running the costly hwdb update stuff in qemu user
mode and run it myself with a native systemd-hwdb with --root=.
2023-12-14 18:57:05 +09:00
huyubiao
c00b446d93 udevadm: exiting udevadm monitor normally under SIGTERM or SIGINT
Under SIGTERM or SIGINT, exit event and release resources, and exit udevadm monitor normally.
2023-11-25 12:53:10 +09:00
Yu Watanabe
5acea42501 fuzz: always call fuzz_setup_logging() 2023-11-18 03:04:27 +09:00
Yu Watanabe
965040d811 test: always call test_setup_logging() 2023-11-18 03:04:27 +09:00
David Tardon
3afe909b75 udev-manager: fix log message 2023-11-16 10:16:11 +01:00
David Tardon
854b3c0485 udev: allow global properties in assignments
Before, handling of global properties (set on systemd-udevd by `udevadm
control -p FOO=foo`) was inconsistent. They were honored in ENV matches,
but not in any assignment. This meant that any use of $env{FOO} (where
FOO was a global property) expanded to an empty string.
2023-11-13 19:19:54 +01:00
David Tardon
57f6950eb9 udev-rules: use udev_get_property_value() 2023-11-13 19:19:04 +01:00
Lennart Poettering
3cc7a9fd25 udev-util: add generic device_get_{vendor,model}_string() helpers
We chck the same props in various places, add a single implementation of
a call to inquire this.
2023-11-13 16:24:17 +01:00
David Tardon
25270051cc udev-manager: mark old_key as unused too 2023-11-08 14:52:43 +01:00
David Tardon
e1593039db udev-manager: actually remove the property
AFAICT there's no reason to keep removed entries in the Hashmap
(although it doesn't break anything either). The only use of this
hashmap is in udev_rule_apply_token_to_event(), which just retrieves the
value using hashmap_get(), hence there's no difference there between an
existing entry with a NULL value and a missing entry.
2023-11-08 14:41:28 +01:00
Luca Boccassi
a6b8ecf304 udev: ressize -> result_size
Lintian flags it as a typo of 'resize', so rename it and make it clearer too
2023-11-06 18:48:25 +00:00
Yu Watanabe
eba449fa81 sd-device-monitor: unconditionally increase buffer size by sd_device_monitor_new()
As suggested at https://github.com/systemd/systemd/pull/29872#discussion_r1382932633:
> socket memory is these days accounted to the process that owns a socket,
> hence we shouldn't be too concerned that this might waste memory.
2023-11-06 20:39:51 +09:00
Yu Watanabe
4e601b7072 udevadm-trigger: extend receive buffer size
We may trigger huge number of devices and will receive many events.
Let's extend the buffer size, otherwise the buffer may be filled.

Fixes #29863.
2023-11-06 14:50:50 +09:00
Frantisek Sumsal
30e8c19270 udevadm: actually set the log level
Follow-up to e4080a6d97.
2023-11-04 14:05:04 +01:00