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

nix-selinux-policy: init at 1.0 #46612

Closed
wants to merge 2 commits into from

Conversation

outergod
Copy link
Contributor

Motivation for this change

This basic SELinux policy for files in /nix is required to support running Nix in multi-user mode on SELinux-enabled systems.

To test the output of this derivation, run semodule -i result/nix.pp after building and restorecon -v on files in /nix to verify that the contexts defined in nix.fc are applied.

Required to fix NixOS/nix#2374.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • 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/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

@jtojnar
Copy link
Contributor

jtojnar commented Sep 13, 2018

Why not add it to Nix itself?

@outergod
Copy link
Contributor Author

@jtojnar I was considering just that. There are pros and cons: On the one hand, this SELinux module is directly tied to nix-store and what it does. On the other hand, decoupling it from the Nix project itself means it's much easier to develop and release separately. A simple tweak on the policy would mean that all of Nix would have to be re-compiled, the version bumped and released, even though nothing changed in Nix itself. The same holds true vice versa: Version bumps in Nix don't mean that the policy needs to be changed, rebuild and deployed.

Lastly, this is also what Fedora does: Most policies are pre-integrated with the OS, and special needs policies for specific packages come as separately versioned and built packages.

@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO individual Nix expressions in Nixpkgs should not have different licenses.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Custom license removed, and since there's no upstream project, I applied nixpkgs' MIT license.

@jtojnar
Copy link
Contributor

jtojnar commented Feb 8, 2019

IMHO the main criterion to decide whether to upstream the file is whether it can be reused by other distributions like desktop files, manual pages or appstream metadata can. Not sure if SELinux policies fall into this category.

@outergod
Copy link
Contributor Author

outergod commented Feb 8, 2019

@jtojnar the policy, in fact, is currently only of use for other distributions than NixOS. However it has to be loaded into the host system's SELinux configuration and there is no mechanism to do this yet except for the one I added to Nix' installer in NixOS/nix#2670, plus files have to be re-labeled unless they had been previously been installed by Nix.

Keeping the policy separate from Nix has purely pragmatic advantages: It can thus be modified without requiring a separate release of Nix.

The effect of the policy, once fully integrated, is global: It affects the future labeling of all files in the Nix store and makes it at least possible to run systemd services based on files from the Nix store on SELinux systems.

I should've probably explained this much earlier, in the description. In any case, the resulting file has to be inserted using semodule -i, first. The mechanism to apply newer versions of the policy should probably also be added to Nix later, as labels have to be restored retroactively.

If you still think it shouldn't go to nixpkgs but Nix, I'm perfectly fine with closing the PR and moving the policy to the aforementioned PR to Nix. However hosting the policy with Nix will complicate future updates to the policy, and I think there are no advantages in not having the policy in nixpkgs except for purely idealistic ones.

@outergod
Copy link
Contributor Author

I ultimately decided to move the policy into the related Nix PR itself.

@outergod outergod closed this Feb 10, 2019
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.

Nix multi-user installer fails on Fedora Rawhide due to SELinux denial
4 participants