]> granicus.if.org Git - sudo/commitdiff
added deif of UID_NO_CHANGE & GID_NO_CHANGE
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 7 Jun 1995 02:32:22 +0000 (02:32 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 7 Jun 1995 02:32:22 +0000 (02:32 +0000)
added setreuid emulation with setresuid if applic

compat.h

index 00f62a5e4415bb36e0abcc9e88c206a3b72e4eb3..707fd11922933f35bec1bc01903e5dac7e0a12e3 100644 (file)
--- a/compat.h
+++ b/compat.h
 #  define S_ISREG(m)           (((m) & _S_IFMT) == _S_IFREG)
 #endif /* S_ISREG */
 
+/*
+ * Some OS's lack these
+ */
+#ifndef UID_NO_CHANGE
+#  define UID_NO_CHANGE        ((uid_t) -1)
+#endif /* UID_NO_CHANGE */
+#ifndef GID_NO_CHANGE
+#  define GID_NO_CHANGE        ((gid_t) -1)
+#endif /* GID_NO_CHANGE */
+
+/*
+ * Emulate setreuid(2) with setresuid(2)
+ */
+#if defined(HAVE_SETRESUID) && !defined(HAVE_SETREUID)
+#  undef setreuid
+#  define setreuid(__R, __E)   (setresuid(__R, __E, UID_NO_CHANGE))
+#  define HAVE_SETREUID
+#endif /* HAVE_SETRESUID && !HAVE_SETREUID */
+
 /*
  * Emulate seteuid() and setegid() for HP-UX
  */
 #ifdef __hpux
-#  define seteuid(__EUID)      (setresuid((uid_t)-1, __EUID, (uid_t)-1))
-#  define setegid(__EGID)      (setresgid((gid_t)-1, __EGID, (gid_t)-1))
+#  define seteuid(_EUID)       (setresuid(UID_NO_CHANGE, _EUID, UID_NO_CHANGE))
+#  define setegid(_EGID)       (setresgid(GID_NO_CHANGE, _EGID, GID_NO_CHANGE))
 #endif /* __hpux */
 
 /*
  */
 #ifdef _AIX
 #  include <sys/id.h>
-#  define seteuid(__EUID)      (setuidx(ID_EFFECTIVE|ID_REAL, __EUID))
-#  define setegid(__EGID)      (setgidx(ID_EFFECTIVE|ID_REAL, __EGID))
+#  define seteuid(_EUID)       (setuidx(ID_EFFECTIVE|ID_REAL, _EUID))
+#  define setegid(_EGID)       (setgidx(ID_EFFECTIVE|ID_REAL, _EGID))
 #endif /* _AIX */
 
 #endif /* _SUDO_COMPAT_H */