forked from mirrors/nixpkgs
/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);
|
||||
|
||||
knownHostsFile = pkgs.runCommand "ssh_known_hosts" {} ''
|
||||
touch "$out"
|
||||
${flip concatMapStrings knownHosts (h: ''
|
||||
pubkeyfile=${builtins.toFile "host.pub" (if h.publicKey == null then readFile h.publicKeyFile else h.publicKey)}
|
||||
${pkgs.gnused}/bin/sed 's/^/${concatStringsSep "," h.hostNames} /' $pubkeyfile >> "$out"
|
||||
'')}
|
||||
'';
|
||||
knownHostsText = flip (concatMapStringsSep "\n") knownHosts
|
||||
(h:
|
||||
concatStringsSep "," h.hostNames + " "
|
||||
+ (if h.publicKey != null then h.publicKey else readFile h.publicKeyFile)
|
||||
);
|
||||
|
||||
userOptions = {
|
||||
|
||||
|
@ -301,7 +299,7 @@ in
|
|||
{ source = "${cfgc.package}/etc/ssh/moduli";
|
||||
target = "ssh/moduli";
|
||||
}
|
||||
{ source = knownHostsFile;
|
||||
{ text = knownHostsText;
|
||||
target = "ssh/ssh_known_hosts";
|
||||
}
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue