-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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
nixos/pam: add serviceDefaults #340197
base: master
Are you sure you want to change the base?
nixos/pam: add serviceDefaults #340197
Conversation
d591f9d
to
7b48b53
Compare
Right now, this module is completely functional when used in my configuration, but is causing the manual build to fail due to some documentation shenanigans. |
@philiptaron What do think about this change, does it fit the pam module? I can see there being an argument against it as it is adds some complexity to the module configuration (only if opted into, but still), and there are some definitely some questions about how to best document the behavior (what is the best default text for the service modules?) |
dadc695
to
80d1bd1
Compare
80d1bd1
to
7ae3575
Compare
I admit, I'll have to do a lot of reading and learning to form a coherent opinion on the matter. I bet there are others in the Nix community that already have opinions and stances -- I'm just not one of them. Maybe write out something on discourse and encourage people who care about PAM and local machine authentication to take a look at this change? |
7ae3575
to
6026525
Compare
6026525
to
43101d9
Compare
I believe this can be achieved without this PR using { lib, ... }: {
security.pam.services = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule ({ config, ... }: {
# Disable unix auth by default if p11Auth is enabled
config.unixAuth = lib.mkIf config.p11Auth (lib.mkDefault false);
}));
};
} Can you confirm that this would work for you? Note that there could still be a reason to have the option from this PR regardless: To make it easier to discover, because the above is a bit obscure. However, if the above works, you can definitely use the same approach in the implementation. There's also efforts like @rhendric's #314058 to make this pattern easier, or the alternative of improving documentation and discoverability for the above pattern, which I'd weakly prefer to this PR though. |
@infinisil
Overall, though, I think the solution you provided is enough of a solution as to make this PR not necessary, but without some improvements to the pattern it is quite confusing (you are directly manipulating the module system's inner workings just to set a setting, which I feel should simply be an option exposed as with all other options). Edit:
In this specific case, there is maybe not an enormous impact, but making things like directly interacting with the module system a recommendation will have a lasting impact, as more and more modules will adopt that style of configuration, which I believe is antithetical to the second point mentioned above. I appreciate that edge cases are edge cases, but this PR is an example where a relatively small addition completely eradicates the need for that workaround, for anyone else. The direct cost is higher eval time (I presume) and more complex modules. NixOS will never be a simple or non technical solution, but being able allowing people to flexibly configure their systems with the simple ease of trivial nix expressions, I feel is overall a desirable goal. On the flip side allowing people to get further into the NixOS ecosystem without using anything but trivial nix expressions will likely lead to them hitting a cliff when they inevitably need/want to do something more powerful, and so there is a good argument that modules should remain concerned with automating aspects of the software/service (such as PAM config files), versus trying to cover the automate the configuration itself (which should be done with the nix language). So the indirect cost of such a change as proposed in this PR is not insignificant either. At the end of the day, I'm really not sure which direction the core NixOS team and the community feel the project should continue in, but there are aspects of both arguments with merit. |
By the way, there is precedent for this: this PR mimics how the |
Description of changes
This change addresses a shortcoming of how the PAM module handles setting up service configurations. As it stands now, if you enable certain modules, then that will affect all the default service configurations for all services, with no way of overriding it. This change adds configuration options to set the default option for all services, taking priority over the defaults given by the system configuration.
Example (
fprintd
):When you set
services.fprintd.enable = true
in your NixOS config, thefprintAuth
option is set totrue
by default for all services, making fingerprint the preferred PAM method for all services by default. If the goal is simply to disable fingerprint for one service, this is easily accomplished by updating the configuration for that particular service (i.e.security.pam.services.sudo.fprintAuth = false
for thesudo
service). If, on the other hand, one only want'sfprintAuth
to be set totrue
for one service, then short of manually setting it tofalse
for all the enabled services (infinite recursion cuts short any attempts at making this automatic), there is no way to change the default settings forfprintAuth
tofalse
.In other words, the only paradigm for setting PAM settings is opt-out, and opt-in is not possible.
With the changes in place, one simply sets
security.pam.serviceDefaults.fprintAuth = false;
Motive for how it was implemented
The way the
security.pam.serviceDefaults
option is implemented should guarantee complete backwards compatibility with old configurations, with the opt-out paradigm still being the default.Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-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.