From e5f8325b42bfcea2e9064ee709423e5779228413 Mon Sep 17 00:00:00 2001 From: Vladis Dronov Date: Thu, 27 May 2021 19:45:48 +0200 Subject: [PATCH] Fix /dev/hwrng permissions issue Resolves: rhbz#1965318 Signed-off-by: Vladis Dronov --- 60-hwrng.rules | 1 + rng-tools.spec | 6 +++++- rngd-wake-threshold.service | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 60-hwrng.rules diff --git a/60-hwrng.rules b/60-hwrng.rules new file mode 100644 index 0000000..dfb7cae --- /dev/null +++ b/60-hwrng.rules @@ -0,0 +1 @@ +SUBSYSTEM=="misc", KERNEL=="hw_random", GROUP="rngd", MODE="0640" diff --git a/rng-tools.spec b/rng-tools.spec index f64360e..280f296 100644 --- a/rng-tools.spec +++ b/rng-tools.spec @@ -17,6 +17,7 @@ URL: https://github.com/nhorman/rng-tools Source0: https://github.com/nhorman/rng-tools/archive/v%{version}/rng-tools-%{version}.tar.gz Source1: rngd.service Source2: rngd-wake-threshold.service +Source3: 60-hwrng.rules BuildRequires: gcc make BuildRequires: gettext @@ -63,15 +64,17 @@ Hardware random number generation tools. %install %make_install -# install systemd unit file +# install systemd unit file and udev rules install -Dt %{buildroot}%{_unitdir} -m0644 %{SOURCE1} install -Dt %{buildroot}%{_unitdir} -m0644 %{SOURCE2} +install -Dt %{buildroot}%{_udevrulesdir} -m0644 %{SOURCE3} %pre getent passwd rngd >/dev/null || useradd -r -M -d %{_localstatedir}/lib/rngd -s /sbin/nologin -c "Random Number Generator Daemon" rngd %post %systemd_post rngd.service rngd-wake-threshold.service +udevadm trigger --sysname-match=hw_random --settle %preun %systemd_preun rngd.service rngd-wake-threshold.service @@ -89,6 +92,7 @@ getent passwd rngd >/dev/null || useradd -r -M -d %{_localstatedir}/lib/rngd -s %{_mandir}/man8/rngd.8.* %attr(0644,root,root) %{_unitdir}/rngd.service %attr(0644,root,root) %{_unitdir}/rngd-wake-threshold.service +%attr(0644,root,root) %{_udevrulesdir}/60-hwrng.rules %changelog * Mon May 24 2021 Vladis Dronov - 6.12-4 diff --git a/rngd-wake-threshold.service b/rngd-wake-threshold.service index f7b3de9..4b45da3 100644 --- a/rngd-wake-threshold.service +++ b/rngd-wake-threshold.service @@ -7,7 +7,7 @@ CapabilityBoundingSet=CAP_SYS_ADMIN AmbientCapabilities=CAP_SYS_ADMIN Type=oneshot RemainAfterExit=yes -ExecStart=/bin/sh -c "PSIZE=$(cat /proc/sys/kernel/random/poolsize); let THRESH=$PSIZE*3/4; echo $THRESH>/proc/sys/kernel/random/write_wakeup_threshold" +ExecStart=/bin/sh -c "PSIZE=$(cat /proc/sys/kernel/random/poolsize); let THRESH=$PSIZE*3/4; echo $THRESH>/proc/sys/kernel/random/write_wakeup_threshold; udevadm trigger --sysname-match=hw_random --settle" [Install] WantedBy=sysinit.target