diff options
-rw-r--r-- | src/lib/krb5util/ChangeLog | 7 | ||||
-rw-r--r-- | src/lib/krb5util/configure.in | 2 | ||||
-rw-r--r-- | src/lib/krb5util/seteuid.c | 31 |
3 files changed, 34 insertions, 6 deletions
diff --git a/src/lib/krb5util/ChangeLog b/src/lib/krb5util/ChangeLog index 63a2c45..26e53f6 100644 --- a/src/lib/krb5util/ChangeLog +++ b/src/lib/krb5util/ChangeLog @@ -1,3 +1,10 @@ +Sun Feb 22 19:22:18 1998 Tom Yu <tlyu@mit.edu> + + * configure.in: Add checks for set{re,e,res}gid(). + + * seteuid.c: Include k5-util.h rather than k5-int.h. Add + krb5_setegid(). + Wed Feb 18 16:26:00 1998 Tom Yu <tlyu@mit.edu> * Makefile.in: Remove trailing slash from thisconfigdir. Fix up diff --git a/src/lib/krb5util/configure.in b/src/lib/krb5util/configure.in index 4db6fec..f03b15f 100644 --- a/src/lib/krb5util/configure.in +++ b/src/lib/krb5util/configure.in @@ -1,7 +1,7 @@ AC_INIT(configure.in) CONFIG_RULES AC_CHECK_HEADERS(unistd.h stdlib.h sys/types.h) -AC_CHECK_FUNCS(seteuid setresuid setreuid) +AC_CHECK_FUNCS(seteuid setresuid setreuid setegid setresgid setregid) dnl AppendRule([all:: all-$(WHAT)]) KRB5_BUILD_LIBRARY_STATIC KRB5_BUILD_LIBOBJS diff --git a/src/lib/krb5util/seteuid.c b/src/lib/krb5util/seteuid.c index 25b3a87..ee848d0 100644 --- a/src/lib/krb5util/seteuid.c +++ b/src/lib/krb5util/seteuid.c @@ -21,7 +21,7 @@ #include <sys/types.h> #endif -#include <k5-int.h> +#include <k5-util.h> #ifdef HAVE_UNISTD_H #include <unistd.h> @@ -33,15 +33,15 @@ #include <errno.h> -int krb5_seteuid( euid_in) +int krb5_seteuid(euid_in) int euid_in; { uid_t euid = (uid_t) euid_in; #if defined(HAVE_SETEUID) - return (seteuid(euid)) ; + return (seteuid(euid)); #else #if defined(HAVE_SETRESUID) - return (setresuid(getuid(), euid, geteuid())) ; + return (setresuid(getuid(), euid, geteuid())); #else #if defined(HAVE_SETREUID) return setreuid(geteuid(), euid); @@ -49,8 +49,29 @@ int krb5_seteuid( euid_in) /* You need to add a case to deal with this operating system.*/ errno = EPERM; return -1; - #endif /* HAVE_SETREUID */ #endif /* HAVE_SETRESUID */ #endif /* HAVE_SETEUID */ } + +int krb5_setegid(egid_in) + int egid_in; +{ + gid_t egid = (gid_t) egid_in; + +#ifdef HAVE_SETEGID + return (seteuid(egid)); +#else +#ifdef HAVE_SETRESGID + return (setresgid(getgid(), egid, getegid())); +#else +#ifdef HAVE_SETREGID + return (setregid(getegid(), egid)); +#else /* HAVE_SETREGID */ + /* You need to add a case to deal with this operating system.*/ + errno = EPERM; + return -1; +#endif /* HAVE_SETREGID */ +#endif /* HAVE_SETRESGID */ +#endif /* HAVE_SETEGID */ +} |