Fix /dev/hwrng permissions issue

Resolves: rhbz#1965318

Signed-off-by: Vladis Dronov <vdronov@redhat.com>
This commit is contained in:
Vladis Dronov 2021-05-27 19:45:48 +02:00
parent ac3673085e
commit e5f8325b42
3 changed files with 7 additions and 2 deletions

1
60-hwrng.rules Normal file
View File

@ -0,0 +1 @@
SUBSYSTEM=="misc", KERNEL=="hw_random", GROUP="rngd", MODE="0640"

View File

@ -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 <vdronov@redhat.com> - 6.12-4

View File

@ -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