5 * Sebastien Pouliot <sebastien@ximian.com>
7 * (C) 2004 Novell (http://www.novell.com)
11 #include <mono/io-layer/io-layer.h>
18 #include <sys/types.h>
26 #ifndef HAVE_GETRESUID
27 #warning getresuid not supported. WindowsImpersonationContext wont work
29 #ifndef HAVE_SETRESUID
30 #warning setresuid not supported. WindowsImpersonationContext wont work
36 ImpersonateLoggedOnUser (gpointer handle
)
38 uid_t token
= (uid_t
) GPOINTER_TO_INT (handle
);
40 if (setresuid (-1, token
, getuid ()) < 0)
43 return (geteuid () == token
);
47 gboolean
RevertToSelf (void)
55 if (getresuid (&ruid
, &euid
, &suid
) < 0)
59 if (setresuid (-1, suid
, -1) < 0)
64 return (geteuid () == suid
);