mirror of
https://git.pvv.ntnu.no/Drift/pvv-nixos-config.git
synced 2026-02-04 09:10:01 +01:00
modules/rsync-pull-targets: fix multiple pull targets with same user
This commit is contained in:
@@ -124,16 +124,22 @@ in
|
||||
services.openssh.enable = true;
|
||||
users.users = lib.pipe cfg.locations [
|
||||
(lib.filterAttrs (_: value: value.enable))
|
||||
(lib.mapAttrs' (_: { user, location, rrsyncPackage, rrsyncArgs, authorizedKeysAttrs, publicKey, ... }: let
|
||||
rrsyncArgString = lib.cli.toCommandLineShellGNU {
|
||||
isLong = _: false;
|
||||
} rrsyncArgs;
|
||||
# TODO: handle " in location
|
||||
in {
|
||||
name = user;
|
||||
value.openssh.authorizedKeys.keys = [
|
||||
"command=\"${lib.getExe rrsyncPackage} ${rrsyncArgString} ${location}\",${lib.concatStringsSep "," authorizedKeysAttrs} ${publicKey}"
|
||||
];
|
||||
|
||||
lib.attrValues
|
||||
|
||||
# Index locations by SSH user
|
||||
(lib.foldl (acc: location: acc // {
|
||||
${location.user} = (acc.${location.user} or [ ]) ++ [ location ];
|
||||
}) { })
|
||||
|
||||
(lib.mapAttrs (_name: locations: {
|
||||
openssh.authorizedKeys.keys = map ({ user, location, rrsyncPackage, rrsyncArgs, authorizedKeysAttrs, publicKey, ... }: let
|
||||
rrsyncArgString = lib.cli.toCommandLineShellGNU {
|
||||
isLong = _: false;
|
||||
} rrsyncArgs;
|
||||
# TODO: handle " in location
|
||||
in "command=\"${lib.getExe rrsyncPackage} ${rrsyncArgString} ${location}\",${lib.concatStringsSep "," authorizedKeysAttrs} ${publicKey}"
|
||||
) locations;
|
||||
}))
|
||||
];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user