summary refs log tree commit diff
path: root/pkgs/applications/virtualization
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2013-03-01 05:29:19 +0100
committeraszlig <aszlig@redmoonstudios.org>2013-03-01 09:42:38 +0100
commit1029ca5767e3d27fbfbeb19a845ffee3485c028f (patch)
tree8752f040eea14494fa2e352142738a0824ebaead /pkgs/applications/virtualization
parentf26b5fb73096300eead230d393c3fc206482ea2a (diff)
downloadnixlib-1029ca5767e3d27fbfbeb19a845ffee3485c028f.tar
nixlib-1029ca5767e3d27fbfbeb19a845ffee3485c028f.tar.gz
nixlib-1029ca5767e3d27fbfbeb19a845ffee3485c028f.tar.bz2
nixlib-1029ca5767e3d27fbfbeb19a845ffee3485c028f.tar.lz
nixlib-1029ca5767e3d27fbfbeb19a845ffee3485c028f.tar.xz
nixlib-1029ca5767e3d27fbfbeb19a845ffee3485c028f.tar.zst
nixlib-1029ca5767e3d27fbfbeb19a845ffee3485c028f.zip
virtualbox: Support UIDGID_STRICT_TYPE_CHECKS.
This adds a patch to support CONFIG_UIDGID_STRICT_TYPE_CHECKS being activated in
the kernel config (selected by CONFIG_USER_NS for example).

When this kernel option is enabled, current->cred->uid is a structure rather
than a simple integer type (uid_t and gid_t), so we need to check for that and
also pass the current user namespace where needed.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'pkgs/applications/virtualization')
-rw-r--r--pkgs/applications/virtualization/virtualbox/default.nix5
-rw-r--r--pkgs/applications/virtualization/virtualbox/strict_types.patch68
2 files changed, 72 insertions, 1 deletions
diff --git a/pkgs/applications/virtualization/virtualbox/default.nix b/pkgs/applications/virtualization/virtualbox/default.nix
index d95d97688c3a..05a9dd7e7d86 100644
--- a/pkgs/applications/virtualization/virtualbox/default.nix
+++ b/pkgs/applications/virtualization/virtualbox/default.nix
@@ -54,7 +54,10 @@ in stdenv.mkDerivation {
     ++ optional javaBindings jdk
     ++ optional pythonBindings python;
 
-  patches = singleton ./missing_files_4.2.8.patch;
+  patches = [
+    ./missing_files_4.2.8.patch
+    ./strict_types.patch
+  ];
 
   prePatch = ''
     set -x
diff --git a/pkgs/applications/virtualization/virtualbox/strict_types.patch b/pkgs/applications/virtualization/virtualbox/strict_types.patch
new file mode 100644
index 000000000000..18ccc77f9b16
--- /dev/null
+++ b/pkgs/applications/virtualization/virtualbox/strict_types.patch
@@ -0,0 +1,68 @@
+diff --git a/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c b/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c
+index 9cc124c..d86da0c 100644
+--- a/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c
++++ b/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c
+@@ -253,7 +253,11 @@ static struct platform_device gPlatformDevice =
+ DECLINLINE(RTUID) vboxdrvLinuxUid(void)
+ {
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
++# ifdef CONFIG_UIDGID_STRICT_TYPE_CHECKS
++    return from_kuid(current_user_ns(), current_uid());
++# else
+     return current->cred->uid;
++# endif
+ #else
+     return current->uid;
+ #endif
+@@ -262,7 +266,11 @@ DECLINLINE(RTUID) vboxdrvLinuxUid(void)
+ DECLINLINE(RTGID) vboxdrvLinuxGid(void)
+ {
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
++# ifdef CONFIG_UIDGID_STRICT_TYPE_CHECKS
++    return from_kgid(current_user_ns(), current_gid());
++# else
+     return current->cred->gid;
++# endif
+ #else
+     return current->gid;
+ #endif
+@@ -271,7 +279,11 @@ DECLINLINE(RTGID) vboxdrvLinuxGid(void)
+ DECLINLINE(RTUID) vboxdrvLinuxEuid(void)
+ {
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
++# ifdef CONFIG_UIDGID_STRICT_TYPE_CHECKS
++    return from_kuid(current_user_ns(), current_euid());
++# else
+     return current->cred->euid;
++# endif
+ #else
+     return current->euid;
+ #endif
+diff --git a/src/VBox/HostDrivers/VBoxPci/linux/VBoxPci-linux.c b/src/VBox/HostDrivers/VBoxPci/linux/VBoxPci-linux.c
+index 575f739..8909e79 100644
+--- a/src/VBox/HostDrivers/VBoxPci/linux/VBoxPci-linux.c
++++ b/src/VBox/HostDrivers/VBoxPci/linux/VBoxPci-linux.c
+@@ -429,7 +429,11 @@ int vboxPciOsDevDetachHostDriver(PVBOXRAWPCIINS pIns)
+         if (!pNewCreds)
+                 goto done;
+ 
++# ifdef CONFIG_UIDGID_STRICT_TYPE_CHECKS
++        pNewCreds->fsuid = GLOBAL_ROOT_UID;;
++# else
+         pNewCreds->fsuid = 0;
++# endif
+         pOldCreds = override_creds(pNewCreds);
+ #endif
+ 
+@@ -539,7 +543,11 @@ int vboxPciOsDevReattachHostDriver(PVBOXRAWPCIINS pIns)
+         if (!pNewCreds)
+             goto done;
+ 
++# ifdef CONFIG_UIDGID_STRICT_TYPE_CHECKS
++        pNewCreds->fsuid = GLOBAL_ROOT_UID;;
++# else
+         pNewCreds->fsuid = 0;
++# endif
+         pOldCreds = override_creds(pNewCreds);
+ #endif
+         RTStrPrintf(szFileBuf, cMaxBuf,