Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#79762 - [systemd] udevd_live() in systemd-hook script erroneously thinks udevd is running

Attached to Project: Arch Linux
Opened by Hugo Trassoudaine (hugotrsd) - Saturday, 23 September 2023, 10:08 GMT
Last edited by Christian Hesse (eworm) - Tuesday, 26 September 2023, 20:48 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Christian Hesse (eworm)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

Check performed at
https://gitlab.archlinux.org/archlinux/packaging/packages/systemd/-/blob/c8277d5d9ddf0d30bb84b97df5e9702637be7880/systemd-hook#L20
is not sufficient to determine if udev is running or not.

This causes "/usr/share/libalpm/scripts/systemd-hook udev-reload" to report an error: "Failed to send reload request: No such file or directory"
This causes pacman to report an error when running hook 30-systemd-udev-reload.hook.

Instead of looking for the directory, changing the condition to check for the socket fixes the issue.
ie. changing [ ! -d /run/udev ] to [ ! -S /run/udev/control ]

This is relevant since other parts of the system may dynamically create files under /run/udev, even if the daemon is not running.
Notably, distrobuilder updated their systemd-generator script to do just that about a year ago.
While this may be considered a bug on distrobuilder side, I feel like it makes more sense to fix it here.
See: https://github.com/lxc/distrobuilder/blob/29e94ac90dc52ae4e5fc0c6ad34951d4369aa001/distrobuilder/main.go#L825-L837

Additional info:
* running systemd 254.4-1
* noticed in LXD/Incus containers (with "lxc.mount.auto = sys:ro" option to prevent systemd-udevd.service from running)

Steps to reproduce:
* Ensure systemd-udevd.service is not running
* Ensure /run/udev exists
* Run "/usr/share/libalpm/scripts/systemd-hook udev-reload" or "pacman -S systemd"
This task depends upon

Closed by  Christian Hesse (eworm)
Tuesday, 26 September 2023, 20:48 GMT
Reason for closing:  Fixed
Additional comments about closing:  in git
Comment by Toolybird (Toolybird) - Sunday, 24 September 2023, 07:20 GMT
> * Ensure systemd-udevd.service is not running
> * Ensure /run/udev exists

At first glance, those conditions would seem to be quite rare. But your suggested improvement is probably more accurate.
Comment by Hugo Trassoudaine (hugotrsd) - Sunday, 24 September 2023, 09:47 GMT
Totally. It is part of a chain of issues in my case.

I'm running unprivileged LXD with the default ArchLinux image (made with distrobuilder).
- 1. By default, /sys is mounted read-write, but isn't actually writable (owned by nobody:nobody). This goes against https://systemd.io/CONTAINER_INTERFACE/.
- 2. SystemD's "ConditionPathIsReadWrite=/sys" does not detect this correctly, causing systemd-udevd.service to start.
- 3. Adding "lxc.mount.auto = sys:ro" to LXD's configuration fixes 1 and 2. However, the default ArchLinux image has a /etc/systemd/system-generator/lxc script which creates files under /run/udev if /etc/udev exists.
- 4. /etc/udev is owned and part of systemd, removing it and rebooting works, but it's not really a fix (it will come back on package upgrades).

I feel like both /usr/share/libalpm/scripts/systemd-hook and /etc/systemd/system-generator/lxc are wrong in how they check for udev.
Fixing one of them solves the issue, and to me the lowest hanging fruit is /usr/share/libalpm/scripts/systemd-hook.
Comment by Christian Hesse (eworm) - Tuesday, 26 September 2023, 20:48 GMT
Sounds reasonable... I will push this for next package and hope things do not explode. :)

Loading...