]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
build: use getgr*_nomembers functions on Interix
authorMarkus Duft <mduft@gentoo.org>
Thu, 8 Sep 2011 11:09:27 +0000 (13:09 +0200)
committerJim Meyering <meyering@redhat.com>
Sat, 1 Oct 2011 17:17:26 +0000 (19:17 +0200)
Interix provides faster replacements for getgr{gid,nam,ent} where
group member information is not fetched from domain controllers.
This makes 'id' usable on domain controlled interix boxes.
* m4/jm-macros.m4: Check for _nomembers functions.
* src/system.h: Redefine function to _nomembers when available.

m4/jm-macros.m4
src/system.h

index 58b000d3f74409bfe9377fe3178b0d4d6f156994..dc68f3b618edcb9e9e853caf6f6be081d612bb72 100644 (file)
@@ -89,6 +89,16 @@ AC_DEFUN([coreutils_MACROS],
     tcgetpgrp \
   )
 
+  # These checks are for Interix, to avoid its getgr* functions, in favor
+  # of these replacements.  The replacement functions are much more efficient
+  # because they do not query the domain controller for user information
+  # when it is not needed.
+  AC_CHECK_FUNCS_ONCE([
+    getgrgid_nomembers
+    getgrnam_nomembers
+    getgrent_nomembers
+  ])
+
   dnl This can't use AC_REQUIRE; I'm not quite sure why.
   cu_PREREQ_STAT_PROG
 
index ec64cd0d878a81c7a780a1cdf19145328698c00d..18ac0cc9f5b128680b8e462b6bfe6f1954a42991 100644 (file)
@@ -213,6 +213,24 @@ struct passwd *getpwuid ();
 struct group *getgrgid ();
 #endif
 
+/* Interix has replacements for getgr{gid,nam,ent}, that don't
+   query the domain controller for group members when not required.
+   This speeds up the calls tremendously (<1 ms vs. >3 s). */
+/* To protect any system that could provide _nomembers functions
+   other than interix, check for HAVE_SETGROUPS, as interix is
+   one of the very few (the only?) platform that lacks it */
+#if ! HAVE_SETGROUPS
+# if HAVE_GETGRGID_NOMEMBERS
+#  define getgrgid(gid) getgrgid_nomembers(gid)
+# endif
+# if HAVE_GETGRNAM_NOMEMBERS
+#  define getgrnam(nam) getgrnam_nomembers(nam)
+# endif
+# if HAVE_GETGRENT_NOMEMBERS
+#  define getgrent() getgrent_nomembers()
+# endif
+#endif
+
 #if !HAVE_DECL_GETUID
 uid_t getuid ();
 #endif