summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Raeburn <raeburn@mit.edu>2002-06-25 20:56:17 +0000
committerKen Raeburn <raeburn@mit.edu>2002-06-25 20:56:17 +0000
commit99c69a712b10152a895bf9f9897d0306fafca8e6 (patch)
treed394e3859991bba13f78413348a52c04bbfd95a1
parent4c22d46592fc34600f718920e10118caba70973c (diff)
move krb5_sete[ug]id from libkrb5util (fn) to k5-util.h (macro)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@14569 dc483132-0cff-0310-8789-dd5450dbe970
-rw-r--r--src/include/ChangeLog10
-rw-r--r--src/include/configure.in2
-rw-r--r--src/include/k5-util.h47
-rw-r--r--src/lib/krb5util/ChangeLog5
-rw-r--r--src/lib/krb5util/Makefile.in7
-rw-r--r--src/lib/krb5util/seteuid.c80
6 files changed, 62 insertions, 89 deletions
diff --git a/src/include/ChangeLog b/src/include/ChangeLog
index c6aebe9d5..0d0e2514e 100644
--- a/src/include/ChangeLog
+++ b/src/include/ChangeLog
@@ -1,3 +1,13 @@
+2002-06-25 Ken Raeburn <raeburn@mit.edu>
+
+ * configure.in: Check for seteuid, setresuid, setreuid, setegid,
+ setresgid and setregid.
+ * k5-util.h: Include sys/types.h, unistd.h, and stdlib.h if
+ available; include krb5/autoconf.h and errno.h always.
+ (krb5_seteuid, krb5_setegid): Replace function declarations with
+ macro definitions.
+ (krb5_setedid): Delete declaration of non-existent function.
+
2002-06-24 Ken Raeburn <raeburn@mit.edu>
* port-sockets.h (win_socket_initialize): Delete declaration,
diff --git a/src/include/configure.in b/src/include/configure.in
index a702a2acc..16117afe7 100644
--- a/src/include/configure.in
+++ b/src/include/configure.in
@@ -5,7 +5,7 @@ AC_PROG_INSTALL
AC_PROG_AWK
AC_PROG_LEX
AC_C_CONST
-AC_CHECK_FUNCS(strdup labs setvbuf memmove bcopy inet_ntoa inet_aton gethostbyname_r gethostbyaddr_r getservbyname_r getservbyport_r)
+AC_CHECK_FUNCS(strdup labs setvbuf memmove bcopy inet_ntoa inet_aton gethostbyname_r gethostbyaddr_r getservbyname_r getservbyport_r seteuid setresuid setreuid setegid setresgid setregid)
dnl
dnl Check what the return types for gethostbyname_r and getservbyname_r are.
dnl
diff --git a/src/include/k5-util.h b/src/include/k5-util.h
index e4d49d96e..4f0c6f73f 100644
--- a/src/include/k5-util.h
+++ b/src/include/k5-util.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 1989-1998 by the Massachusetts Institute of Technology,
+ * Copyright (C) 1989-1998,2002 by the Massachusetts Institute of Technology,
* Cambridge, MA, USA. All Rights Reserved.
*
* This software is being provided to you, the LICENSEE, by the
@@ -44,9 +44,48 @@
* They live in libkrb5util.
*/
-int krb5_seteuid(int);
-int krb5_setedid(int);
-int krb5_setegid(int);
+#include "krb5/autoconf.h"
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#include <errno.h>
+
+#ifndef krb5_seteuid
+
+#if defined(HAVE_SETEUID)
+# define krb5_seteuid(EUID) (seteuid((uid_t)(EUID)))
+#elif defined(HAVE_SETRESUID)
+# define krb5_seteuid(EUID) setresuid(getuid(), (uid_t)(EUID), geteuid())
+#elif defined(HAVE_SETREUID)
+# define krb5_seteuid(EUID) setreuid(geteuid(), (uid_t)(EUID))
+#else
+ /* You need to add a case to deal with this operating system.*/
+# define krb5_seteuid(EUID) (errno = EPERM, -1)
+#endif
+
+#ifdef HAVE_SETEGID
+# define krb5_setegid(EGID) (setegid((gid_t)(EGID)))
+#elif defined(HAVE_SETRESGID)
+# define krb5_setegid(EGID) (setresgid(getgid(), (gid_t)(EGID), getegid()))
+#elif defined(HAVE_SETREGID)
+# define krb5_setegid(EGID) (setregid(getegid(), (gid_t)(EGID)))
+#else
+ /* You need to add a case to deal with this operating system.*/
+# define krb5_setegid(EGID) (errno = EPERM, -1)
+#endif
+
+#endif
+
#if defined(KRB_DEFS) && defined(SOCK_DGRAM)
krb5_error_code krb5_compat_recvauth(krb5_context, krb5_auth_context *,
diff --git a/src/lib/krb5util/ChangeLog b/src/lib/krb5util/ChangeLog
index db3dc5eaf..f335bfdd8 100644
--- a/src/lib/krb5util/ChangeLog
+++ b/src/lib/krb5util/ChangeLog
@@ -1,3 +1,8 @@
+2002-06-25 Ken Raeburn <raeburn@mit.edu>
+
+ * seteuid.c: Deleted.
+ * Makefile.in (OBJS, STLIBOBJS, SRCS): Remove references.
+
2001-10-05 Ken Raeburn <raeburn@mit.edu>
* compat_recv.c: Drop _MSDOS support.
diff --git a/src/lib/krb5util/Makefile.in b/src/lib/krb5util/Makefile.in
index dbb47bd37..bc5836ea6 100644
--- a/src/lib/krb5util/Makefile.in
+++ b/src/lib/krb5util/Makefile.in
@@ -6,11 +6,11 @@ BUILDTOP=$(REL)$(U)$(S)$(U)
##DOSBUILDTOP = ..\..
##DOSLIBNAME=krb5util.lib
-OBJS= compat_recv.$(OBJEXT) seteuid.$(OBJEXT)
+OBJS= compat_recv.$(OBJEXT)
-STLIBOBJS=compat_recv.o seteuid.o
+STLIBOBJS=compat_recv.o
-SRCS= $(srcdir)/compat_recv.c $(srcdir)/seteuid.c
+SRCS= $(srcdir)/compat_recv.c
LIB=krb5util
LIBMAJOR=1
@@ -40,5 +40,4 @@ compat_recv.so compat_recv.po $(OUTPRE)compat_recv.$(OBJEXT): compat_recv.c $(SR
$(SRCTOP)/include/socket-utils.h $(SRCTOP)/include/krb5/kdb.h \
$(BUILDTOP)/include/profile.h $(SRCTOP)/include/kerberosIV/krb.h \
$(SRCTOP)/include/kerberosIV/des.h $(SRCTOP)/include/k5-util.h
-seteuid.so seteuid.po $(OUTPRE)seteuid.$(OBJEXT): seteuid.c $(SRCTOP)/include/k5-util.h
diff --git a/src/lib/krb5util/seteuid.c b/src/lib/krb5util/seteuid.c
deleted file mode 100644
index 2b4f596c0..000000000
--- a/src/lib/krb5util/seteuid.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * krb5_seteuid: Attempt to set the effective user ID of the current process
- * in such a way it can be restored lated.
- *
- * Copyright 1996 by the Massachusetts Institute of Technology.
- *
- *
- * Permission to use, copy, modify, and distribute this software and
- * its documentation for any purpose and without fee is hereby
- * granted, provided that the above copyright notice appear in all
- * copies and that both that copyright notice and this permission
- * notice appear in supporting documentation, and that the name of
- * M.I.T. not be used in advertising or publicity pertaining to
- * distribution of the software without specific, written prior
- * permission. Furthermore if you modify this software you must label
- * your software as modified software and not distribute it in such a
- * fashion that it might be confused with the original M.I.T. software.
- * M.I.T. makes no representations about the suitability
- * of this software for any purpose. It is provided "as is" without
- * express or implied warranty.
- *
- */
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
-
-#include <k5-util.h>
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-
-#include <errno.h>
-
-int krb5_seteuid(euid_in)
- int euid_in;
-{
- uid_t euid = (uid_t) euid_in;
-#if defined(HAVE_SETEUID)
- return (seteuid(euid));
-#else
-#if defined(HAVE_SETRESUID)
- return (setresuid(getuid(), euid, geteuid()));
-#else
-#if defined(HAVE_SETREUID)
- return setreuid(geteuid(), euid);
-#else /*HAVE_SETREUID*/
- /* 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 (setegid(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 */
-}