git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #97726 from NickHu/pam_gnupg

pam: add support for pam_gnupg

commit921287e7f07cda020efe341cc6f6f6ab58c23722 authorNick Hu <me@nickhu.co.uk> dateMon 26 Oct 2020, 15:27 (6 years ago) parentfdcd714948e05b
1 file changed+45
nixos/modules/security/pam.nix+45
nixos/modules/security/pam.nix+45
@@ -318,6 +318,42 @@ let
318318 '';
319319 };
320320
321+ gnupg = {
322+ enable = mkOption {
323+ type = types.bool;
324+ default = false;
325+ description = ''
326+ If enabled, pam_gnupg will attempt to automatically unlock the
327+ user's GPG keys with the login password via
328+ <command>gpg-agent</command>. The keygrips of all keys to be
329+ unlocked should be written to <filename>~/.pam-gnupg</filename>,
330+ and can be queried with <command>gpg -K --with-keygrip</command>.
331+ Presetting passphrases must be enabled by adding
332+ <literal>allow-preset-passphrase</literal> in
333+ <filename>~/.gnupg/gpg-agent.conf</filename>.
334+ '';
335+ };
336+
337+ noAutostart = mkOption {
338+ type = types.bool;
339+ default = false;
340+ description = ''
341+ Don't start <command>gpg-agent</command> if it is not running.
342+ Useful in conjunction with starting <command>gpg-agent</command> as
343+ a systemd user service.
344+ '';
345+ };
346+
347+ storeOnly = mkOption {
348+ type = types.bool;
349+ default = false;
350+ description = ''
351+ Don't send the password immediately after login, but store for PAM
352+ <literal>session</literal>.
353+ '';
354+ };
355+ };
356+
321357 text = mkOption {
322358 type = types.nullOr types.lines;
323359 description = "Contents of the PAM service file.";
@@ -386,6 +422,7 @@ let
386422 || cfg.enableKwallet
387423 || cfg.enableGnomeKeyring
388424 || cfg.googleAuthenticator.enable
425+ || cfg.gnupg.enable
389426 || cfg.duoSecurity.enable)) ''
390427 auth required pam_unix.so ${optionalString cfg.allowNullPassword "nullok"} ${optionalString cfg.nodelay "nodelay"} likeauth
391428 ${optionalString config.security.pam.enableEcryptfs
@@ -397,6 +434,10 @@ let
397434 " kwalletd=${pkgs.kdeFrameworks.kwallet.bin}/bin/kwalletd5")}
398435 ${optionalString cfg.enableGnomeKeyring
399436 "auth optional ${pkgs.gnome3.gnome-keyring}/lib/security/pam_gnome_keyring.so"}
437+ ${optionalString cfg.gnupg.enable
438+ "auth optional ${pkgs.pam_gnupg}/lib/security/pam_gnupg.so"
439+ + optionalString cfg.gnupg.storeOnly " store-only"
440+ }
400441 ${optionalString cfg.googleAuthenticator.enable
401442 "auth required ${pkgs.googleAuthenticator}/lib/security/pam_google_authenticator.so no_increment_hotp"}
402443 ${optionalString cfg.duoSecurity.enable
@@ -472,6 +513,10 @@ let
472513 " kwalletd=${pkgs.kdeFrameworks.kwallet.bin}/bin/kwalletd5")}
473514 ${optionalString (cfg.enableGnomeKeyring)
474515 "session optional ${pkgs.gnome3.gnome-keyring}/lib/security/pam_gnome_keyring.so auto_start"}
516+ ${optionalString cfg.gnupg.enable
517+ "session optional ${pkgs.pam_gnupg}/lib/security/pam_gnupg.so"
518+ + optionalString cfg.gnupg.noAutostart " no-autostart"
519+ }
475520 ${optionalString (config.virtualisation.lxc.lxcfs.enable)
476521 "session optional ${pkgs.lxc}/lib/security/pam_cgfs.so -c all"}
477522 '');