]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
build: Drop support for non-POSIX getpwnam_r(), getgrnam_r()
authorSimon McVittie <smcv@collabora.com>
Mon, 22 Oct 2018 13:52:01 +0000 (14:52 +0100)
committerSimon McVittie <smcv@collabora.com>
Mon, 19 Nov 2018 11:27:38 +0000 (11:27 +0000)
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 <smcv@collabora.com>
cmake/ConfigureChecks.cmake
cmake/config.h.cmake
configure.ac
dbus/dbus-sysdeps-unix.c
dbus/dbus-sysdeps-util-unix.c

index 310b1bbba2c13e36565b9a8b68d652d70c5e1ec6..8571e2160e00c1ca11a488ce89b932b06592f975 100644 (file)
@@ -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
index d223881662bd26e77145890a9c12d36261e4ab40..15f3490977eb544f3244b7af27ca1b1ff9d15ad8 100644 (file)
 #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
index 89337836275aab353a5133e2f7f64d9e6a28c19b..668d55395471782256c473caca2b69ed901cfc81 100644 (file)
@@ -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 <errno.h>
-#include <pwd.h>
-]],
-[[
-    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 <pwd.h>]], [[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)
index 2b1c60691cdaf2989c5b171175f60c7b8cc5db8a..77afae525ad9d5ca50679e0675b8cd561d7e2b22 100644 (file)
@@ -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
index 262dcfdedca56046eb763ba20827d9db6ad266c5..f5e56c080c08b3d349faa979d57aaf3b5d611d50 100644 (file)
@@ -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)