Skip to content

Commit 4efb432

Browse files
authored
Merge pull request NixOS#113850 from nbraud/rngd
nixos/rngd: Remove module entirely, leave an explanation
2 parents b3216e6 + 3c88820 commit 4efb432

File tree

5 files changed

+22
-62
lines changed

5 files changed

+22
-62
lines changed

nixos/doc/manual/installation/installing-virtualbox-guest.xml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,12 @@
8383
VirtualBox settings (Machine / Settings / Shared Folders, then click on the
8484
"Add" icon). Add the following to the
8585
<literal>/etc/nixos/configuration.nix</literal> to auto-mount them. If you do
86-
not add <literal>"nofail"</literal>, the system will not boot properly. The
87-
same goes for disabling <literal>rngd</literal> which is normally used to get
88-
randomness but this does not work in virtual machines.
86+
not add <literal>"nofail"</literal>, the system will not boot properly.
8987
</para>
9088

9189
<programlisting>
9290
{ config, pkgs, ...} :
9391
{
94-
security.rngd.enable = false; // otherwise vm will not boot
95-
...
96-
9792
fileSystems."/virtualboxshare" = {
9893
fsType = "vboxsf";
9994
device = "nameofthesharedfolder";

nixos/doc/manual/release-notes/rl-2105.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,15 @@ self: super:
509509
<varname>services.flashpolicyd</varname> module.
510510
</para>
511511
</listitem>
512+
<listitem>
513+
<para>
514+
The <literal>security.rngd</literal> module has been removed.
515+
It was disabled by default in 20.09 as it was functionally redundent
516+
with krngd in the linux kernel. It is not necessary for any device that the kernel recognises
517+
as an hardware RNG, as it will automatically run the krngd task to periodically collect random
518+
data from the device and mix it into the kernel's RNG.
519+
</para>
520+
</listitem>
512521
</itemizedlist>
513522
</section>
514523

nixos/modules/config/swap.nix

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,6 @@ in
185185
{ description = "Initialisation of swap device ${sw.device}";
186186
wantedBy = [ "${realDevice'}.swap" ];
187187
before = [ "${realDevice'}.swap" ];
188-
# If swap is encrypted, depending on rngd resolves a possible entropy starvation during boot
189-
after = mkIf (config.security.rngd.enable && sw.randomEncryption.enable) [ "rngd.service" ];
190188
path = [ pkgs.util-linux ] ++ optional sw.randomEncryption.enable pkgs.cryptsetup;
191189

192190
script =

nixos/modules/security/rngd.nix

Lines changed: 12 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,16 @@
1-
{ config, lib, pkgs, ... }:
2-
3-
with lib;
4-
1+
{ lib, ... }:
52
let
6-
cfg = config.security.rngd;
3+
removed = k: lib.mkRemovedOptionModule [ "security" "rngd" k ];
74
in
85
{
9-
options = {
10-
security.rngd = {
11-
enable = mkOption {
12-
type = types.bool;
13-
default = false;
14-
description = ''
15-
Whether to enable the rng daemon. Devices that the kernel recognises
16-
as entropy sources are handled automatically by krngd.
17-
'';
18-
};
19-
debug = mkOption {
20-
type = types.bool;
21-
default = false;
22-
description = "Whether to enable debug output (-d).";
23-
};
24-
};
25-
};
26-
27-
config = mkIf cfg.enable {
28-
systemd.services.rngd = {
29-
bindsTo = [ "dev-random.device" ];
30-
31-
after = [ "dev-random.device" ];
32-
33-
# Clean shutdown without DefaultDependencies
34-
conflicts = [ "shutdown.target" ];
35-
before = [
36-
"sysinit.target"
37-
"shutdown.target"
38-
];
39-
40-
description = "Hardware RNG Entropy Gatherer Daemon";
41-
42-
# rngd may have to start early to avoid entropy starvation during boot with encrypted swap
43-
unitConfig.DefaultDependencies = false;
44-
serviceConfig = {
45-
ExecStart = "${pkgs.rng-tools}/sbin/rngd -f"
46-
+ optionalString cfg.debug " -d";
47-
# PrivateTmp would introduce a circular dependency if /tmp is on tmpfs and swap is encrypted,
48-
# thus depending on rngd before swap, while swap depends on rngd to avoid entropy starvation.
49-
NoNewPrivileges = true;
50-
PrivateNetwork = true;
51-
ProtectSystem = "full";
52-
ProtectHome = true;
53-
};
54-
};
55-
};
6+
imports = [
7+
(removed "enable" ''
8+
rngd is not necessary for any device that the kernel recognises
9+
as an hardware RNG, as it will automatically run the krngd task
10+
to periodically collect random data from the device and mix it
11+
into the kernel's RNG.
12+
'')
13+
(removed "debug"
14+
"The rngd module was removed, so its debug option does nothing.")
15+
];
5616
}

nixos/modules/virtualisation/hyperv-guest.nix

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ in {
4040

4141
environment.systemPackages = [ config.boot.kernelPackages.hyperv-daemons.bin ];
4242

43-
security.rngd.enable = false;
44-
4543
# enable hotadding cpu/memory
4644
services.udev.packages = lib.singleton (pkgs.writeTextFile {
4745
name = "hyperv-cpu-and-memory-hotadd-udev-rules";

0 commit comments

Comments
 (0)