]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/commitdiff
rngd: Mix-in RDRAND and reload for HWRNGs added at runtime.
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 1 Feb 2014 15:46:22 +0000 (16:46 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 1 Feb 2014 15:46:22 +0000 (16:46 +0100)
config/rootfiles/common/udev
config/udev/90-hwrng.rules [new file with mode: 0644]
lfs/udev
src/initscripts/init.d/rngd

index 3b9979b2e8972bcf03db3fb919e17c91b4ed260e..bc1cdaa1ff3ba1ceae448a37f13ed5b8314b6e85 100644 (file)
@@ -51,6 +51,7 @@ lib/udev
 #lib/udev/rules.d/78-sound-card.rules
 #lib/udev/rules.d/80-drivers.rules
 #lib/udev/rules.d/80-net-name-slot.rules
+#lib/udev/rules.d/90-hwrng.rules
 #lib/udev/rules.d/95-udev-late.rules
 #lib/udev/rules.d/99-codel.rules
 #lib/udev/scsi_id
diff --git a/config/udev/90-hwrng.rules b/config/udev/90-hwrng.rules
new file mode 100644 (file)
index 0000000..a939790
--- /dev/null
@@ -0,0 +1 @@
+ACTION=="add|remove", KERNEL=="hw_random", RUN+="/etc/rc.d/init.d/rngd udev-event"
index d0349936a18e58bcf1b8c9d6d8038dedf3c2d8dc..fdf8bf296876d4e03df7cc30910cab281de1cc93 100644 (file)
--- a/lfs/udev
+++ b/lfs/udev
@@ -108,6 +108,10 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        install -v -m 644 $(DIR_SRC)/config/udev/25-alsa.rules \
                /lib/udev/rules.d
 
+       # Install hwrng rules.
+       install -v -m 644 $(DIR_SRC)/config/udev/90-hwrng.rules \
+               /lib/udev/rules.d
+
        # Install codel rules.
        install -v -m 644 $(DIR_SRC)/config/udev/99-codel.rules \
                /lib/udev/rules.d
index cc1c10d7cce5b73fdaceb24e56468f4fa4312de0..22437fdc4e5c2b4a9603d18a3f4d1fb521496c2a 100644 (file)
 . /etc/sysconfig/rc
 . ${rc_functions}
 
+function has_rdrand() {
+       grep -q "rdrand" /proc/cpuinfo
+}
+
+function has_hwrng() {
+       [ -e "/dev/hwrng" ]
+}
+
 case "${1}" in
        start)
-               if [ ! -e "/dev/hwrng" ]; then
-                       boot_mesg "No Hardware Random Number Generator found..." ${WARNING}
+               if ! has_hwrng && ! has_rdrand; then
+                       boot_mesg "No Hardware Random Number Generator found..."
                        echo_warning
                        exit 0
                fi
 
                boot_mesg "Starting Random Number Generator Daemon..."
-               loadproc /usr/sbin/rngd
+               loadproc /usr/sbin/rngd --no-tpm=1
                ;;
 
        stop)
@@ -38,6 +46,10 @@ case "${1}" in
                statusproc /usr/sbin/rngd
                ;;
 
+       udev-event)
+               $0 restart &>/dev/null
+               ;;
+
        *)
                echo "Usage: ${0} {start|stop|restart|status}"
                exit 1