Re: [PATCH] Re: glibc and getgrouplist



Hi,

Of course you can't use strverscmp() like that. Another go. Probably
futile but hey.

Leonard.

-- 
mount -t life -o ro /dev/dna /genetic/research

--- configure.ac.000	2005-07-02 12:40:58.000000000 +0200
+++ configure.ac	2005-07-22 16:04:51.000000000 +0200
@@ -169,7 +169,47 @@ dnl 
 
 AC_CHECK_FUNCS([atoll cfgetospeed getsid initgroups memcpy memmove memset \
 		putenv setreuid setuid statfs strerror strftime \
-		sysconf tcgetattr tcsetattr truncate getgrouplist])
+		sysconf tcgetattr tcsetattr truncate])
+
+dnl The GNU libc, versions < 2.3.3 have a buffer overflow in the getgrouplist(3)
+dnl function, so we cannot use that function.
+AC_ARG_WITH(getgrouplist, 
+	[  --with-getgrouplist            Force using getgrouplist on patched glibc systems [[no]]])
+if test "x$with_getgrouplist" == "xyes"; then
+    AC_CHECK_FUNCS([getgrouplist])
+else
+    AC_MSG_CHECKING([for glibc version])
+    AC_LINK_IFELSE([
+#include <gnu/libc-version.h>
+#include <stdio.h>
+int main(void) {
+    return puts(gnu_get_libc_version());
+}
+    ], [
+	mc_glibc_version=`./conftest$ac_exeext`
+	AC_LINK_IFELSE([
+#include <string.h>
+int main (char* str) {
+    int i;
+    if (strverscmp(str, "2.3.3") >= 0)
+	return 1;
+    else
+	return 0;
+}
+	], [
+	    mc_glibc_ge_2_3_3=`./conftest$ac_exeext(${mc_glibc_version})`
+	    if mc_glibc_ge_2_3_3 -eq 1; then
+        	AC_CHECK_FUNCS([getgrouplist])
+	    fi
+	], [
+    	    AC_CHECK_FUNCS([getgrouplist])
+	])
+	AC_MSG_RESULT([${mc_glibc_version}])
+    ], [
+        AC_CHECK_FUNCS([getgrouplist])
+        AC_MSG_RESULT([none])
+    ])
+fi
 
 dnl S-Lang needs all four functions to be defined to use POSIX signal API
 AC_CHECK_FUNCS([sigaction sigemptyset sigprocmask sigaddset], , [slang_signals=no])


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