Add autoconf checks for getpwnam_r and getgrnam_r.
authorAlan T. DeKok <aland@freeradius.org>
Tue, 2 Sep 2014 12:28:49 +0000 (08:28 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Tue, 2 Sep 2014 12:28:49 +0000 (08:28 -0400)
Right now, only the checks are included.  The functions aren't
used at all.

configure
configure.ac
src/include/autoconf.h.in

index f54c784..0ad2c47 100755 (executable)
--- a/configure
+++ b/configure
@@ -11418,6 +11418,81 @@ if test "x$gethostbynamerstyle" = "xBSD"; then
 $as_echo "$as_me: WARNING:  ****** BSD-style gethostbyname might NOT be thread-safe! ****** " >&2;}
 fi
 
+if test "x$ac_cv_header_pwd_h" = "xyes"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking getpwnam_r" >&5
+$as_echo_n "checking getpwnam_r... " >&6; }
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+      #include <stdlib.h>
+      #include <sys/types.h>
+      #include <pwd.h>
+
+int
+main ()
+{
+ getpwnam_r(NULL, NULL, NULL, 0, NULL)
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+$as_echo "#define HAVE_GETPWNAM_R 1" >>confdefs.h
+
+
+else
+
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+
+if test "x$ac_cv_header_grp_h" = "xyes"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking getgrnam_r" >&5
+$as_echo_n "checking getgrnam_r... " >&6; }
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+      #include <stdlib.h>
+      #include <sys/types.h>
+      #include <grp.h>
+
+int
+main ()
+{
+ getgrnam_r(NULL, NULL, NULL, 0, NULL)
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+$as_echo "#define HAVE_GETGRNAM_R 1" >>confdefs.h
+
+
+else
+
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+
+
 
 $as_echo "#define POSIXSTYLE 1" >>confdefs.h
 
index 819e441..798c72c 100644 (file)
@@ -1861,6 +1861,52 @@ if test "x$gethostbynamerstyle" = "xBSD"; then
 fi
 
 dnl #
+dnl #  Check for thread-safe getpwnam_r and getgrnam_r
+dnl #
+if test "x$ac_cv_header_pwd_h" = "xyes"; then
+  AC_MSG_CHECKING([getpwnam_r])
+  AC_TRY_LINK(
+    [
+      #include <stdlib.h>
+      #include <sys/types.h>
+      #include <pwd.h>
+    ],
+    [ getpwnam_r(NULL, NULL, NULL, 0, NULL) ],
+    [
+      AC_MSG_RESULT([yes])
+      AC_DEFINE(HAVE_GETPWNAM_R, 1,
+                [Define to 1 if you have the getpwnam_r.]
+                )
+    ],
+    [
+        AC_MSG_RESULT(no)
+    ]
+  )
+fi
+
+if test "x$ac_cv_header_grp_h" = "xyes"; then
+  AC_MSG_CHECKING([getgrnam_r])
+  AC_TRY_LINK(
+    [
+      #include <stdlib.h>
+      #include <sys/types.h>
+      #include <grp.h>
+    ],
+    [ getgrnam_r(NULL, NULL, NULL, 0, NULL) ],
+    [
+      AC_MSG_RESULT([yes])
+      AC_DEFINE(HAVE_GETGRNAM_R, 1,
+                [Define to 1 if you have the getgrnam_r.]
+                )
+    ],
+    [
+        AC_MSG_RESULT(no)
+    ]
+  )
+fi
+
+
+dnl #
 dnl #  Check for non-posix solaris ctime_r (extra buflen int arg)
 dnl #
 AC_DEFINE(POSIXSTYLE, [1], [Posix-Style ctime_r])
index 204051b..d547ab0 100644 (file)
@@ -81,6 +81,9 @@
 /* Define to 1 if you have the `getaddrinfo' function. */
 #undef HAVE_GETADDRINFO
 
+/* Define to 1 if you have the getgrnam_r. */
+#undef HAVE_GETGRNAM_R
+
 /* Define to 1 if you have the `getnameinfo' function. */
 #undef HAVE_GETNAMEINFO
 
@@ -93,6 +96,9 @@
 /* Define to 1 if you have the `getpeereid' function. */
 #undef HAVE_GETPEEREID
 
+/* Define to 1 if you have the getpwnam_r. */
+#undef HAVE_GETPWNAM_R
+
 /* Define to 1 if you have the `getresuid' function. */
 #undef HAVE_GETRESUID