-
-
Notifications
You must be signed in to change notification settings - Fork 492
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: move pam
configuration to sudo_local
#1344
base: master
Are you sure you want to change the base?
Conversation
53abaae
to
9646928
Compare
I was just bitten again by the latest os update reverting this option - so is there anything I can do to move this forward? |
I'm in the process of fixing this PR :) Aiming to merge it today 😄 |
9646928
to
4052178
Compare
@Mic92 can you test this PR again? |
@dwt @pitkling @takoverflow if you could also test this PR that'd be great |
Great to see this moving forward! Would it be possible to add a setting like {
environment.etc."pam.d/sudo_local" = {
enable = true;
text = ''
auth optional ${lib.getLib pkgs.pam-reattach}/lib/pam/pam_reattach.so
auth sufficient ${lib.getLib pkgs.pam-watchid}/lib/pam/pam_watchid.so
auth sufficient pam_tid.so
'';
} (note that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latter two commits should have Co-authored-by: Andrew Lubawy <[email protected]>
trailers to preserve attribution (possibly @Mic92 too? I didn’t look at the previous state of this PR). Otherwise LGTM in principle with some comments.
(lib.optional cfg.enableSudoPamReattach "auth optional ${pkgs.pam-reattach}/lib/pam/pam_reattach.so") | ||
++ (lib.optional cfg.enableSudoTouchIdAuth "auth sufficient pam_tid.so") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I’d prefer to trim the unnecessary alignment whitespace here, but it doesn’t matter.
survive across user sessions to work with PAM services that are tied to the | ||
bootstrap session. | ||
''; | ||
default = cfg.enableSudoTouchIdAuth; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I said in the previous PR I think we shouldn’t turn this on by default. It brings a third‐party PAM module into the sudo
chain which I don’t think we should be doing implicitly, and I think most users probably don’t need it. IIRC it relies on undocumented private APIs too.
``` | ||
auth sufficient pam_tid.so | ||
``` | ||
enableSudoPamReattach = lib.mkEnableOption "" // { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, this could be introduced as security.pam.services.sudo_local.reattach
.
example = false; | ||
}; | ||
|
||
enableSudoTouchIdAuth = lib.mkEnableOption "" // { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per the previous comment, since we’re adding more options and moving stuff around, this could be renamed to security.pam.services.sudo_local.touchIdAuth
to match the NixOS structure.
security.pam = { | ||
enable = lib.mkEnableOption "managing PAM with nix-darwin" // { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take it this is to accommodate users that want a custom sudo_local
file?
I’m wondering if this should be security.pam.services.sudo_local.enable
. That’s not an option that exists in NixOS, but it brings us closer to NixOS’s structure for security.pam.*
. We’re just managing the sudo_local
configuration rather than PAM as a whole here.
I might prefer something like @mirkolenz’s solution, which could also increase NixOS compatibility: we could have security.pam.services.sudo_local.text
which is lib.types.lines
and populate it with our settings by default; users who want extra configuration could use lib.mkAfter
; users who want to replace the entire configuration could override it completely. If someone really wants a totally unmanaged sudo_local
file, we could make environment.etc."pam.d/sudo_local".enable
just a lib.mkDefault
so that they can disable it directly. (Or we could keep the non‐standard .enable
, but I think in the presence of .text
it would be niche enough that it’s fine to expect someone to toggle the file like that.)
(if not for .text
, we could make it security.pam.services.sudo.*
since we’re effectively extending the sudo
configuration. But if we add .text
– which seems nicer than .enable
here – then we should make sure it’s sudo_local
, as security.pam.services.sudo_local.text
will not be able to overwrite the entire PAM sudo
service configuration, as a NixOS user or configuration might expect.)
@Enzime: Works great for me (tested on a current Sequoia installation), thanks for continuing this. That said, I agree with @emilazy's review comments. Especially that |
Also tested the current implementation, no issues. |
Supersedes #1020, #591, #787 and #662
Closes #784 and #985