Subject: eudev: regex in preinst script prevents installation

From: David Paul <[email-masked]>
Date: Thu, 5 Aug 2021 21:42:36 -0500

Package: eudev
Version: 3.2.9-9
Severity: grave
Tags: patch
Justification: renders package unusable

Dear Maintainer,

### Summary:
Please apply the attached patch to the eudev source package. A
similar change should also be made to Debian's systemd source package.

### Details:
Last week a user on the Devuan support IRC reported an inability to
upgrade eudev while attempting to perform an upgrade from ASCII to
Beowulf. After much back and forth, I was able to determine the cause
to be a regular expression in the preinst script for the eudev package.
(For the full
conversion see the IRC log beginning at
http://reisenweber.net/irclogs/freenode/_devuan/_devuan.2021-07-27.log.html#t2021-07-27T18:25:49
and ending at
http://reisenweber.net/irclogs/freenode/_devuan/_devuan.2021-07-28.log.html#t2021-07-28T05:01:23)
The regex in question is responsible for verifying the presence of six
kernel system call symbols required for eudev to function.
Unfortunately, because of prefixes on the names of the symbols in
the /proc/kallsyms file, the current version of the regex fails to
identify the presence of all the needed symbols. As can be seen in the
timeline that follows, this same issue was discovered November of
2018 and the problematic regular expression was modified accordingly.
Unfortunately, when the eudev maintainer scripts were modified in
January of 2020 to more closely match those of the udev binary package
from the Debian systemd source package, the regex in the check was
inadvertently reverted to the pre-2018 problematic version. The
attached patch modifies the regex back to its fixed version.

For the sake of completeness, it should be noted that the issue
mentioned in Debian bug #552778 (see 2009-11-10 in the timeline that
follows) is left unaddressed by this patch. Given that it involves a
processor architecture no longer supported by Debian (never supported
by Devuan) and applies to an issue with a 12 year old kernel, I think
it can be safely ignored. I will nevertheless be preforming experiments
with a Power Mac G5 to determine if this issue was every resolved
merely through the use of newer kernels. If an additional patch is
required as a result of these tests I will file a separate bug report.

### Timeline (reverse chronological order):
https://git.devuan.org/devuan/eudev/commit/243adc9487e06a928558628f5e0bf3f647c1a3c4
2020-01-08
The eudev.{init,preinst,postinst,prerm} scripts are modified to more
closely match the udev.{init,preinst,postinst,prerm} scripts in the
Debian package systemd 243-8 (see
https://salsa.debian.org/systemd-team/systemd/-/tree/debian/243-8). In
the process the regex in question in the eudev.preinst is inadvertently
reverted to the earlier problematic version.

https://git.devuan.org/devuan/eudev/commit/893574a43ab9cc9779dbbc7deab591b72b92ab59
https://git.devuan.org/devuan/eudev/commit/c5e67ec148a250ab432c565ccd08a386154fc5ee
2018-11-02
The regex in the kernel symbol check in eudev.preinst is changed to
contain "(_+.*_)" in place of "\.?" for detecting prefixed symbol
names. This change is the result of a conversation on IRC spanning from
http://reisenweber.net/irclogs/freenode/_devuan-dev/_devuan-dev.2018-11-02.log.html#t2018-11-02T16:47:03
to
http://reisenweber.net/irclogs/freenode/_devuan-dev/_devuan-dev.2018-11-02.log.html#t2018-11-02T18:49:16

https://git.devuan.org/devuan/eudev/commit/3529a42fc1c80a147ee0b6abd46e8175e5fe6bc7
2017-06-01
The eudev.preinst symlink to udev.preinst is replaced with a standard
file and udev.preinst is deleted.

https://git.devuan.org/devuan/eudev/commit/53a6f64a81a04a14a3fd44b294a3668ca483b9f4
2017-04-29
eudev.preinst is added as a symlink to udev.preinst

https://git.devuan.org/devuan/eudev/commit/8c34e95b65648801ec93959a3a8fc706d23d4abe
2017-04-22
The first commit with a debian/ directory is added to the current eudev
packaging repository. Included is a udev.preinst file. Prior early
debian packaging work is referenced in the included debian/changelog
file, but as far as I can tell that early work is not publicly
preserved, though I'd be happy to be proved wrong about that.

https://salsa.debian.org/systemd-team/systemd/-/commit/681aaee461212681c7efa4aed932cd93a03ec8e7
2016-02-05
The explicit checks in udev.preinst and udev.postinst for linux kernel
versions >= 2.6.32, which was released in 2009, are dropped. Support
for forcing udev upgrades via /etc/udev/kernel-upgrade to kernels known
to not be compatible is also dropped. check_kernel_features() remains
in udev.preinst but is simplified.

https://salsa.debian.org/systemd-team/systemd/-/commit/d4751047810b64f5a23c55cd04d2c7cf568dd9f5
2014-04-26
A check is added to udev.preinst for the syscall symbol accept4,
resolving Debian bug #648325.

https://salsa.debian.org/systemd-team/systemd/-/commit/aa9ec4cdf2f0e2c97cc61f295b348e17735a9fc7
2014-04-26
Checks are added to udev.preinst for the syscall symbols
open_by_handle_at, timerfd_create, and epoll_create.

https://salsa.debian.org/systemd-team/systemd/-/commit/b56f8637a1e03ac6a45af7820287159df9b506b9
2013-07-17
Following the merging of udev into systemd upstream, debian/ files from
udev 175-7 are incorporated into the systemd source package.

https://salsa.debian.org/systemd-team/systemd/-/commit/7ffbf10c801a5fa0adf60d57d634e0b7d28efb62
2013-07-17
The explicit kernel version incompatibilities are removed in
debian/control from the udev package stanza.

https://snapshot.debian.org/package/udev/147%7Egit20091109-1/
2009-11-10
The regex in the udev preinst script is changed to also match kernel
symbols with a leading dot to address Debian bug #552778 involving a
powerpc64 system.

https://snapshot.debian.org/package/udev/146-5/
2009-10-08
The check_kernel_features() function is first added to the udev.preinst
script. The function checks for the inotify_init and signalfd system
call symbols.
diff --git a/debian/eudev.preinst b/debian/eudev.preinst
index 743c8267c..339e4a150 100644
--- a/debian/eudev.preinst
+++ b/debian/eudev.preinst
@@ -18,7 +18,7 @@ check_kernel_features() {
 
       local needed_symbols='inotify_init signalfd accept4 open_by_handle_at timerfd_create epoll_create'
       for symbol in $needed_symbols; do
-      if ! egrep -q "^[a-fA-F0-9]+ T \.?sys_${symbol}$" /proc/kallsyms; then
+      if ! egrep -q "^[a-fA-F0-9]+ T (_+.*_)sys_${symbol}$" /proc/kallsyms; then
 	  cat <<END
 Since release 198, udev requires support for the following features in
 the running kernel: