- Package:
- rng-tools-debian
- Source:
- rng-tools-debian
- Description:
- daemon to use a Hardware RNG (classic version)
- Submitter:
- Luca Boccassi
- Date:
- 2025-01-17 00:57:06 UTC
- Severity:
- normal
Dear Maintainers,
Thanks for adding a native systemd service!
I noticed that in an autopkgtest-build-qemu VM the service fails:
root@host:~# systemctl status --no-pager -l rng-tools-debian
× rng-tools-debian.service - Hardware RNG entropy gatherer daemon
(Debian variant)
Loaded: loaded (/usr/lib/systemd/system/rng-tools-debian.service;
enabled; preset: enabled)
Active: failed (Result: exit-code) since Tue 2025-01-14 12:58:55
UTC; 31s ago
Invocation: 50bf1d4b6ec64387a27ea1a42c0be118
Docs: man:rngd(8)
Process: 441 ExecStart=/usr/share/rng-tools-debian/systemd-helper
start (code=exited, status=1/FAILURE)
Mem peak: 1.7M
CPU: 8ms
Jan 14 12:58:55 host systemd[1]: Starting rng-tools-debian.service -
Hardware RNG entropy gatherer daemon (Debian variant)...
Jan 14 12:58:55 host rng-tools-debian[450]: not starting: /dev/hwrng
is used by the kernel automatically
Jan 14 12:58:55 host systemd[1]: rng-tools-debian.service: Control
process exited, code=exited, status=1/FAILURE
Jan 14 12:58:55 host systemd[1]: rng-tools-debian.service: Failed with
result 'exit-code'.
Jan 14 12:58:55 host systemd[1]: Failed to start
rng-tools-debian.service - Hardware RNG entropy gatherer daemon
(Debian variant).
It looks like this is doing some checks, and intends to skip. But just
exiting means the service is recorded as failed, and this will likely
trip other tests, hence the severity to stop migrating to testing for
now.
There are several ways to do such checks natively _and_ resulting in a
service that is skipped, rather than failed.
You could run the script that does the check in an ExecCondition=
statement - if that fails, the service is marked as skipped.
https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html#ExecCondition=
Or, you could have a special exit status that means the service is
marked as successful:
https://www.freedesktop.org/software/systemd/man/latest/systemd.service.html#SuccessExitStatus=
There might be other options as well, these are just the first that
came to mind.
Ah, ouch. Agreed. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=504044#162 RestartPreventExitStatus was the one I found and wondered about. That’s also an option. Would you mind looking at the aforementioned mail again, as it also has other questions, and suggest how we best deal with this? Additionally… what should we do if no random device is found, as opposed to quietly not starting if one is found that doesn’t need rngd to run? The sysvinit script will also just exit 0 in that case, but it doesn’t have service tracking, and a subsequent status query will show the dæmon as not running, obviously. I’ve got no idea how this maps best into the systemd ecosystem, though I’m currently leaning towards making all the “expected not to start” conditions the same. Thanks in advance, //mirabilos
Looking into it now. Wasn't aware of this. Thanks for the pointers. Applying ExecCondition to me seems the most reasonable solution to this bug. I believe the service should get skipped per ExecCondition also in this case (no random device found/available). Sven
Can the script behind ExecCondition pass variables to the script behind ExecStart or, even better, the unit itself so we can then use $HRNGDEVICE and $RNGDOPTIONS there? If not, I’d lean towards one (which?) of the errorlevel-using ones, because otherwise we’d have to run the detection code twice. OK. bye, //mirabilos
Found no suitable way to achieve this. One can write a file to hold the variables and their values when checking the conditions, and read it back when actually starting the service, but this seems a clunky approach to me. Not sure what you mean by 'one of the errorlevel-using ones'. Please explain your idea in more details. My current solution indeed needs to run the detection code twice. Sven
SuccessExitStatus or RestartPreventExitStatus, see further above
in the thread.
(I’d also s̲t̲i̲l̲l̲ like input from the systemd maintainers whether
we should exec the binary from the wrapper script or call it in
the background as is currently done.)
Thanks,
//mirabilos
Michael Schmitz on nntp://news.gmane.org/gmane.linux.debian.ports.68k
a.k.a. {news.gmane.org/nntp}#news.gmane.linux.debian.ports.68k in pine
This is an anti-pattern, and best avoided. What's the problem if the script runs twice? If it just detects things it should be just fine, no?
Extra effort, though. And, in general, TOCTOU, but probably not applicable here. bye, //mirabilos
Hi Thorsten, see https://salsa.debian.org/sven-geuer/rng-tools-debian for what, according to my tests, fixes the issue. Cheers, Sven
We believe that the bug you reported is fixed in the latest version of
rng-tools-debian, which is due to be installed in the Debian FTP archive.
A summary of the changes between this version and the previous one is
attached.
Thank you for reporting the bug, which will now be closed. If you
have further comments please address them to 1093002@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.
Debian distribution maintenance software
pp.
Thorsten Glaser <tg@mirbsd.de> (supplier of updated rng-tools-debian package)
(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)
Format: 1.8
Date: Fri, 17 Jan 2025 01:04:37 +0100
Source: rng-tools-debian
Architecture: source
Version: 2.6
Distribution: unstable
Urgency: low
Maintainer: Thorsten Glaser <tg@mirbsd.de>
Changed-By: Thorsten Glaser <tg@mirbsd.de>
Closes: 1093002
Changes:
rng-tools-debian (2.6) unstable; urgency=low
.
[ Sven Geuer ]
* Rework d/rng-tools-debian.service and d/systemd-helper:
- Switch service from Type=forking to Type=exec
- Terminate the service cleanly in case it decides it cannot run
(Closes: #1093002)
* Rename systemd-helper to rngd-systemd-helper
- Update d/rng-tools-debian.install and d/rng-tools-debian.service for
referencing the renamed file
* d/t/*: Adapt autopkgtests to the changes listed above
* configure.ac: Bump version to 2.6
.
[ Thorsten Glaser ]
* Update autopkgtests restrictions
* Tell lintian
Checksums-Sha1:
76617c6df0aaeaccf8e3a935866323711f87eaf5 1761 rng-tools-debian_2.6.dsc
a1d9b54489c6306986ff4aaf5608f9a19f79f68d 56064 rng-tools-debian_2.6.tar.xz
Checksums-Sha256:
1a4499b455db2b38904fafd03dd4d86ec65b0f5e3c2528e1d8464759c5fb8a2c 1761 rng-tools-debian_2.6.dsc
677f4fe861f1281b0bd029ef6905c9506988b2eb1b3a6cea2e8bd7c145cfe69a 56064 rng-tools-debian_2.6.tar.xz
Files:
4d469f925b7959aed0532c855338f35f 1761 utils optional rng-tools-debian_2.6.dsc
78e8c08a67b6e6b0ef484d4ba4f2b143 56064 utils optional rng-tools-debian_2.6.tar.xz
iQIcBAEBCQAGBQJniZ8lAAoJEHa1NLLpkAfg1FIP/2x/Baey4qI9U5zo2oln9KbJ
pR0VF35OdF94bGKEmstEDWxPui534DW6Q3MfK1UsIS1wAgUDvEKKAM0Sb1PQW0g2
/Rfqgqq4uNjRrlA8B13wP81LySNBA6ppD3R9gmF5QRFyB4G34QslcDhS2HzUFwFp
Pzs0/CxePDTAxqUF5Rc3m+UxrOs99uf0B8FOFwnDAAp8XcqQtk8SfWR+7L/qhVHl
62OplduiqByDFIAucXbQBCSgpCpuLMSzs4WgDDVNQczoilxtP9X4qsWeYIOrylNK
hea1TDsKQAyw/XA04EscnqvtZ3qZIqJJ5HAYtFT4H9eWlR7AJVGhurBOl1VkmMy4
QYjvnpSvt3ZX6eJQm3YfD3dCyPF0lArcapsFeB4qfU3qQJ+oEsKKjG93Jqkma4Ly
tKtQVRiq/G6g81DcTGGyrOgmEL/KySVTyHw+S1ukbJQJRfDSsIRH4UMNtYJFdi5i
FxIuJ+wE8uSmEUU/sYiCXOy4O/AWb17r0/jlh/h7f6UaHmgG5J85VRxbhhfTsBQA
6DOKZ15yvJTWJpa5n86AJFPHqC9f0+cUUtASxNL3zCIJUMyBuhLr1UTwlFRXyYFS
L2IJohyM2T3VTjZFN8BP2rcG0/lnCwNfdUDW5Y5clBDA5khAJOD/hSoDZD7yACP2
p3PaYpAXeczUQ9VEvhAB
=WjqH
-----END PGP SIGNATURE-----