package/rng-tools: add systemd support for rngd
authorMaxim Mikityanskiy <maxtram95@gmail.com>
Mon, 19 Jan 2015 16:14:16 +0000 (18:14 +0200)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Wed, 22 Apr 2015 20:07:26 +0000 (22:07 +0200)
Add rngd.service for systemd. Also patch rngd with patch from Fedora to
ignore failure if no hwrng present:
https://bugzilla.redhat.com/show_bug.cgi?id=892178

[Thomas:
 - rename patch to the proper naming convention
 - add description and SoB to patch
 - install service file to /usr/lib/systemd and not /lib/systemd
 - use a relative symbolic link instead of an absolute one]

Signed-off-by: Maxim Mikityanskiy <maxtram95@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
package/rng-tools/0001-rngd-exit-code.patch [new file with mode: 0644]
package/rng-tools/rng-tools.mk
package/rng-tools/rngd.service [new file with mode: 0644]

diff --git a/package/rng-tools/0001-rngd-exit-code.patch b/package/rng-tools/0001-rngd-exit-code.patch
new file mode 100644 (file)
index 0000000..709e20c
--- /dev/null
@@ -0,0 +1,22 @@
+Exit with a special value when RNG modules are not available
+
+Instead of returning with an error, exit with a special value when the
+RNG kernel modules are not present in the kernel. This is not really a
+hard failure.
+
+Patch borrowed from Fedora, at
+http://pkgs.fedoraproject.org/cgit/rng-tools.git/tree/rngd-exit-code.patch.
+
+Signed-off-by: Maxim Mikityanskiy <maxtram95@gmail.com>
+
+--- a/rngd.c
++++ b/rngd.c
+@@ -319,7 +319,7 @@ int main(int argc, char **argv)
+                       message(LOG_DAEMON|LOG_ERR,
+                               "Maybe RNG device modules are not loaded\n");
+               }
+-              return 1;
++              return 66;
+       }
+       if (arguments->verbose) {
index 5b89656e02b26af84e8ef59ac9d70cc7331588a6..8648c4f878c5c6e86681439fd0e07f37496e6897 100644 (file)
@@ -21,4 +21,12 @@ else
 RNG_TOOLS_CONF_OPTS += --without-libgcrypt
 endif
 
+define RNG_TOOLS_INSTALL_INIT_SYSTEMD
+       $(INSTALL) -D -m 644 package/rng-tools/rngd.service \
+               $(TARGET_DIR)/usr/lib/systemd/system/rngd.service
+       mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
+       ln -fs ../../../../usr/lib/systemd/system/rngd.service \
+               $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/rngd.service
+endef
+
 $(eval $(autotools-package))
diff --git a/package/rng-tools/rngd.service b/package/rng-tools/rngd.service
new file mode 100644 (file)
index 0000000..3bdc4c1
--- /dev/null
@@ -0,0 +1,9 @@
+[Unit]
+Description=Hardware RNG Entropy Gatherer Daemon
+
+[Service]
+ExecStart=/usr/sbin/rngd -f
+SuccessExitStatus=66
+
+[Install]
+WantedBy=multi-user.target