Skip to content
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

Add options to configure idmapd.conf #97616

Closed
justinlovinger opened this issue Sep 10, 2020 · 10 comments · Fixed by #98980
Closed

Add options to configure idmapd.conf #97616

justinlovinger opened this issue Sep 10, 2020 · 10 comments · Fixed by #98980
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS

Comments

@justinlovinger
Copy link
Contributor

Issue description

If you want root access to an NFS share secured with Kerberos, you need to modify the default idmapd.conf . Currently, I override the idmapd.conf source, because NixOS has no options to modify idmapd.conf :

environment.etc."idmapd.conf".source = let
  nfsStateDir = "/var/lib/nfs";
  rpcMountpoint = "${nfsStateDir}/rpc_pipefs";
in lib.mkForce (pkgs.writeText "idmapd.conf" ''
  [General]
  Pipefs-Directory = ${rpcMountpoint}
  ${lib.optionalString (config.networking.domain != null)
    "Domain = ${config.networking.domain}"}

  [Mapping]
  Nobody-User = nobody
  Nobody-Group = nogroup

  [Translation]
  GSS-Methods = static,nsswitch

  [Static]
  root/[email protected] = root
'');

The text is mostly copied from the default NixOS idmapd.conf . The only changes are

-  Method = nsswitch
+  GSS-Methods = static,nsswitch
+
+  [Static]
+  root/[email protected] = root

This solution is brittle, and requires manual intervention if the default idmapd.conf ever changes. I'm not sure exactly what the NixOS options should look like, but there should be mechanisms to modify idmapd.conf in NixOS.

Technical details

  • system: "x86_64-linux"
  • host os: Linux 5.4.62, NixOS, 20.03.2882.51d115ac89d (Markhor)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.3.6
  • channels(root): "nixos-20.03.2882.51d115ac89d"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos
@veprbl veprbl added the 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS label Sep 10, 2020
@aanderse
Copy link
Member

@justinlovinger what about an option like this so you can easily override/append values as you see fit?

@justinlovinger
Copy link
Contributor Author

@justinlovinger what about an option like this so you can easily override/append values as you see fit?

That looks great. I'm a big fan of RFC 42 :) Just one question though. Can you remove an option, such as Translation.Method = null?

@aanderse
Copy link
Member

Good question. @infinisil can we bug you for some advice on how you can remove values from a settings option?

@infinisil
Copy link
Member

There's nothing builtin for that. The best that can be done is to just filter out null values during string generation. Though in INI's case, null is also a valid value in INI files, so that might not be a great idea. There is a PR that adds a way to "unset" values, though I haven't looked into it much.

@aanderse
Copy link
Member

Thanks for mentioning @infinisil!
@justinlovinger without the ability to remove values would this not work?

@justinlovinger
Copy link
Contributor Author

@aanderse I did a double-check on man idmapd.conf, and it looks like Method and GSS-Methods are actually separate, but related. GSS-Methods defaults to the value of Method. Also, the default value of Method is already nsswitch, so removing it in my configuration had no effect. On that note, we may consider removing Method = "nsswitch", as that is already the default. Regardless, your RFC 42 solution should work, even without the ability to remove values.

@aanderse
Copy link
Member

@justinlovinger are you interested in opening a PR? Feel free to use the branch I posted.

@justinlovinger
Copy link
Contributor Author

@justinlovinger are you interested in opening a PR? Feel free to use the branch I posted.

I can open a pull request. Just one question: is there a reason the option and variables are called imapd instead of idmapd?

@aanderse
Copy link
Member

Typo 🤷‍♂️

@justinlovinger
Copy link
Contributor Author

justinlovinger commented Sep 28, 2020

@aanderse pull request is up. I fixed the imapd typo and a syntax error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants