Repository navigation
nixos: replace 'text' with structured PAM rules - #420889
Conversation
a16cbd8 to
44e32d0
Compare
|
Merge conflict :p |
44e32d0 to
7df5623
Compare
7df5623 to
3db2e0b
Compare
|
Thank you, replacing strings with structured data is always welcome. But this is a rather large change, so it's hard to review. Would it be possible to include tests beyond |
3db2e0b to
43edd00
Compare
|
I have pushed a second branch ( For comparing the generated files, I often do something like this: Some changes are expected, since the structured rules produce PAM files with a different format than the manual |
43edd00 to
4621d3a
Compare
4621d3a to
bca9f2e
Compare
|
Rebased to resolve merge conflicts. @l0b0 Do you have enough now to give this a review? |
l0b0
left a comment
There was a problem hiding this comment.
I've only skimmed the rule translations, but this looks good. IIUC the main functional change is pulling autoOrderRules out verbatim.
The autoOrderRules implementation is a bit hard to understand with the combination of flip and pipe, but that was already in the original code.
|
I've taken the liberty to link this in Matrix. |
4cc528b to
9bbd0dd
Compare
This function is used to convert an ordered list of rules into an attrset of rules with reasonable 'order' values. This reduces boilerplate to define 'order' and makes it simple to switch how ordering is managed in the future.
9bbd0dd to
584fe70
Compare
Several modules define whole PAM service rule stacks by overwriting the default value of the 'text' option. Instead, we disable useDefaultRules for these services and declare a new set of rules using the 'rules' option. This option is considered experimental and hidden from users, but it is supported for use within nixpkgs.
584fe70 to
4b86499
Compare
|
There was a problem hiding this comment.
After my code-only review last time, I rebuilt all 3 desktop/laptop and 6 server machines that include gdm, fprintd, and vsftpd at least. Once with nixos-unstable and once with this branch rebased on it and diffed all of /etc/pam.d.
All changes were
- whitespace
- using absolute store paths for pam modules.
- autorder comments.
Except for gdm-fingerprint where the file is now absent if fprintd is disabled, which makes sense. from the diff (gdm-fingerprint vs gdm-fingerprint.text in the mkIf).
Also ran the following pam-related vm-tests for good measure:
nom-build --keep-going \
-A nixosTests.pam-file-contents \
-A nixosTests.pam-lastlog \
-A nixosTests.pam-oath-login \
-A nixosTests.pam-pgsql \
-A nixosTests.pam-u2f \
-A nixosTests.pam-u2f-polkit \
-A nixosTests.pam-ussh \
-A nixosTests.pam-zfs-key \
-A nixosTests.slurm-pam \
-A nixosTests.ssh-agent-auth \
-A nixosTests.google-oslogin \
-A nixosTests.auth-mysql \
-A nixosTests.sssd-ldap \
-A nixosTests.sssd-legacy-config \
-A nixosTests.kanidm \
-A nixosTests.fscrypt \
-A nixosTests.systemd-homed \
-A nixosTests.openssh
google-oslogin and pam-zfs-key failed, but they did so on my merge base (4c1018d) as well.
Looks safe, fingers crossed 🤞
5aa9012
|
The commit 4b86499 (which is a part of this PR) gives an evaluation error when AppArmor is enabled. Should I report here or create an issue? |
|
@catuhana Thanks for reporting: |
… service in ly - Replace manual pam.services.ly-autologin with services.displayManager.autoLogin - Set defaultSession = "niri" via services.displayManager - ly v1.3.0 added native auto-login support [1][2] [1]: NixOS/nixpkgs#473013 [2]: NixOS/nixpkgs#420889
… service in ly - Replace manual pam.services.ly-autologin with services.displayManager.autoLogin - Set defaultSession = "niri" via services.displayManager - ly v1.3.0 added native auto-login support [1][2] [1]: NixOS/nixpkgs#473013 [2]: NixOS/nixpkgs#420889
Commit 5aa9012 (nixos: replace 'text' with structured PAM rules (NixOS#420889), 2026-04-14) resulted in the vsftpd module no longer creating a PAM module, and therefore configurations relying on `cfg.localUsers` stopped permitting logins unless the PAM module was being set up by other configuration. In the absence of a better fix, document this change of behaviour as a regression. Per the discussion at [0], provide a mechanims to restore the previous behaviour, but with the caveat that this may be insecure. I'd prefer more useful advice, but if I had a better understanding of NixOS's PAM configuration and how it interacts with vsftpd, I'd just be providing the better fix in the first place. [0]: NixOS#515531 (comment)
Commit 5aa9012 (nixos: replace 'text' with structured PAM rules (NixOS#420889), 2026-04-14) resulted in the vsftpd module no longer creating a PAM module, and therefore configurations relying on `cfg.localUsers` stopped permitting logins unless the PAM module was being set up by other configuration. In the absence of a better fix, document this change of behaviour as a regression. Per the discussion at [0], provide a mechanims to restore the previous behaviour, but with the caveat that this may be insecure. I'd prefer more useful advice, but if I had a better understanding of NixOS's PAM configuration and how it interacts with vsftpd, I'd just be providing the better fix in the first place. [0]: NixOS#515531 (comment) (cherry picked from commit 93699b8)
Commit 5aa9012 (nixos: replace 'text' with structured PAM rules (NixOS#420889), 2026-04-14) resulted in the vsftpd module no longer creating a PAM module, and therefore configurations relying on `cfg.localUsers` stopped permitting logins unless the PAM module was being set up by other configuration. In the absence of a better fix, document this change of behaviour as a regression. Per the discussion at [0], provide a mechanims to restore the previous behaviour, but with the caveat that this may be insecure. I'd prefer more useful advice, but if I had a better understanding of NixOS's PAM configuration and how it interacts with vsftpd, I'd just be providing the better fix in the first place. [0]: NixOS#515531 (comment)
Commit 5aa9012 (nixos: replace 'text' with structured PAM rules (NixOS#420889), 2026-04-14) resulted in the vsftpd module no longer creating a PAM module, and therefore configurations relying on `cfg.localUsers` stopped permitting logins unless the PAM module was being set up by other configuration. In the absence of a better fix, document this change of behaviour as a regression. Per the discussion at [0], provide a mechanims to restore the previous behaviour, but with the caveat that this may be insecure. I'd prefer more useful advice, but if I had a better understanding of NixOS's PAM configuration and how it interacts with vsftpd, I'd just be providing the better fix in the first place. [0]: NixOS#515531 (comment)
Replaces most of the nixpkgs usages of the
textoption to define PAM service rules with the newrulesoption introduced in #255547. (There's one moretextusage which is removed in #420885.) See commit descriptions for details.This incidentally fixes a bug where the
gdm-fingerprintandvsftpdPAM services are created with an invalid set of default rules when some (but not all) of the conditions are met to enable them.How this fits into the PAM refactoring plan:
rulesinterface, using these in-tree rules as test casestextoptionpam.nixinto modules that contributerulesThings done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truepam-file-contentsnix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.