[PATCH] Re: glibc and getgrouplist



Hi,

On Fri, 2005-07-22 at 15:24, Leonard den Ottolander wrote:
> And totally untested. From a standpoint of a proper release procedure
> and stabilizing the tree before a release instead of introducing
> untested code I vote against and once more suggest to go with a patch to
> configure.ac for PRE.

Would this be a correct implementation of that proposal? Patch only
affects configure.ac and doesn't check for getgrouplist() in case glibc
< 2.3.3 and the user hasn't overridden it --with-getgrouplist.

Note that I have hardly any experience with patching configure.ac files,
so if people agree this is a more safe approach at this point I'd like
some feedback on the patch.

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 15:33:21.000000000 +0200
@@ -169,7 +169,33 @@ 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`
+    if [ strverscmp(${mc_glibc_version}, "2.3.3") >= 0 ]; then
+        AC_CHECK_FUNCS([getgrouplist])
+    fi
+    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]