changeset 3:b0033e69105a

Set group ID during initialization, added a patch to mono to fix a double free 'bug'
author Ivo Smits
date Wed, 04 May 2011 16:32:10 +0200
parents f1deea9c97a0
children 64226294e26b
files VBoxFrontend/MonoCOMInteropDoubleFree.patch VBoxFrontend/ProgramLoader.cs VBoxFrontend/VBoxFrontend.csproj
diffstat 3 files changed, 27 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/VBoxFrontend/MonoCOMInteropDoubleFree.patch	Wed May 04 16:32:10 2011 +0200
@@ -0,0 +1,17 @@
+diff --git a/mcs/class/corlib/Mono.Interop/ComInteropProxy.cs b/mcs/class/corlib/Mono.Interop/ComInteropProxy.cs
+index 54fefe2..1271257 100644
+--- a/mcs/class/corlib/Mono.Interop/ComInteropProxy.cs
++++ b/mcs/class/corlib/Mono.Interop/ComInteropProxy.cs
+@@ -93,12 +93,9 @@ namespace Mono.Interop
+                        Marshal.ThrowExceptionForHR (hr);
+                        ComInteropProxy obj = FindProxy (ppv);
+                        if (obj == null) {
+-                               Marshal.Release (pItf);
+                                return new ComInteropProxy (ppv);
+                        }
+                        else {
+-                               Marshal.Release (pItf);
+-                               System.Threading.Interlocked.Increment (ref obj.ref_count);
+                                return obj;
+                        }
+                }
--- a/VBoxFrontend/ProgramLoader.cs	Wed May 04 16:10:08 2011 +0200
+++ b/VBoxFrontend/ProgramLoader.cs	Wed May 04 16:32:10 2011 +0200
@@ -26,7 +26,13 @@
 		private static void Unix_setuid() {
 			uint uid = Mono.Unix.Native.Syscall.getuid();
 			uint euid = Mono.Unix.Native.Syscall.geteuid();
-			Console.WriteLine("Running as user {0} effective {1}", uid, euid);
+			uint gid = Mono.Unix.Native.Syscall.getgid();
+			uint egid = Mono.Unix.Native.Syscall.getegid();
+			Console.WriteLine("Running as user {0} effective {1} group {2} effective {3}", uid, euid, gid, egid);
+			if (gid != egid) {
+				Console.WriteLine("Set group ID: {0}", gid);
+				Mono.Unix.Native.Syscall.setregid(gid, gid);
+			}
 			if (uid != euid) {
 				Console.WriteLine("Set user ID: {0}", uid);
 				Mono.Unix.Native.Syscall.setreuid(uid, uid);
--- a/VBoxFrontend/VBoxFrontend.csproj	Wed May 04 16:10:08 2011 +0200
+++ b/VBoxFrontend/VBoxFrontend.csproj	Wed May 04 16:32:10 2011 +0200
@@ -86,6 +86,9 @@
   <ItemGroup>
     <Content Include="VBoxMono.c" />
   </ItemGroup>
+  <ItemGroup>
+    <None Include="MonoCOMInteropDoubleFree.patch" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.