Skip to contentSkip to conversation

rng-tools: disable rngd daemon start by default

PATCH In review Xiangyu Chen 2 participants 2 messages Mar 15, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rng-tools: disable rngd daemon start by default

From: Xiangyu Chen <[email protected]>

Since we removed the openssh dependency[1] on rng-tools, there are no package requiring rng-tools in oe-core, meta-oe, meta-virt, one of the reasons for keeping rng-tools build into the image is that it can be used to test[2], so adding an option to disable rngd daemon by default since the linux-5.6 and later /dev/random won't block anymore[3].

By default, this option set to 0 to disable the rngd start, when this option set to 1, the rngd daemon would start normally (if someone really need it).

Reference:
[1] https://git.openembedded.org/openembedded-core/commit/?id=868dfb46d96a27ec9041cb902fb769330277257d
[2] https://linux.die.net/man/1/rngtest
[3] https://github.com/torvalds/linux/commit/30c08efec8884fb106b8e57094baa51bb4c44e32

---
 .../rng-tools/rng-tools/default               |  1 +
 meta/recipes-support/rng-tools/rng-tools/init | 42 ++++++++++++-------
 .../rng-tools/rng-tools/rng-tools.service     |  2 +-
 3 files changed, 29 insertions(+), 16 deletions(-)
meta/recipes-support/rng-tools/rng-tools/default +1 -0
index b9f8e03635..02659742fd 100644
@@ -1 +1,2 @@
 EXTRA_ARGS="-r /dev/hwrng"
+RUN_RNGD=0
meta/recipes-support/rng-tools/rng-tools/init +27 -15

54 lines not on this page · raw message

meta/recipes-support/rng-tools/rng-tools/rng-tools.service +1 -1
index 5ae2fba215..be88ab125a 100644
@@ -7,7 +7,7 @@ ConditionVirtualization=!container
 
 [Service]
 EnvironmentFile=-@SYSCONFDIR@/default/rng-tools
-ExecStart=@SBINDIR@/rngd -f $EXTRA_ARGS
+ExecStart=/bin/sh -c '[ x$RUN_RNGD != x1 ] || exec @SBINDIR@/rngd -f $EXTRA_ARGS '
 CapabilityBoundingSet=CAP_SYS_ADMIN
 IPAddressDeny=any
 LockPersonality=yes
Signature · 1 line
2.34.1
#1 lore raw

I don't think adding a custom variable is the correct approach.

If you want rngtest or other supplementary tools in the image, but don't want to install and start rngd, then rngtest should be packaged and installed separately via appropriate FILES/PACKAGES assignments in the recipe. Can you make it work that way please?

Alex

Quoted 114 lines · Xiangyu Chen

From: Xiangyu Chen <[email protected]>

Since we removed the openssh dependency[1] on rng-tools, there are no package requiring rng-tools in oe-core, meta-oe, meta-virt, one of the reasons for keeping rng-tools build into the image is that it can be used to test[2], so adding an option to disable rngd daemon by default since the linux-5.6 and later /dev/random won't block anymore[3].

By default, this option set to 0 to disable the rngd start, when this option set to 1, the rngd daemon would start normally (if someone really need it).

Reference:
[1] https://git.openembedded.org/openembedded-core/commit/?id=868dfb46d96a27ec9041cb902fb769330277257d
[2] https://linux.die.net/man/1/rngtest
[3] https://github.com/torvalds/linux/commit/30c08efec8884fb106b8e57094baa51bb4c44e32

---
 .../rng-tools/rng-tools/default               |  1 +
 meta/recipes-support/rng-tools/rng-tools/init | 42 ++++++++++++-------
 .../rng-tools/rng-tools/rng-tools.service     |  2 +-
 3 files changed, 29 insertions(+), 16 deletions(-)
meta/recipes-support/rng-tools/rng-tools/default +1 -0
index b9f8e03635..02659742fd 100644
@@ -1 +1,2 @@
 EXTRA_ARGS="-r /dev/hwrng"
+RUN_RNGD=0
meta/recipes-support/rng-tools/rng-tools/init +27 -15
index 13f0ecd37c..6c8ce00104 100644
@@ -12,27 +12,39 @@ test -x "$rngd" || exit 1
 
 case "$1" in
   start)
-    echo -n "Starting random number generator daemon"
-    start-stop-daemon -S -q -x $rngd -- $EXTRA_ARGS
-    echo "."
+    if [ $RUN_RNGD = 1 ]
+    then
+        echo -n "Starting random number generator daemon"
+        start-stop-daemon -S -q -x $rngd -- $EXTRA_ARGS
+        echo "."
+    fi
     ;;
   stop)
-    echo -n "Stopping random number generator daemon"
-    start-stop-daemon -K -q -n rngd
-    echo "."
+    if [ $RUN_RNGD = 1 ]
+    then
+        echo -n "Stopping random number generator daemon"
+        start-stop-daemon -K -q -n rngd
+        echo "."
+    fi
     ;;
   reload|force-reload)
-    echo -n "Signalling rng daemon restart"
-    start-stop-daemon -K -q -s 1 -x $rngd
-    start-stop-daemon -K -q -s 1 -x $rngd
+    if [ $RUN_RNGD = 1 ]
+    then
+        echo -n "Signalling rng daemon restart"
+        start-stop-daemon -K -q -s 1 -x $rngd
+        start-stop-daemon -K -q -s 1 -x $rngd
+    fi
     ;;
   restart)
-    echo -n "Stopping random number generator daemon"
-    start-stop-daemon -K -q -n rngd
-    echo "."
-    echo -n "Starting random number generator daemon"
-    start-stop-daemon -S -q -x $rngd -- $EXTRA_ARGS
-    echo "."
+    if [ $RUN_RNGD = 1 ]
+    then
+        echo -n "Stopping random number generator daemon"
+        start-stop-daemon -K -q -n rngd
+        echo "."
+        echo -n "Starting random number generator daemon"
+        start-stop-daemon -S -q -x $rngd -- $EXTRA_ARGS
+        echo "."
+    fi
     ;;
   *)
     echo "Usage: @SYSCONFDIR@/init.d/rng-tools {start|stop|reload|restart|force-reload}"
meta/recipes-support/rng-tools/rng-tools/rng-tools.service +1 -2
index 5ae2fba215..be88ab125a 100644
@@ -7,7 +7,7 @@ ConditionVirtualization=!container
 
 [Service]
 EnvironmentFile=-@SYSCONFDIR@/default/rng-tools
-ExecStart=@SBINDIR@/rngd -f $EXTRA_ARGS
+ExecStart=/bin/sh -c '[ x$RUN_RNGD != x1 ] || exec @SBINDIR@/rngd -f $EXTRA_ARGS '
 CapabilityBoundingSet=CAP_SYS_ADMIN
 IPAddressDeny=any
 LockPersonality=yes
--

2.34.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#178518): https://lists.openembedded.org/g/openembedded-core/message/178518
Mute This Topic: https://lists.openembedded.org/mt/97619573/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-