[msvc] Update csproj files
[mono.git] / mono / io-layer / security.c
index 3a5c622de9d08c7620e4cbc3b215a2604e047bf4..d1bf3d0362c5b355311ab9af67c9c7c636872383 100644 (file)
 #include <config.h>
 #include <mono/io-layer/io-layer.h>
 
+#ifdef HAVE_PWD_H
 #include <pwd.h>
+#endif
+
 #include <string.h>
 #include <sys/types.h>
+#include <sys/stat.h>
 #include <unistd.h>
 
-
-/* Disclaimers */
-
-#if defined(__GNUC__)
-#ifndef HAVE_GETRESUID
-       #warning getresuid not supported. WindowsImpersonationContext wont work
-#endif
-#ifndef HAVE_SETRESUID
-       #warning setresuid not supported. WindowsImpersonationContext wont work
-#endif
-#endif
-
-
 gboolean 
 ImpersonateLoggedOnUser (gpointer handle)
 {
-       uid_t token = (uid_t) handle;
+       uid_t token = (uid_t) GPOINTER_TO_INT (handle);
 #ifdef HAVE_SETRESUID
        if (setresuid (-1, token, getuid ()) < 0)
                return FALSE;
@@ -54,6 +45,8 @@ gboolean RevertToSelf (void)
 #ifdef HAVE_SETRESUID
        if (setresuid (-1, suid, -1) < 0)
                return FALSE;
+#else
+       return TRUE;
 #endif
        return (geteuid () == suid);
 }