[glib] Stop supporting non-POSIX getpwuid_r, getgrgid_r



commit aa16359986a1cf5a77a70cb4f92e1f99de233572
Author: Ryan Lortie <desrt desrt ca>
Date:   Fri Oct 16 12:36:58 2015 +0100

    Stop supporting non-POSIX getpwuid_r, getgrgid_r
    
    Bug 13403 introduced support for the non-POSIX variants of these APIs
    found on a system called "DG/UX".  Meanwhile, the complicated checks
    here are breaking cross-builds on systems that we actually care about.
    
    Remove the complicated checks and replace them with AC_CHECK_FUNCS.
    Remove the resulting dead code from a couple of .c files.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=756475

 configure.ac         |   84 ++------------------------------------------------
 gio/glocalfileinfo.c |    8 +---
 glib/gutils.c        |   22 +------------
 3 files changed, 7 insertions(+), 107 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 13489a7..6f8aad5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2052,85 +2052,8 @@ glib_save_LIBS="$LIBS"
 # we are not doing the following for now, as this might require glib 
 # to always be linked with the thread libs on some platforms. 
 # LIBS="$LIBS $G_THREAD_LIBS"
-AC_CHECK_FUNCS(localtime_r gmtime_r)
-AS_IF([ test "$glib_native_win32" != "yes"], [
-       AC_CACHE_CHECK([for posix getpwuid_r],
-               ac_cv_func_posix_getpwuid_r,
-               [AC_TRY_RUN([
-#include <errno.h>
-#include <pwd.h>
-int main () { 
-    char buffer[10000];
-    struct passwd pwd, *pwptr = &pwd;
-    int error;
-    errno = 0;
-    error = getpwuid_r (0, &pwd, buffer, 
-                        sizeof (buffer), &pwptr);
-   return (error < 0 && errno == ENOSYS) 
-          || error == ENOSYS; 
-}                               ],
-                       [ac_cv_func_posix_getpwuid_r=yes],
-                       [ac_cv_func_posix_getpwuid_r=no])])
-       GLIB_ASSERT_SET(ac_cv_func_posix_getpwuid_r)
-       if test "$ac_cv_func_posix_getpwuid_r" = yes; then
-               AC_DEFINE(HAVE_POSIX_GETPWUID_R,1,
-                       [Have POSIX function getpwuid_r])
-       else
-               AC_CACHE_CHECK([for nonposix getpwuid_r],
-                       ac_cv_func_nonposix_getpwuid_r,
-                       [AC_TRY_LINK([#include <pwd.h>],
-                               [char buffer[10000];
-                               struct passwd pwd;
-                               getpwuid_r (0, &pwd, buffer, 
-                                               sizeof (buffer));],
-                               [ac_cv_func_nonposix_getpwuid_r=yes],
-                               [ac_cv_func_nonposix_getpwuid_r=no])])
-               GLIB_ASSERT_SET(ac_cv_func_nonposix_getpwuid_r)
-               if test "$ac_cv_func_nonposix_getpwuid_r" = yes; then
-                       AC_DEFINE(HAVE_NONPOSIX_GETPWUID_R,1,
-                               [Have non-POSIX function getpwuid_r])
-               fi
-       fi
-])
-AS_IF([ test "$glib_native_win32" != "yes"], [
-       AC_CACHE_CHECK([for posix getgrgid_r],
-               ac_cv_func_posix_getgrgid_r,
-               [AC_TRY_RUN([
-#include <errno.h>
-#include <grp.h>
-int main () { 
-    char buffer[10000];
-    struct group grp, *grpptr = &grp;
-    int error;
-    errno = 0;
-    error = getgrgid_r (0, &grp, buffer, 
-                        sizeof (buffer), &grpptr);
-   return (error < 0 && errno == ENOSYS) 
-          || error == ENOSYS; 
-}                              ],
-                      [ac_cv_func_posix_getgrgid_r=yes],
-                      [ac_cv_func_posix_getgrgid_r=no])])
-       GLIB_ASSERT_SET(ac_cv_func_posix_getgrgid_r)
-       AS_IF([ test "$ac_cv_func_posix_getgrgid_r" = yes ], [
-               AC_DEFINE(HAVE_POSIX_GETGRGID_R,1,
-                       [Have POSIX function getgrgid_r])
-       ], [
-               AC_CACHE_CHECK([for nonposix getgrgid_r],
-                       ac_cv_func_nonposix_getgrgid_r,
-                       [AC_TRY_LINK([#include <grp.h>],
-                                       [char buffer[10000];
-                               struct group grp;       
-                               getgrgid_r (0, &grp, buffer, 
-                                       sizeof (buffer));],
-                       [ac_cv_func_nonposix_getgrgid_r=yes],
-                       [ac_cv_func_nonposix_getgrgid_r=no])])
-               GLIB_ASSERT_SET(ac_cv_func_nonposix_getgrgid_r)
-               if test "$ac_cv_func_nonposix_getgrgid_r" = yes; then
-                       AC_DEFINE(HAVE_NONPOSIX_GETGRGID_R,1,
-                               [Have non-POSIX function getgrgid_r])
-               fi
-       ])
-])
+AC_CHECK_FUNCS(localtime_r gmtime_r getpwuid_r getgrgid_r)
+
 LIBS="$G_THREAD_LIBS $LIBS"
 AS_IF([ test x"$have_threads" = xposix], [
         glib_save_CPPFLAGS="$CPPFLAGS"
@@ -2180,8 +2103,7 @@ AS_IF([ test x"$have_threads" = xposix], [
 LIBS="$glib_save_LIBS"
 
 # now spit out all the warnings.
-if test "$ac_cv_func_posix_getpwuid_r" != "yes" && 
-   test "$ac_cv_func_nonposix_getpwuid_r" != "yes"; then
+if test "$ac_cv_func_getpwuid_r" != "yes"; then
        AC_MSG_WARN($FUNC_NO_GETPWUID_R)
 fi
 if test "$ac_cv_func_localtime_r" != "yes"; then
diff --git a/gio/glocalfileinfo.c b/gio/glocalfileinfo.c
index 75bcef4..620320f 100644
--- a/gio/glocalfileinfo.c
+++ b/gio/glocalfileinfo.c
@@ -1096,10 +1096,8 @@ lookup_uid_data (uid_t uid)
 
   data = g_new0 (UidData, 1);
 
-#if defined(HAVE_POSIX_GETPWUID_R)
+#if defined(HAVE_GETPWUID_R)
   getpwuid_r (uid, &pwbuf, buffer, sizeof(buffer), &pwbufp);
-#elif defined(HAVE_NONPOSIX_GETPWUID_R)
-  pwbufp = getpwuid_r (uid, &pwbuf, buffer, sizeof(buffer));
 #else
   pwbufp = getpwuid (uid);
 #endif
@@ -1184,10 +1182,8 @@ lookup_gid_name (gid_t gid)
   if (name)
     return name;
 
-#if defined (HAVE_POSIX_GETGRGID_R)
+#if defined (HAVE_GETGRGID_R)
   getgrgid_r (gid, &gbuf, buffer, sizeof(buffer), &gbufp);
-#elif defined (HAVE_NONPOSIX_GETGRGID_R)
-  gbufp = getgrgid_r (gid, &gbuf, buffer, sizeof(buffer));
 #else
   gbufp = getgrgid (gid);
 #endif
diff --git a/glib/gutils.c b/glib/gutils.c
index e82ce54..ee465d9 100644
--- a/glib/gutils.c
+++ b/glib/gutils.c
@@ -626,7 +626,7 @@ g_get_user_database_entry (void)
         gint error;
         gchar *logname;
 
-#  if defined (HAVE_POSIX_GETPWUID_R) || defined (HAVE_NONPOSIX_GETPWUID_R)
+#  if defined (HAVE_GETPWUID_R)
         struct passwd pwd;
 #    ifdef _SC_GETPW_R_SIZE_MAX
         /* This reurns the maximum length */
@@ -649,7 +649,6 @@ g_get_user_database_entry (void)
             buffer = g_malloc (bufsize + 6);
             errno = 0;
 
-#    ifdef HAVE_POSIX_GETPWUID_R
             if (logname) {
               error = getpwnam_r (logname, &pwd, buffer, bufsize, &pw);
               if (!pw || (pw->pw_uid != getuid ())) {
@@ -660,23 +659,6 @@ g_get_user_database_entry (void)
               error = getpwuid_r (getuid (), &pwd, buffer, bufsize, &pw);
             }
             error = error < 0 ? errno : error;
-#    else /* HAVE_NONPOSIX_GETPWUID_R */
-#      if defined(_AIX)
-            error = getpwuid_r (getuid (), &pwd, buffer, bufsize);
-            pw = error == 0 ? &pwd : NULL;
-#      else /* !_AIX */
-            if (logname) {
-              pw = getpwnam_r (logname, &pwd, buffer, bufsize);
-              if (!pw || (pw->pw_uid != getuid ())) {
-                /* LOGNAME is lying, fall back to looking up the uid */
-                pw = getpwuid_r (getuid (), &pwd, buffer, bufsize);
-              }
-            } else {
-              pw = getpwuid_r (getuid (), &pwd, buffer, bufsize);
-            }
-            error = pw ? 0 : errno;
-#      endif /* !_AIX */
-#    endif /* HAVE_NONPOSIX_GETPWUID_R */
 
             if (!pw)
               {
@@ -702,7 +684,7 @@ g_get_user_database_entry (void)
               }
           }
         while (!pw);
-#  endif /* HAVE_POSIX_GETPWUID_R || HAVE_NONPOSIX_GETPWUID_R */
+#  endif /* HAVE_GETPWUID_R */
 
         if (!pw)
           {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]