-
-
Notifications
You must be signed in to change notification settings - Fork 457
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 #1020
base: master
Are you sure you want to change the base?
Conversation
Thanks! This is definitely the direction I want to go, but we need to keep support for macOS < 14. That means that ensuring the |
Good call on the support for older versions and older nix-darwin support. What do you think of the recent changes? I added back an activation script like the old one which will check for the old implementation and delete it using
Otherwise, if all For users on macOS >=14, the entire thing will just be managed through |
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.
Sorry, it took so long to getting around to reviewing this PR
Let us know if you're still interested on working on this PR
{ | ||
environment.etc."pam.d/sudo_local" = { | ||
enable = isPamEnabled; | ||
text = lib.strings.concatStringsSep "\n" [ |
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.
text = lib.strings.concatStringsSep "\n" [ | |
text = lib.concatLines [ |
(lib.optionalString cfg.enablePamReattach "auth optional ${pkgs.pam-reattach}/lib/pam/pam_reattach.so") | ||
(lib.optionalString 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.
(lib.optionalString cfg.enablePamReattach "auth optional ${pkgs.pam-reattach}/lib/pam/pam_reattach.so") | |
(lib.optionalString cfg.enableSudoTouchIdAuth "auth sufficient pam_tid.so") | |
(lib.mkIf cfg.enablePamReattach "auth optional ${pkgs.pam-reattach}/lib/pam/pam_reattach.so") | |
(lib.mkIf cfg.enableSudoTouchIdAuth "auth sufficient pam_tid.so") |
I think this will mean the output file won't have blank lines in it
# NOTE: this can be removed at some point when support for older versions are dropped | ||
# Always clear out older implementation if it exists | ||
if grep '${deprecatedOption}' ${file} > /dev/null; then | ||
${sed} -i '/${option}/d' ${file} |
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.
${sed} -i '/${option}/d' ${file} | |
${sed} -i '/${deprecatedOption}/d' ${file} |
file = "/etc/pam.d/sudo"; | ||
option = "security.pam.enableSudoTouchIdAuth"; | ||
file = "/etc/pam.d/sudo"; | ||
option = "security.pam"; |
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.
option = "security.pam"; | |
marker = "security.pam.sudo_local"; |
fi | ||
# Check if include line is needed (macOS < 14) | ||
if ! grep 'sudo_local' ${file} > /dev/null; then | ||
${sed} -i '2iauth include sudo_local # nix-darwin: ${option}' ${file} |
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.
${sed} -i '2iauth include sudo_local # nix-darwin: ${option}' ${file} | |
${sed} -i '2iauth include sudo_local # nix-darwin: ${marker}' ${file} |
# for the existance of the line `auth include sudo_local`. This is included | ||
# in macOS Sonoma and later. If the line is not there already then `sed` will add it. | ||
# In those cases, the line will include the name of the option root (`security.pam`), | ||
# to make it easier to identify the line that should be deleted when the option is disabled. |
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.
It would be good to add a comment about what happens to the marker
line in /etc/pam.d/sudo
when upgrading to Sonoma
# in macOS Sonoma and later. If the line is not there already then `sed` will add it. | ||
# In those cases, the line will include the name of the option root (`security.pam`), | ||
# to make it easier to identify the line that should be deleted when the option is disabled. | ||
mkIncludeSudoLocalScript = isEnabled: |
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.
mkIncludeSudoLocalScript = isEnabled: |
This being a function seems unnecessary
${sed} -i '2i\ | ||
auth sufficient pam_tid.so # nix-darwin: ${option} | ||
' ${file} | ||
# NOTE: this can be removed at some point when support for older versions are dropped |
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.
# NOTE: this can be removed at some point when support for older versions are dropped | |
# REMOVEME when macOS 13 no longer supported |
I think we can skip the I also think that we shouldn’t include a marker on the |
The benefit of the marker would be that if a user uninstalled nix-darwin on a pre-Sonoma version we'd be able to restore it to closer to the original state, but either way is fine as As |
I think not being able to use touch ID very early in the user session is an acceptable failure mode if that’s all it is. |
@Enzime, thanks for taking the time to review. I should still be able to address the points you made and will request a re-review when I get that done. |
Addresses #985 and #787.
/etc/pam.d/sudo_local
environment.etc
pam_reattach
option to fix sudo TouchID in tmuxImplementation uses
environment.etc
to create the/etc/pam.d/sudo_local
file and adds thepkgs.pam-reattach
option provided in #662. Follows the comment by @emilazy to have nix-darwin manage the file entirely. If the file exists already, nix-darwin should handle it through the usual warning telling the user to rename the file tosudo_local.before-nix-darwin
. As identified by @lilyball in their comment, the symlink approach here shouldn't impact users since it doesn't touch the main/etc/pam.d/sudo
file. As long as/etc/pam.d/sudo
remains a regular file than this should work fine without disrupting sudo to applynix-darwin
configurations.I recognize this may be a duplicate PR given all the other open issues/PRs, but I haven't seen movement on them in a while. Feel free to close this if it's unnecessary.