>From 1ef299a66faa06becdd9bdb30ee6736a823e184b Mon Sep 17 00:00:00 2001 From: Markus Duft Date: Thu, 8 Sep 2011 13:09:27 +0200 Subject: [PATCH 2/2] add support for getgr*_nomembers functions on interix. 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. Signed-off-by: Markus Duft --- m4/jm-macros.m4 | 9 +++++++++ src/system.h | 13 +++++++++++++ 2 files changed, 22 insertions(+), 0 deletions(-) diff --git a/m4/jm-macros.m4 b/m4/jm-macros.m4 index 58b000d..a6de8f1 100644 --- a/m4/jm-macros.m4 +++ b/m4/jm-macros.m4 @@ -89,6 +89,15 @@ AC_DEFUN([coreutils_MACROS], tcgetpgrp \ ) + # those checks exists for interix, where there are blazingly fast + # replacements for some functions, that don't query the domain + # controller for user information where 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 diff --git a/src/system.h b/src/system.h index 107dbd5..3e44f89 100644 --- a/src/system.h +++ b/src/system.h @@ -213,6 +213,19 @@ 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), so use them. */ +#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 + #if !HAVE_DECL_GETUID uid_t getuid (); #endif -- 1.7.6.1