]> granicus.if.org Git - sudo/commitdiff
Emulate seteuid using setreuid() or setresuid() as needed.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 14 May 2010 20:43:55 +0000 (16:43 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Fri, 14 May 2010 20:43:55 +0000 (16:43 -0400)
There are still a few places that call seteuid() directly.

include/compat.h

index 1872728aa0e9ca1ceddad7d8c63af50d1424df6b..3b5c65059ddc291822496e105d97769d9897e923 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 1998-2005, 2008
+ * Copyright (c) 1996, 1998-2005, 2008, 2010
  *     Todd C. Miller <Todd.Miller@courtesan.com>
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -299,4 +299,16 @@ void setprogname(const char *);
 # endif
 #endif
 
+#ifndef HAVE_SETEUID
+#  if defined(HAVE_SETRESUID)
+#    define seteuid(u) setresuid(-1, (u), -1)
+#    define setegid(g) setresgid(-1, (g), -1)
+#    HAVE_SETEUID 1
+#  elif defined(HAVE_SETREUID)
+#    define seteuid(u) setreuid(-1, (u))
+#    define setegid(g) setregid(-1, (g))
+#    HAVE_SETEUID 1
+#  endif
+#endif /* HAVE_SETEUID */
+
 #endif /* _SUDO_COMPAT_H */