summary refs log tree commit diff
path: root/nixos/modules/programs
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2014-11-29 08:09:50 +0100
committeraszlig <aszlig@redmoonstudios.org>2014-11-29 19:21:46 +0100
commit3e49487c1a3289acdb72c15e7a6d6105070dd420 (patch)
tree3451aa4b8ae7b01910a8bf4eb2ffa819f667b51f /nixos/modules/programs
parentdeec767efab85b61c8b58dfd597b7c221f823112 (diff)
downloadnixlib-3e49487c1a3289acdb72c15e7a6d6105070dd420.tar
nixlib-3e49487c1a3289acdb72c15e7a6d6105070dd420.tar.gz
nixlib-3e49487c1a3289acdb72c15e7a6d6105070dd420.tar.bz2
nixlib-3e49487c1a3289acdb72c15e7a6d6105070dd420.tar.lz
nixlib-3e49487c1a3289acdb72c15e7a6d6105070dd420.tar.xz
nixlib-3e49487c1a3289acdb72c15e7a6d6105070dd420.tar.zst
nixlib-3e49487c1a3289acdb72c15e7a6d6105070dd420.zip
virtualbox: Enable hardening by default.
VirtualBox with hardening support requires the main binaries to be
setuid root. Using VBOX_WITH_RUNPATH, we ensure that the RPATHs are
pointing to the libexec directory and we also need to unset
VBOX_WITH_ORIGIN to make sure that the build system is actually setting
those RPATHs.

The hardened.patch implements two things:

 * Set the binary directory to the setuid-wrappers dir so that
   VboxSVC calls them instead of the binaries from the store path. The
   reason behind this is because nothing in the Nix store can have the
   setuid flag.
 * Excempt /nix/store from the group permission check, because while it
   is group-writeable indeed it also has the sticky bit set (and also
   the whole store is mounted read-only on most NixOS systems), so we're
   checking on that as well.

Right now, the hardened.patch uses /nix/store and /var/setuid-wrappers
directly, so someone would ever want to change those on a NixOS system,
please provide a patch to set those paths on build time. However, for
simplicity, it's best to do it when we _really_ need it.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'nixos/modules/programs')
-rw-r--r--nixos/modules/programs/virtualbox-host.nix16
1 files changed, 16 insertions, 0 deletions
diff --git a/nixos/modules/programs/virtualbox-host.nix b/nixos/modules/programs/virtualbox-host.nix
index d32ebc7ebcb6..ea962d5d6cee 100644
--- a/nixos/modules/programs/virtualbox-host.nix
+++ b/nixos/modules/programs/virtualbox-host.nix
@@ -16,6 +16,22 @@ in
     boot.extraModulePackages = [ virtualbox ];
     environment.systemPackages = [ virtualbox ];
 
+    security.setuidOwners = let
+      mkVboxStub = program: {
+        inherit program;
+        owner = "root";
+        group = "vboxusers";
+        setuid = true;
+      };
+    in map mkVboxStub [
+      "VBoxBFE"
+      "VBoxBalloonCtrl"
+      "VBoxHeadless"
+      "VBoxManage"
+      "VBoxSDL"
+      "VirtualBox"
+    ];
+
     users.extraGroups.vboxusers.gid = config.ids.gids.vboxusers;
 
     services.udev.extraRules =