Don't trigger udev if socket is not accessible

In container environments or rpm-ostree systems, scriptlets are not
directly run on a host system. Thus, there's no point in asking udev to
reload and retrigger: the host udev wouldn't see the new rules anyway.

Let's just generalize this by checking if the udev socket even exists.
If not, then we can't talk to `udevd` and we should just skip the reload
& trigger bits.

Ref: https://bugzilla.redhat.com/show_bug.cgi?id=1753786
This commit is contained in:
Jonathan Lebon 2019-10-01 10:03:05 -04:00
parent b743c2506b
commit f651544b54

View File

@ -59,7 +59,7 @@
Name: udisks2 Name: udisks2
Summary: Disk Manager Summary: Disk Manager
Version: 2.8.4 Version: 2.8.4
Release: 2%{?dist} Release: 3%{?dist}
License: GPLv2+ License: GPLv2+
URL: https://github.com/storaged-project/udisks URL: https://github.com/storaged-project/udisks
Source0: https://github.com/storaged-project/udisks/releases/download/udisks-%{version}/udisks-%{version}.tar.bz2 Source0: https://github.com/storaged-project/udisks/releases/download/udisks-%{version}/udisks-%{version}.tar.bz2
@ -307,8 +307,12 @@ chrpath --delete %{buildroot}/%{_libexecdir}/udisks2/udisksd
%post -n %{name} %post -n %{name}
%systemd_post udisks2.service %systemd_post udisks2.service
%systemd_post clean-mount-point@.service %systemd_post clean-mount-point@.service
udevadm control --reload # skip retriggering if udevd isn't even accessible, e.g. containers or
udevadm trigger # rpm-ostree-based systems
if [ -S /run/udev/control ]; then
udevadm control --reload
udevadm trigger
fi
%preun -n %{name} %preun -n %{name}
%systemd_preun udisks2.service %systemd_preun udisks2.service
@ -430,6 +434,9 @@ udevadm trigger
%endif %endif
%changelog %changelog
* Tue Oct 01 2019 Jonathan Lebon <jonathan@jlebon.com> - 2.8.4-3
- Don't trigger udev if socket is not accessible
* Sat Jul 27 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.8.4-2 * Sat Jul 27 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.8.4-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild