diff options
-rw-r--r-- | cmake/ConfigureChecks.cmake | 2 | ||||
-rw-r--r-- | cmake/config.h.cmake | 12 | ||||
-rw-r--r-- | configure.ac | 47 | ||||
-rw-r--r-- | dbus/dbus-sysdeps-unix.c | 12 | ||||
-rw-r--r-- | dbus/dbus-sysdeps-util-unix.c | 9 |
5 files changed, 19 insertions, 63 deletions
diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index 27cd986d..3a1165f0 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 881dfa14..2f9f5413 100644 --- a/cmake/config.h.cmake +++ b/cmake/config.h.cmake @@ -13,6 +13,16 @@ * should be placed in this file */ +/* Opt-in to modern APIs and thread-safety for Solaris. In the Autotools + * build system we do the equivalent of this by appending to CFLAGS + * in configure.ac */ +#ifdef __sun +# define __EXTENSIONS__ +# define _POSIX_PTHREAD_SEMANTICS +# define _REENTRANT +# define _XOPEN_SOURCE 500 +#endif + #cmakedefine DBUS_CONSOLE_AUTH_DIR "@DBUS_CONSOLE_AUTH_DIR@" #cmakedefine DBUS_DATADIR "@DBUS_DATADIR@" #cmakedefine DBUS_BINDIR "@DBUS_BINDIR@" @@ -164,7 +174,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 5cadc09c..ec208bef 100644 --- a/configure.ac +++ b/configure.ac @@ -680,52 +680,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) diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c index 4607f537..71e5d86d 100644 --- a/dbus/dbus-sysdeps-unix.c +++ b/dbus/dbus-sysdeps-unix.c @@ -2656,7 +2656,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; @@ -2685,20 +2685,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) { @@ -2734,6 +2726,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 ccf3d9f5..d29cbd1f 100644 --- a/dbus/dbus-sysdeps-util-unix.c +++ b/dbus/dbus-sysdeps-util-unix.c @@ -824,7 +824,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; @@ -854,17 +854,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 */ @@ -899,6 +894,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) |