+2005-03-25 Ken Raeburn <raeburn@mit.edu>
+
+ * configure.in: Don't check for getpwnam_r and getpwuid_r in the
+ thread-safety warnings. The tests done elsewhere in the tree are
+ stricter and may not agree.
+
2005-01-12 Tom Yu <tlyu@mit.edu>
* aclocal.m4 (AC_LIBRARY_NET): Also check for res_ndestroy.
dnl
dnl Check for thread safety issues.
dnl (Is there a better place for this?)
-tsfuncs="getpwnam_r getpwuid_r gethostbyname_r getservbyname_r gmtime_r localtime_r"
+dnl tsfuncs="getpwnam_r getpwuid_r gethostbyname_r getservbyname_r gmtime_r localtime_r"
+dnl Removed getpwnam_r and getpwuid_r because include/configure.in has some
+dnl more careful checks, and may decide to pretend that they're not found if
+dnl the function signatures can't be figured out.
+tsfuncs="gethostbyname_r getservbyname_r gmtime_r localtime_r"
AC_CHECK_FUNCS($tsfuncs)
if test "$enable_thread_support" = yes; then
tsmissing=""
2005-03-25 Ken Raeburn <raeburn@mit.edu>
+ * configure.in: Don't check for getpwnam_r and getpwuid_r with
+ AC_CHECK_FUNCS; use AC_CHECK_FUNC, and only set shell variables.
+ Run stricter tests on return types and numbers of arguments, and
+ only define the C macros if these parameters can actually be
+ determined.
+ * k5-platform.h (k5_getpwnam_r, k5_getpwuid_r): New macros.
+
* k5-platform.h: Expand on init/fini comments some more.
(MAKE_FINI_FUNCTION): Add an HP-UX specific variant that defines
an auxiliary function fitting the signature of HP-UX 10 library
AC_PROG_AWK
AC_PROG_LEX
AC_C_CONST
-AC_CHECK_FUNCS(strdup setvbuf inet_ntoa inet_aton seteuid setresuid setreuid setegid setresgid setregid setsid flock fchmod chmod strftime strptime geteuid setenv unsetenv getenv gethostbyname2 getifaddrs getpwnam_r getpwuid_r gmtime_r localtime_r pthread_mutex_lock sched_yield)
+AC_CHECK_FUNCS(strdup setvbuf inet_ntoa inet_aton seteuid setresuid setreuid setegid setresgid setregid setsid flock fchmod chmod strftime strptime geteuid setenv unsetenv getenv gethostbyname2 getifaddrs gmtime_r localtime_r pthread_mutex_lock sched_yield)
AC_CHECK_FUNCS( mkstemp)
AC_HEADER_STDARG
AC_CHECK_HEADERS(unistd.h paths.h regex.h regexp.h regexpr.h fcntl.h memory.h ifaddrs.h sys/filio.h sched.h)
])
dnl
+AC_CHECK_FUNC(getpwnam_r,ac_cv_func_getpwnam_r=yes,ac_cv_func_getpwnam_r=no)
+AC_CHECK_FUNC(getpwuid_r,ac_cv_func_getpwuid_r=yes,ac_cv_func_getpwuid_r=no)
if test "$ac_cv_func_getpwnam_r" = yes; then
AC_MSG_CHECKING([return type of getpwnam_r])
AC_CACHE_VAL(krb5_cv_getpwnam_r_return_type,
if test $krb5_cv_getpwnam_r_return_type = int; then
AC_DEFINE(GETPWNAM_R_RETURNS_INT, 1, [Define if getpwnam_r returns an int])
elif test $krb5_cv_getpwnam_r_return_type = unknown; then
- AC_MSG_WARN([Cannot determine getpwnam_r return type, disabling])
+ AC_MSG_WARN([Cannot determine getpwnam_r return type, disabling getpwnam_r])
ac_cv_func_getpwnam_r=no
fi
fi
AC_CACHE_VAL(krb5_cv_getpwnam_r_args,
[AC_TRY_COMPILE([#include <pwd.h>
struct passwd pwx; char buf[1024];],
- [getpwnam_r("", &pwx, buf, sizeof(buf));],
- krb5_cv_getpwnam_r_args=4,krb5_cv_getpwnam_r_args=5)])
+ [getpwnam_r("", &pwx, buf, sizeof(buf));], args4=yes, args4=no)
+ AC_TRY_COMPILE([#include <pwd.h>
+ struct passwd pwx, *p; char buf[1024];],
+ [getpwnam_r("", &pwx, buf, sizeof(buf), &p);], args5=yes, args5=no)
+ case $args4/$args5 in
+ yes/no) krb5_cv_getpwnam_r_args=4 ;;
+ no/yes) krb5_cv_getpwnam_r_args=5 ;;
+ *) krb5_cv_getpwnam_r_args=unknown ;;
+ esac])
AC_MSG_RESULT($krb5_cv_getpwnam_r_args)
- if test "$krb5_cv_getpwnam_r_args" = 4; then
- AC_DEFINE(GETPWNAM_R_4_ARGS,1,[Define if getpwnam_r exists but takes only 4 arguments (e.g., POSIX draft 6 implementations like some Solaris releases).])
+ if test "$krb5_cv_getpwnam_r_args" = unknown; then
+ AC_MSG_WARN([Cannot determine number of arguments to getpwnam_r, disabling its use.])
+ ac_cv_func_getpwnam_r=no
+ else
+ AC_DEFINE(HAVE_GETPWNAM_R,1,[Define if getpwnam_r is available and useful.])
+ if test "$krb5_cv_getpwnam_r_args" = 4; then
+ AC_DEFINE(GETPWNAM_R_4_ARGS,1,[Define if getpwnam_r exists but takes only 4 arguments (e.g., POSIX draft 6 implementations like some Solaris releases).])
+ fi
fi
fi
+if test "$ac_cv_func_getpwnam_r" = no && test "$ac_cv_func_getpwuid_r" = yes; then
+ # Actually, we could do this check, and the corresponding checks
+ # for return type and number of arguments, but I doubt we'll run
+ # into a system where we'd get to use getpwuid_r but not getpwnam_r.
+ AC_MSG_NOTICE([getpwnam_r not useful, so disabling getpwuid_r too])
+ ac_cv_func_getpwuid_r=no
+fi
if test "$ac_cv_func_getpwuid_r" = yes; then
- AC_MSG_CHECKING([number of arguments to getpwuid_r])
- AC_CACHE_VAL(krb5_cv_getpwuid_r_args,
- [AC_TRY_COMPILE([#include <pwd.h>
- struct passwd pwx; char buf[1024];],
- [getpwuid_r(0, &pwx, buf, sizeof(buf));],
- krb5_cv_getpwuid_r_args=4,krb5_cv_getpwuid_r_args=5)])
- AC_MSG_RESULT($krb5_cv_getpwuid_r_args)
- if test "$krb5_cv_getpwuid_r_args" = 4; then
+ AC_DEFINE(HAVE_GETPWUID_R,1,[Define if getpwuid_r is available and useful.])
+ # Hack: Assume getpwuid_r is the shorter form if getpwnam_r is.
+ if test "$krb5_cv_getpwnam_r_args" = 4; then
AC_DEFINE(GETPWUID_R_4_ARGS,1,[Define if getpwuid_r exists but takes only 4 arguments (e.g., POSIX draft 6 implementations like some Solaris releases).])
fi
fi
* + 64-bit types and load/store code
* + SIZE_MAX
* + shared library init/fini hooks
+ * + consistent getpwnam/getpwuid interfaces
*/
#ifndef K5_PLATFORM_H
return ((UINT64_TYPE)load_32_le(p+4) << 32) | load_32_le(p);
}
+
+/* Make the interfaces to getpwnam and getpwuid consistent.
+ Model the wrappers on the POSIX thread-safe versions, but
+ use the unsafe system versions if the safe ones don't exist
+ or we can't figure out their interfaces. */
+
+/* int k5_getpwnam_r(const char *, blah blah) */
+#ifdef HAVE_GETPWNAM_R
+# ifndef GETPWNAM_R_4_ARGS
+/* POSIX */
+# define k5_getpwnam_r(NAME, REC, BUF, BUFSIZE, OUT) \
+ getpwnam_r(NAME,REC,BUF,BUFSIZE,OUT)
+# else
+/* POSIX drafts? */
+# ifdef GETPWNAM_R_RETURNS_INT
+# define k5_getpwnam_r(NAME, REC, BUF, BUFSIZE, OUT) \
+ (getpwnam_r(NAME,REC,BUF,BUFSIZE) == 0 \
+ ? (*(OUT) = REC, 0) \
+ : (*(OUT) = NULL, -1))
+# else
+# define k5_getpwnam_r(NAME, REC, BUF, BUFSIZE, OUT) \
+ (*(OUT) = getpwnam_r(NAME,REC,BUF,BUFSIZE), *(OUT) == NULL ? -1 : 0)
+# endif
+# endif
+#else /* no getpwnam_r, or can't figure out #args or return type */
+/* Will get warnings about unused variables. */
+# define k5_getpwnam_r(NAME, REC, BUF, BUFSIZE, OUT) \
+ (*(OUT) = getpwnam(NAME), *(OUT) == NULL ? -1 : 0)
+#endif
+
+/* int k5_getpwuid_r(uid_t, blah blah) */
+#ifdef HAVE_GETPWUID_R
+# ifndef GETPWUID_R_4_ARGS
+/* POSIX */
+# define k5_getpwuid_r(UID, REC, BUF, BUFSIZE, OUT) \
+ getpwuid_r(UID,REC,BUF,BUFSIZE,OUT)
+# else
+/* POSIX drafts? Yes, I mean to test GETPWNAM... here. Less junk to
+ do at configure time. */
+# ifdef GETPWNAM_R_RETURNS_INT
+# define k5_getpwuid_r(UID, REC, BUF, BUFSIZE, OUT) \
+ (getpwuid_r(UID,REC,BUF,BUFSIZE) == 0 \
+ ? (*(OUT) = REC, 0) \
+ : (*(OUT) = NULL, -1))
+# else
+# define k5_getpwuid_r(UID, REC, BUF, BUFSIZE, OUT) \
+ (*(OUT) = getpwuid_r(UID,REC,BUF,BUFSIZE), *(OUT) == NULL ? -1 : 0)
+# endif
+# endif
+#else /* no getpwuid_r, or can't figure out #args or return type */
+/* Will get warnings about unused variables. */
+# define k5_getpwuid_r(UID, REC, BUF, BUFSIZE, OUT) \
+ (*(OUT) = getpwuid(UID), *(OUT) == NULL ? -1 : 0)
+#endif
+
+
#endif /* K5_PLATFORM_H */
* Makefile.in (gssapi_krb5.h): Use awk hack to work around quoting
problem.
+2005-03-25 Ken Raeburn <raeburn@mit.edu>
+
+ * import_name.c (krb5_gss_import_name): Use k5_getpwuid_r.
+
2005-01-13 Jeffrey Altman <jaltman@mit.edu>
* init_sec_context.c, acquire_cred.c: fix calls to
} else {
#ifndef NO_PASSWORD
uid_t uid;
-#ifdef HAVE_GETPWUID_R
struct passwd pwx;
char pwbuf[BUFSIZ];
-#endif
#endif
stringrep = NULL;
} else if (g_OID_equal(input_name_type, gss_nt_machine_uid_name)) {
uid = *(uid_t *) input_name_buffer->value;
do_getpwuid:
-#ifndef HAVE_GETPWUID_R
- pw = getpwuid(uid);
-#elif defined(GETPWUID_R_4_ARGS)
- /* old POSIX drafts */
- pw = getpwuid_r(uid, &pwx, pwbuf, sizeof(pwbuf));
-#else
- /* POSIX */
- if (getpwuid_r(uid, &pwx, pwbuf, sizeof(pwbuf), &pw) != 0)
- pw = NULL;
-#endif
- if (pw)
- stringrep = pw->pw_name;
+ if (k5_getpwuid_r(uid, &pwx, pwbuf, sizeof(pwbuf), &pw) == 0)
+ stringrep = pw->pw_name;
else
*minor_status = (OM_uint32) G_NOUSER;
} else if (g_OID_equal(input_name_type, gss_nt_string_uid_name)) {
reference counter if they have been previously called
within the application.
+2005-03-25 Ken Raeburn <raeburn@mit.edu>
+
+ * kuserok.c (krb5_kuserok): Use k5_getpwnam_r.
+
2005-03-22 Tom Yu <tlyu@mit.edu>
* dnsglue.h: Define ns_rr_class to ns_rr_cl if ns_rr_class doesn't
int gobble;
/* no account => no access */
-#ifdef HAVE_GETPWNAM_R
char pwbuf[BUFSIZ];
struct passwd pwx;
-#if !defined(GETPWNAM_R_4_ARGS)
- /* POSIX */
- if (getpwnam_r(luser, &pwx, pwbuf, sizeof(pwbuf), &pwd) != 0)
- pwd = NULL;
-#else
- /* draft POSIX */
- pwd = getpwnam_r(luser, &pwx, pwbuf, sizeof(pwbuf));
-#endif
-#else
- pwd = getpwnam(luser);
-#endif
- if (pwd == NULL)
+ if (k5_getpwnam_r(luser, &pwx, pwbuf, sizeof(pwbuf), &pwd) != 0)
return(FALSE);
(void) strncpy(pbuf, pwd->pw_dir, sizeof(pbuf) - 1);
pbuf[sizeof(pbuf) - 1] = '\0';
+2005-03-25 Ken Raeburn <raeburn@mit.edu>
+
+ * configure.in: Don't check for getpwuid_r here.
+ * prof_file.c (profile_open_file): Use k5_getpwuid_r.
+
2005-03-03 Ken Raeburn <raeburn@mit.edu>
* prof_tree.c (profile_node_iterator): After checking skip_num
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(long)
AC_CHECK_HEADERS(unistd.h stdlib.h pwd.h)
-AC_CHECK_FUNCS(stat access strdup getpwuid_r)
+AC_CHECK_FUNCS(stat access strdup)
AC_PROG_AWK
AC_KRB5_TCL
DO_TCL=
#ifdef HAVE_PWD_H
if (home_env == NULL) {
uid_t uid;
- struct passwd *pw;
-#ifdef HAVE_GETPWUID_R
- struct passwd pwx;
+ struct passwd *pw, pwx;
char pwbuf[BUFSIZ];
-#endif
uid = getuid();
-#ifndef HAVE_GETPWUID_R
- pw = getpwuid(uid);
-#elif defined(GETPWUID_R_4_ARGS)
- /* earlier POSIX drafts */
- pw = getpwuid_r(uid, &pwx, pwbuf, sizeof(pwbuf));
-#else
- /* POSIX */
- if (getpwuid_r(uid, &pwx, pwbuf, sizeof(pwbuf), &pw) != 0)
- /* Probably already null, but let's make sure. */
- pw = NULL;
-#endif /* getpwuid variants */
- if (pw != NULL && pw->pw_dir[0] != 0)
+ if (!k5_getpwuid_r(uid, &pwx, pwbuf, sizeof(pwbuf), &pw)
+ && pw != NULL && pw->pw_dir[0] != 0)
home_env = pw->pw_dir;
}
#endif