···
cfg = config.services.userdbd;
7
-
options.services.userdbd.enable = lib.mkEnableOption ''
8
-
the systemd JSON user/group record lookup service
7
+
options.services.userdbd = {
8
+
enable = lib.mkEnableOption ''
9
+
the systemd JSON user/group record lookup service
12
+
enableSSHSupport = lib.mkEnableOption ''
13
+
exposing OpenSSH public keys defined in userdb. Be aware that this
14
+
enables modifying public keys at runtime, either by users managed by
15
+
{option}`services.homed`, or globally via drop-in files
config = lib.mkIf cfg.enable {
20
+
assertions = lib.singleton {
21
+
assertion = cfg.enableSSHSupport -> config.security.enableWrappers;
22
+
message = "OpenSSH userdb integration requires security wrappers.";
systemd.additionalUpstreamSystemUnits = [
"systemd-userdbd.service"
systemd.sockets.systemd-userdbd.wantedBy = [ "sockets.target" ];
32
+
# OpenSSH requires AuthorizedKeysCommand to be owned only by root.
33
+
# Referencing `userdbctl` directly from the Nix store won't work, as
34
+
# `/nix/store` is owned by the `nixbld` group.
35
+
security.wrappers = lib.mkIf cfg.enableSSHSupport {
39
+
source = lib.getExe' config.systemd.package "userdbctl";
43
+
services.openssh = lib.mkIf cfg.enableSSHSupport {
44
+
authorizedKeysCommand = "/run/wrappers/bin/userdbctl ssh-authorized-keys %u";
45
+
authorizedKeysCommandUser = "root";