/etc/ssh/ssh_known_hosts: refactor and fix #5612
Generating the file was refactored to be completely in nix. Functionally it should create the same content as before, only adding the newlines. CC recent updaters: @aszlig, @rickynils.
This commit is contained in:
parent
e98a443e71
commit
72d2d59cd4
@ -17,13 +17,11 @@ let
|
|||||||
|
|
||||||
knownHosts = map (h: getAttr h cfg.knownHosts) (attrNames cfg.knownHosts);
|
knownHosts = map (h: getAttr h cfg.knownHosts) (attrNames cfg.knownHosts);
|
||||||
|
|
||||||
knownHostsFile = pkgs.runCommand "ssh_known_hosts" {} ''
|
knownHostsText = flip (concatMapStringsSep "\n") knownHosts
|
||||||
touch "$out"
|
(h:
|
||||||
${flip concatMapStrings knownHosts (h: ''
|
concatStringsSep "," h.hostNames + " "
|
||||||
pubkeyfile=${builtins.toFile "host.pub" (if h.publicKey == null then readFile h.publicKeyFile else h.publicKey)}
|
+ (if h.publicKey != null then h.publicKey else readFile h.publicKeyFile)
|
||||||
${pkgs.gnused}/bin/sed 's/^/${concatStringsSep "," h.hostNames} /' $pubkeyfile >> "$out"
|
);
|
||||||
'')}
|
|
||||||
'';
|
|
||||||
|
|
||||||
userOptions = {
|
userOptions = {
|
||||||
|
|
||||||
@ -301,7 +299,7 @@ in
|
|||||||
{ source = "${cfgc.package}/etc/ssh/moduli";
|
{ source = "${cfgc.package}/etc/ssh/moduli";
|
||||||
target = "ssh/moduli";
|
target = "ssh/moduli";
|
||||||
}
|
}
|
||||||
{ source = knownHostsFile;
|
{ text = knownHostsText;
|
||||||
target = "ssh/ssh_known_hosts";
|
target = "ssh/ssh_known_hosts";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user