Skip to content

Commit

Permalink
nixos/ecryptfs: init
Browse files Browse the repository at this point in the history
Currently, ecryptfs support is coupled to `security.pam.enableEcryptfs`, but one
might want to use ecryptfs without enabling the PAM functionality. This commit
splits it out into a `boot.supportedFilesystems` switch.
  • Loading branch information
edef1c authored and obadz committed Oct 20, 2017
1 parent 7867b50 commit ea35bc9
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions nixos/modules/module-list.nix
Expand Up @@ -696,6 +696,7 @@
./tasks/filesystems/bcachefs.nix
./tasks/filesystems/btrfs.nix
./tasks/filesystems/cifs.nix
./tasks/filesystems/ecryptfs.nix
./tasks/filesystems/exfat.nix
./tasks/filesystems/ext.nix
./tasks/filesystems/f2fs.nix
Expand Down
10 changes: 4 additions & 6 deletions nixos/modules/security/pam.nix
Expand Up @@ -486,19 +486,17 @@ in
++ optionals config.krb5.enable [pam_krb5 pam_ccreds]
++ optionals config.security.pam.enableOTPW [ pkgs.otpw ]
++ optionals config.security.pam.oath.enable [ pkgs.oathToolkit ]
++ optionals config.security.pam.enableU2F [ pkgs.pam_u2f ]
++ optionals config.security.pam.enableEcryptfs [ pkgs.ecryptfs ];
++ optionals config.security.pam.enableU2F [ pkgs.pam_u2f ];

boot.supportedFilesystems = optionals config.security.pam.enableEcryptfs [ "ecryptfs" ];

security.wrappers = {
unix_chkpwd = {
source = "${pkgs.pam}/sbin/unix_chkpwd.orig";
owner = "root";
setuid = true;
};
} // (if config.security.pam.enableEcryptfs then {
"mount.ecryptfs_private".source = "${pkgs.ecryptfs.out}/bin/mount.ecryptfs_private";
"umount.ecryptfs_private".source = "${pkgs.ecryptfs.out}/bin/umount.ecryptfs_private";
} else {});
};

environment.etc =
mapAttrsToList (n: v: makePAMService v) config.security.pam.services;
Expand Down
14 changes: 14 additions & 0 deletions nixos/modules/tasks/filesystems/ecryptfs.nix
@@ -0,0 +1,14 @@
{ config, lib, pkgs, ... }:
# TODO: make ecryptfs work in initramfs?

with lib;

{
config = mkIf (any (fs: fs == "ecryptfs") config.boot.supportedFilesystems) {
system.fsPackages = [ pkgs.ecryptfs ];
security.wrappers = {
"mount.ecryptfs_private".source = "${pkgs.ecryptfs.out}/bin/mount.ecryptfs_private";
"umount.ecryptfs_private".source = "${pkgs.ecryptfs.out}/bin/umount.ecryptfs_private";
};
};
}

0 comments on commit ea35bc9

Please sign in to comment.