From 0ecb45e7b10894ec5ff5aa0b2becdc12a09dbe79 Mon Sep 17 00:00:00 2001 From: Mike Fleetwood Date: Sun, 6 Aug 2023 11:34:07 +0100 Subject: [PATCH] Also find system default udev rules in /usr/lib/udev/rules.d (!116) When blanking of udev rules was first tested [1][2] and added [3] all the distributions at the time (CentOS 6, Debian 6, Fedora 19, openSUSE 12.2, Ubuntu 12.04 LTS) stored the system default rules in directory /lib/udev/rules.d. Now most distributions (CentOS Stream 9, Debian 11, Fedora 38, Ubuntu 22.04 LTS, openSUSE Leap 15.4) store the system default rules in directory /usr/lib/udev/rules.d. Most of these distributions have a merged /usr file system [4][5] so /lib is a symlink to /usr/lib and the system default rules can still found using the original directory. But openSUSE 15.4 doesn't have a merged /usr so the gparted shell wrapper doesn't find the system default rules in directory /usr/lib/udev/rules.d and doesn't prevent auto starting of Linux Software RAID arrays and bcache devices during a storage probe. An extra consideration is that Alpine Linux 3.17 doesn't have a merged /usr file system, but has both /lib/udev/rules.d and /usr/lib/udev/rules.d directories with different rules files. Therefore fix this by checking for system default udev rules in both directories. [1] Bug 709640 - Linux Swap Suspend and Software RAID partitions not recognised, comment 7 https://bugzilla.gnome.org/show_bug.cgi?id=709640#c7 [2] Bug 709640 - Linux Swap Suspend and Software RAID partitions not recognised, comment 12 https://bugzilla.gnome.org/show_bug.cgi?id=709640#c12 [3] a255abf3432ad106fac9c766f0816ada20be8e42 Prevent GParted starting stopped Linux Software RAID arrays (#709640) [4] The Case for the /usr Merge http://0pointer.de/blog/projects/the-usr-merge [5] The Case for the /usr Merge https://www.freedesktop.org/wiki/Software/systemd/TheCaseForTheUsrMerge/ Closes !116 - Systemd mount masking and udev rule location updates --- gparted.in | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gparted.in b/gparted.in index d35b4a8f..82ada982 100755 --- a/gparted.in +++ b/gparted.in @@ -183,8 +183,9 @@ fi # start Linux Software RAID array members and Bcache devices. # # Udev stores volatile / temporary runtime rules in directory /run/udev/rules.d. -# Volatile / temporary rules are used to override default rules from -# /lib/udev/rules.d. (Permanent local administrative rules in directory +# Volatile / temporary rules are used to override system default rules from +# /lib/udev/rules.d and/or /usr/lib/udev/rules.d (depending on udev +# configuration). (Permanent local administrative rules in directory # /etc/udev/rules.d override all others). See udev(7) manual page for details. # # Default udev rules containing mdadm to incrementally start array members are @@ -194,9 +195,12 @@ fi UDEV_TEMP_RULES='' # List of temporary override rules files. if test -d /run/udev; then test ! -d /run/udev/rules.d && mkdir /run/udev/rules.d - udev_mdadm_rules=`egrep -l '^[^#].*mdadm (-I|--incremental)' /lib/udev/rules.d/*.rules 2> /dev/null` - udev_bcache_rules=`ls /lib/udev/rules.d/*bcache*.rules 2> /dev/null` - UDEV_TEMP_RULES=`echo $udev_mdadm_rules $udev_bcache_rules | sed 's,/lib/udev,/run/udev,g'` + UDEV_TEMP_RULES=`for udev_default_rules_dir in /lib/udev/rules.d /usr/lib/udev/rules.d + do + test -d $udev_default_rules_dir || continue + egrep -l '^[^#].*mdadm (-I|--incremental)' $udev_default_rules_dir/*.rules 2> /dev/null + ls $udev_default_rules_dir/*bcache*.rules 2> /dev/null + done | sed 's,.*/lib/udev,/run/udev,g' | sort -u` fi for rule in $UDEV_TEMP_RULES; do touch "$rule"