[io-layer] Remove security.{c,h} (#4079)
authorLudovic Henry <ludovic@xamarin.com>
Fri, 2 Dec 2016 20:06:09 +0000 (15:06 -0500)
committerGitHub <noreply@github.com>
Fri, 2 Dec 2016 20:06:09 +0000 (15:06 -0500)
mono/io-layer/Makefile.am
mono/io-layer/security.c [deleted file]
mono/io-layer/security.h [deleted file]
mono/io-layer/wapi.h
mono/metadata/mono-security.c

index 2240cf753d79aba9f5edf1e02a2f850b5d433263..67dc21aab6a9fa0e2d14fa99e7c522f86b589f1f 100644 (file)
@@ -17,7 +17,6 @@ OTHER_H = \
        io-layer.h      \
        io-portability.h        \
        messages.h      \
-       security.h      \
        sockets.h       \
        uglify.h        \
        versioninfo.h   \
@@ -37,8 +36,6 @@ OTHER_SRC = \
        messages.c              \
        messages.h              \
        posix.c                 \
-       security.c              \
-       security.h              \
        sockets.c               \
        sockets.h               \
        socket-private.h        \
diff --git a/mono/io-layer/security.c b/mono/io-layer/security.c
deleted file mode 100644 (file)
index d1bf3d0..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * security.c:  Security
- *
- * Author:
- *     Sebastien Pouliot  <sebastien@ximian.com>
- *
- * (C) 2004 Novell (http://www.novell.com)
- */
-
-#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>
-
-gboolean 
-ImpersonateLoggedOnUser (gpointer handle)
-{
-       uid_t token = (uid_t) GPOINTER_TO_INT (handle);
-#ifdef HAVE_SETRESUID
-       if (setresuid (-1, token, getuid ()) < 0)
-               return FALSE;
-#endif
-       return (geteuid () == token);
-}
-
-
-gboolean RevertToSelf (void)
-{
-#ifdef HAVE_GETRESUID
-       uid_t ruid, euid;
-#endif
-       uid_t suid = -1;
-
-#ifdef HAVE_GETRESUID
-       if (getresuid (&ruid, &euid, &suid) < 0)
-               return FALSE;
-#endif
-#ifdef HAVE_SETRESUID
-       if (setresuid (-1, suid, -1) < 0)
-               return FALSE;
-#else
-       return TRUE;
-#endif
-       return (geteuid () == suid);
-}
-
diff --git a/mono/io-layer/security.h b/mono/io-layer/security.h
deleted file mode 100644 (file)
index 1f91659..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * security.h:  Security
- *
- * Author:
- *     Sebastien Pouliot  <sebastien@ximian.com>
- *
- * (C) 2004 Novell (http://www.novell.com)
- */
-
-#ifndef _WAPI_SECURITY_H_
-#define _WAPI_SECURITY_H_
-
-#include <glib.h>
-
-G_BEGIN_DECLS
-
-extern gboolean ImpersonateLoggedOnUser (gpointer handle);
-extern gboolean RevertToSelf (void);
-
-G_END_DECLS
-
-#endif /* _WAPI_SECURITY_H_ */
index 769eaf1c80b6d2dc2ff9f6928639908348514aff..a2ef68539ee936fac0c72cf39c958a4a6d3406fb 100644 (file)
@@ -18,7 +18,6 @@
 #include <mono/io-layer/io.h>
 #include <mono/io-layer/error.h>
 #include <mono/io-layer/messages.h>
-#include <mono/io-layer/security.h>
 #include <mono/io-layer/sockets.h>
 #include <mono/io-layer/versioninfo.h>
 
index 09b8cd44abe6deaba2428602aa257022dbf21a88..4d39be15a265a934d97a9a75af69f6ec30e42c47 100644 (file)
@@ -337,15 +337,41 @@ ves_icall_System_Security_Principal_WindowsImpersonationContext_DuplicateToken (
 gboolean
 ves_icall_System_Security_Principal_WindowsImpersonationContext_SetCurrentToken (gpointer token)
 {
-       /* Posix version implemented in /mono/mono/io-layer/security.c */
+#ifdef HOST_WIN32
        return (ImpersonateLoggedOnUser (token) != 0);
+#else
+       uid_t itoken = (uid_t) GPOINTER_TO_INT (token);
+#ifdef HAVE_SETRESUID
+       if (setresuid (-1, itoken, getuid ()) < 0)
+               return FALSE;
+#endif
+       return geteuid () == itoken;
+#endif
 }
 
 gboolean
 ves_icall_System_Security_Principal_WindowsImpersonationContext_RevertToSelf (void)
 {
-       /* Posix version implemented in /mono/mono/io-layer/security.c */
+#ifdef HOST_WIN32
        return (RevertToSelf () != 0);
+#else
+#ifdef HAVE_GETRESUID
+       uid_t ruid, euid;
+#endif
+       uid_t suid = -1;
+
+#ifdef HAVE_GETRESUID
+       if (getresuid (&ruid, &euid, &suid) < 0)
+               return FALSE;
+#endif
+#ifdef HAVE_SETRESUID
+       if (setresuid (-1, suid, -1) < 0)
+               return FALSE;
+#else
+       return TRUE;
+#endif
+       return geteuid () == suid;
+#endif
 }
 #endif /* G_HAVE_API_SUPPORT(HAVE_CLASSIC_WINAPI_SUPPORT) */