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

WIP: Setuid interface #22532

Closed
wants to merge 6 commits into from
Closed

WIP: Setuid interface #22532

wants to merge 6 commits into from

Conversation

zimbatm
Copy link
Member

@zimbatm zimbatm commented Feb 7, 2017

Motivation for this change

Inspired by the discussion at http://lists.science.uu.nl/pipermail/nix-dev/2017-February/022698.html I had a look and it seems that each setuid program needs to be specified by hand.

On other operating systems, the packages install their setuid themselves. I believe the package is also best placed to know which binaries he installs should setuid.

This is just a proof of concept for now, let me know what you think!

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

Use a sane default. Who wants a setuid to "nobody"

TODO: Big fat warning for breaking backward-compatibility
Automatically install the setuid wrappers for all
environent.systemPackages that expose the "setuid" attribute.

That "setuid" attribute must be a list of programs that need to be
wrapped with the following attrset:

    { program
    , source ? ""
    , owner ? "root"
    , group ? "root"
    , setuid ? true
    , setgid ? false
    , permissions ? "u+rx,g+x,o+x"
    }
Guarantees that the wrapper is going to use the package's binary and not
some other one with the same name.
@mention-bot
Copy link

@zimbatm, thanks for your PR! By analyzing the history of the files in this pull request, we identified @edolstra, @7c6f434c and @nbp to be potential reviewers.

@edolstra
Copy link
Member

edolstra commented Feb 8, 2017

👍 on this.

One minor issue is the use of passthru, which is only available at evaluation time. So if you install a package by store path (e.g. environment.systemPackages = [ (builtins.storePath /nix/store/...) ]) then the setuid info is lost. This could be fixed by writing info about setuid programs to some file in $out/nix-support.

@zimbatm
Copy link
Member Author

zimbatm commented Feb 8, 2017

Alright, makes sense.

Playing devil's advocate on my own proposal but what do you think of having the package select the uid/gid of the setuid like I implemented? I'm a bit concerned that the uid/gid list is a system concern instead.

@7c6f434c
Copy link
Member

7c6f434c commented Feb 9, 2017

I would say that sometimes having some package available in the system path makes sense both with and without setuid wrapper (for different use cases), so not having a system-level override at all would be a step back.

As for UID/GID management, maybe recommending the default names and allocating new ids if the names are unknown would be OK, but that requires state, because such a user name could be added to the global list of UIDs later…

@7c6f434c
Copy link
Member

I think NixOS wrappers have gone in a slightly different direction…

@7c6f434c 7c6f434c closed this Apr 12, 2018
@zimbatm zimbatm deleted the setuid-interface branch April 12, 2018 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants