From: Simon McVittie Date: Mon, 22 Oct 2018 13:52:01 +0000 (+0100) Subject: build: Drop support for non-POSIX getpwnam_r(), getgrnam_r() X-Git-Tag: dbus-1.13.14~9^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e57120cb6535347bc538c00db1ad6cf7cf808878;p=thirdparty%2Fdbus.git build: Drop support for non-POSIX getpwnam_r(), getgrnam_r() Solaris 2.3 and 2.4 took their getpwnam_r() signature from draft 6 of the POSIX threads standard. Since Solaris 2.5 (1995), defining _POSIX_PTHREAD_SEMANTICS opts-in to the non-draft version of getpwnam_r(), and since Solaris 11.4 (2018), the non-draft version is the default. We already use AC_USE_SYSTEM_EXTENSIONS, which defines _POSIX_PTHREAD_SEMANTICS, among other useful macros. Thanks to Alan Coopersmith for assistance with Solaris history. Signed-off-by: Simon McVittie --- diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index 310b1bbba..8571e2160 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -46,7 +46,7 @@ check_symbol_exists(backtrace "execinfo.h" HAVE_BACKTRACE) # check_symbol_exists(getgrouplist "grp.h" HAVE_GETGROUPLIST) # dbus-sysdeps.c check_symbol_exists(getpeerucred "ucred.h" HAVE_GETPEERUCRED) # dbus-sysdeps.c, dbus-sysdeps-win.c check_symbol_exists(nanosleep "time.h" HAVE_NANOSLEEP) # dbus-sysdeps.c -check_symbol_exists(getpwnam_r "errno.h;pwd.h" HAVE_POSIX_GETPWNAM_R) # dbus-sysdeps-util-unix.c +check_symbol_exists(getpwnam_r "errno.h;pwd.h" HAVE_GETPWNAM_R) # dbus-sysdeps-util-unix.c check_symbol_exists(setenv "stdlib.h" HAVE_SETENV) # dbus-sysdeps.c check_symbol_exists(unsetenv "stdlib.h" HAVE_UNSETENV) # dbus-sysdeps.c check_symbol_exists(clearenv "stdlib.h" HAVE_CLEARENV) # dbus-sysdeps.c diff --git a/cmake/config.h.cmake b/cmake/config.h.cmake index d22388166..15f349097 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -167,7 +167,7 @@ #cmakedefine HAVE_NANOSLEEP 1 /* Define to 1 if you have getpwnam_r */ -#cmakedefine HAVE_POSIX_GETPWNAM_R 1 +#cmakedefine HAVE_GETPWNAM_R 1 /* Define to 1 if you have socketpair */ #cmakedefine HAVE_SOCKETPAIR 1 diff --git a/configure.ac b/configure.ac index 893378362..668d55395 100644 --- a/configure.ac +++ b/configure.ac @@ -701,52 +701,7 @@ case $host_os in CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS" ;; esac -# checking for a posix version of getpwnam_r -# if we are cross compiling and can not run the test -# assume getpwnam_r is the posix version -# it is up to the person cross compiling to change -# this behavior if desired -AC_LANG_PUSH(C) -AC_CACHE_CHECK([for posix getpwnam_r], - ac_cv_func_posix_getpwnam_r, - [AC_RUN_IFELSE([AC_LANG_PROGRAM( -[[ -#include -#include -]], -[[ - char buffer[10000]; - struct passwd pwd, *pwptr = &pwd; - int error; - errno = 0; - error = getpwnam_r ("", &pwd, buffer, - sizeof (buffer), &pwptr); - return (error < 0 && errno == ENOSYS) - || error == ENOSYS; -]])], - [ac_cv_func_posix_getpwnam_r=yes], - [ac_cv_func_posix_getpwnam_r=no], - [ac_cv_func_posix_getpwnam_r=yes] -)]) -AC_LANG_POP(C) - -if test "$ac_cv_func_posix_getpwnam_r" = yes; then - AC_DEFINE(HAVE_POSIX_GETPWNAM_R,1, - [Have POSIX function getpwnam_r]) -else - AC_CACHE_CHECK([for nonposix getpwnam_r], - ac_cv_func_nonposix_getpwnam_r, - [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], [[char buffer[10000]; - struct passwd pwd; - getpwnam_r ("", &pwd, buffer, - sizeof (buffer));]])], - [ac_cv_func_nonposix_getpwnam_r=yes], - [ac_cv_func_nonposix_getpwnam_r=no])]) - if test "$ac_cv_func_nonposix_getpwnam_r" = yes; then - AC_DEFINE(HAVE_NONPOSIX_GETPWNAM_R,1, - [Have non-POSIX function getpwnam_r]) - fi -fi +AC_CHECK_FUNCS_ONCE([getpwnam_r]) dnl check for socklen_t AC_MSG_CHECKING(whether socklen_t is defined) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 2b1c60691..77afae525 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -2654,7 +2654,7 @@ fill_user_info (DBusUserInfo *info, * checks */ -#if defined (HAVE_POSIX_GETPWNAM_R) || defined (HAVE_NONPOSIX_GETPWNAM_R) +#ifdef HAVE_GETPWNAM_R { struct passwd *p; int result; @@ -2683,20 +2683,12 @@ fill_user_info (DBusUserInfo *info, } p = NULL; -#ifdef HAVE_POSIX_GETPWNAM_R if (uid != DBUS_UID_UNSET) result = getpwuid_r (uid, &p_str, buf, buflen, &p); else result = getpwnam_r (username_c, &p_str, buf, buflen, &p); -#else - if (uid != DBUS_UID_UNSET) - p = getpwuid_r (uid, &p_str, buf, buflen); - else - p = getpwnam_r (username_c, &p_str, buf, buflen); - result = 0; -#endif /* !HAVE_POSIX_GETPWNAM_R */ //Try a bigger buffer if ERANGE was returned if (result == ERANGE && buflen < 512 * 1024) { @@ -2732,6 +2724,8 @@ fill_user_info (DBusUserInfo *info, /* I guess we're screwed on thread safety here */ struct passwd *p; +#warning getpwnam_r() not available, please report this to the dbus maintainers with details of your OS + if (uid != DBUS_UID_UNSET) p = getpwuid (uid); else diff --git a/dbus/dbus-sysdeps-util-unix.c b/dbus/dbus-sysdeps-util-unix.c index 262dcfded..f5e56c080 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -808,7 +808,7 @@ fill_group_info (DBusGroupInfo *info, * to add more configure checks. */ -#if defined (HAVE_POSIX_GETPWNAM_R) || defined (HAVE_NONPOSIX_GETPWNAM_R) +#ifdef HAVE_GETPWNAM_R { struct group *g; int result; @@ -838,17 +838,12 @@ fill_group_info (DBusGroupInfo *info, } g = NULL; -#ifdef HAVE_POSIX_GETPWNAM_R if (group_c_str) result = getgrnam_r (group_c_str, &g_str, buf, buflen, &g); else result = getgrgid_r (gid, &g_str, buf, buflen, &g); -#else - g = getgrnam_r (group_c_str, &g_str, buf, buflen); - result = 0; -#endif /* !HAVE_POSIX_GETPWNAM_R */ /* Try a bigger buffer if ERANGE was returned: https://bugs.freedesktop.org/show_bug.cgi?id=16727 */ @@ -883,6 +878,8 @@ fill_group_info (DBusGroupInfo *info, /* I guess we're screwed on thread safety here */ struct group *g; +#warning getpwnam_r() not available, please report this to the dbus maintainers with details of your OS + g = getgrnam (group_c_str); if (g != NULL)