From: Tom Yu Date: Mon, 23 Feb 1998 01:10:51 +0000 (+0000) Subject: * configure.in: Add checks for set{re,e,res}gid() X-Git-Tag: krb5-1.1-beta1~805 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=04f398c083f719d460d2d21eb09b5c75221ae067;p=krb5.git * configure.in: Add checks for set{re,e,res}gid() * seteuid.c: Include k5-util.h rather than k5-int.h. Add krb5_setegid(). git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@10468 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5util/ChangeLog b/src/lib/krb5util/ChangeLog index 63a2c45c3..26e53f68f 100644 --- a/src/lib/krb5util/ChangeLog +++ b/src/lib/krb5util/ChangeLog @@ -1,3 +1,10 @@ +Sun Feb 22 19:22:18 1998 Tom Yu + + * 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 * Makefile.in: Remove trailing slash from thisconfigdir. Fix up diff --git a/src/lib/krb5util/configure.in b/src/lib/krb5util/configure.in index 4db6fec01..f03b15f83 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 25b3a8713..ee848d092 100644 --- a/src/lib/krb5util/seteuid.c +++ b/src/lib/krb5util/seteuid.c @@ -21,7 +21,7 @@ #include #endif -#include +#include #ifdef HAVE_UNISTD_H #include @@ -33,15 +33,15 @@ #include -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 */ +}