summaryrefslogtreecommitdiff
blob: 68809bcf1b1bad250afa62d6bfcbc1c681c66379 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
diff -c -r nss_ldap-250/ChangeLog nss_ldap-250.1/ChangeLog
*** nss_ldap-250/ChangeLog	Wed Apr 26 18:19:00 2006
--- nss_ldap-250.1/ChangeLog	Wed Aug 16 16:58:57 2006
***************
*** 1,6 ****
--- 1,13 ----
  $Id$
  ===============================================================
  
+ 250.1   Paul B. Henson <henson@acm.org>
+ 
+ 	* add nss_getgrent_skipmembers parameter to ldap.conf,
+ 	  if enabled will not request member attributes for
+ 	  group lookups, greatly increasing performance in the
+ 	  face of large groups
+ 
  250	Luke Howard <lukeh@padl.com>
  
  	* don't use static _nss_ldap_no_members buffer,
diff -c -r nss_ldap-250/ldap-nss.c nss_ldap-250.1/ldap-nss.c
*** nss_ldap-250/ldap-nss.c	Wed Apr 26 18:19:00 2006
--- nss_ldap-250.1/ldap-nss.c	Wed Aug 16 16:51:49 2006
***************
*** 1258,1264 ****
  
    cfg = __config;
  
!   _nss_ldap_init_attributes (cfg->ldc_attrtab);
    _nss_ldap_init_filters ();
  
  #ifdef HAVE_LDAP_SET_OPTION
--- 1258,1264 ----
  
    cfg = __config;
  
!   _nss_ldap_init_attributes (cfg->ldc_attrtab, cfg->ldc_getgrent_skipmembers);
    _nss_ldap_init_filters ();
  
  #ifdef HAVE_LDAP_SET_OPTION
diff -c -r nss_ldap-250/ldap-nss.h nss_ldap-250.1/ldap-nss.h
*** nss_ldap-250/ldap-nss.h	Wed Apr 26 18:19:00 2006
--- nss_ldap-250.1/ldap-nss.h	Wed Aug 16 16:51:59 2006
***************
*** 390,395 ****
--- 390,396 ----
    time_t ldc_mtime;
  
    char **ldc_initgroups_ignoreusers;
+   int ldc_getgrent_skipmembers;
  };
  
  typedef struct ldap_config ldap_config_t;
diff -c -r nss_ldap-250/ldap-schema.c nss_ldap-250.1/ldap-schema.c
*** nss_ldap-250/ldap-schema.c	Wed Apr 26 18:19:00 2006
--- nss_ldap-250.1/ldap-schema.c	Wed Aug 16 16:54:52 2006
***************
*** 273,279 ****
  
  static void init_pwd_attributes (const char ***pwd_attrs);
  static void init_sp_attributes (const char ***sp_attrs);
! static void init_grp_attributes (const char ***grp_attrs);
  static void init_hosts_attributes (const char ***hosts_attrs);
  static void init_services_attributes (const char ***services_attrs);
  static void init_network_attributes (const char ***network_attrs);
--- 273,279 ----
  
  static void init_pwd_attributes (const char ***pwd_attrs);
  static void init_sp_attributes (const char ***sp_attrs);
! static void init_grp_attributes (const char ***grp_attrs, int ldc_getgrent_skipmembers);
  static void init_hosts_attributes (const char ***hosts_attrs);
  static void init_services_attributes (const char ***services_attrs);
  static void init_network_attributes (const char ***network_attrs);
***************
*** 289,299 ****
   * attribute table initialization routines
   */
  void
! _nss_ldap_init_attributes (const char ***attrtab)
  {
    init_pwd_attributes (&attrtab[LM_PASSWD]);
    init_sp_attributes (&attrtab[LM_SHADOW]);
!   init_grp_attributes (&attrtab[LM_GROUP]);
    init_hosts_attributes (&attrtab[LM_HOSTS]);
    init_services_attributes (&attrtab[LM_SERVICES]);
    init_network_attributes (&attrtab[LM_NETWORKS]);
--- 289,299 ----
   * attribute table initialization routines
   */
  void
! _nss_ldap_init_attributes (const char ***attrtab, int ldc_getgrent_skipmembers)
  {
    init_pwd_attributes (&attrtab[LM_PASSWD]);
    init_sp_attributes (&attrtab[LM_SHADOW]);
!   init_grp_attributes (&attrtab[LM_GROUP], ldc_getgrent_skipmembers);
    init_hosts_attributes (&attrtab[LM_HOSTS]);
    init_services_attributes (&attrtab[LM_SERVICES]);
    init_network_attributes (&attrtab[LM_NETWORKS]);
***************
*** 357,363 ****
  }
  
  static void
! init_grp_attributes (const char ***grp_attrs)
  {
    int i = 0;
    static const char *__grp_attrs[ATTRTAB_SIZE + 1];
--- 357,363 ----
  }
  
  static void
! init_grp_attributes (const char ***grp_attrs, int ldc_getgrent_skipmembers)
  {
    int i = 0;
    static const char *__grp_attrs[ATTRTAB_SIZE + 1];
***************
*** 366,374 ****
  
    (*grp_attrs)[i++] = (char *) ATM (LM_GROUP, cn);
    (*grp_attrs)[i++] = (char *) ATM (LM_GROUP, userPassword);
!   (*grp_attrs)[i++] = (char *) AT (memberUid);
!   if (_nss_ldap_test_config_flag (NSS_LDAP_FLAGS_RFC2307BIS))
!     (*grp_attrs)[i++] = (char *) AT (uniqueMember);
    (*grp_attrs)[i++] = (char *) ATM (LM_GROUP, gidNumber);
    (*grp_attrs)[i] = NULL;
  }
--- 366,377 ----
  
    (*grp_attrs)[i++] = (char *) ATM (LM_GROUP, cn);
    (*grp_attrs)[i++] = (char *) ATM (LM_GROUP, userPassword);
!   if (!ldc_getgrent_skipmembers)
!     {
!       (*grp_attrs)[i++] = (char *) AT (memberUid);
!       if (_nss_ldap_test_config_flag (NSS_LDAP_FLAGS_RFC2307BIS))
!         (*grp_attrs)[i++] = (char *) AT (uniqueMember);
!     }
    (*grp_attrs)[i++] = (char *) ATM (LM_GROUP, gidNumber);
    (*grp_attrs)[i] = NULL;
  }
diff -c -r nss_ldap-250/ldap-schema.h nss_ldap-250.1/ldap-schema.h
*** nss_ldap-250/ldap-schema.h	Wed Apr 26 18:19:00 2006
--- nss_ldap-250.1/ldap-schema.h	Wed Aug 16 16:54:07 2006
***************
*** 30,36 ****
   * function to initialize global lookup filters.
   */
  void _nss_ldap_init_filters ();
! void _nss_ldap_init_attributes (const char ***attrtab);
  
  /**
   * make filters formerly declared in ldap-*.h globally available.
--- 30,36 ----
   * function to initialize global lookup filters.
   */
  void _nss_ldap_init_filters ();
! void _nss_ldap_init_attributes (const char ***attrtab, int ldc_getgrent_skipmembers);
  
  /**
   * make filters formerly declared in ldap-*.h globally available.
diff -c -r nss_ldap-250/nss_ldap.5 nss_ldap-250.1/nss_ldap.5
*** nss_ldap-250/nss_ldap.5	Wed Apr 26 18:19:00 2006
--- nss_ldap-250.1/nss_ldap.5	Wed Aug 16 17:07:19 2006
***************
*** 445,450 ****
--- 445,458 ----
  to return NSS_STATUS_NOTFOUND if called with a listed users as
  its argument.
  .TP
+ .B nss_getgrent_skipmembers <yes|no>
+ Specifies whether or not to populate the members list in
+ the group structure for group lookups. If very large groups
+ are present, enabling this option will greatly increase
+ perforance, at the cost of some lost functionality. You should
+ verify no local applications rely on this information before
+ enabling this on a production system.
+ .TP
  .B nss_srv_domain <domain>
  This option determines the DNS domain used for performing SRV
  lookups.
diff -c -r nss_ldap-250/util.c nss_ldap-250.1/util.c
*** nss_ldap-250/util.c	Wed Apr 26 18:19:00 2006
--- nss_ldap-250.1/util.c	Wed Aug 16 16:52:55 2006
***************
*** 660,665 ****
--- 660,666 ----
    result->ldc_reconnect_maxsleeptime = LDAP_NSS_MAXSLEEPTIME;
    result->ldc_reconnect_maxconntries = LDAP_NSS_MAXCONNTRIES;
    result->ldc_initgroups_ignoreusers = NULL;
+   result->ldc_getgrent_skipmembers = 0;
  
    for (i = 0; i <= LM_NONE; i++)
      {
***************
*** 1137,1142 ****
--- 1138,1156 ----
  	      break;
  	    }
  	}
+       else if (!strcasecmp (k, NSS_LDAP_KEY_GETGRENT_SKIPMEMBERS))
+ 	{
+ 	  if (!strcasecmp (v, "on") || !strcasecmp (v, "yes")
+ 	      || !strcasecmp (v, "true"))
+ 	    {
+ 	      result->ldc_getgrent_skipmembers = 1;
+ 	    }
+ 	  else if (!strcasecmp (v, "off") || !strcasecmp (v, "no")
+ 		   || !strcasecmp (v, "false"))
+ 	    {
+ 	      result->ldc_getgrent_skipmembers = 0;
+ 	    }
+ 	}
        else if (!strcasecmp (k, NSS_LDAP_KEY_CONNECT_POLICY))
          {
  	  if (!strcasecmp (v, "oneshot"))
diff -c -r nss_ldap-250/util.h nss_ldap-250.1/util.h
*** nss_ldap-250/util.h	Wed Apr 26 18:19:00 2006
--- nss_ldap-250.1/util.h	Wed Aug 16 16:49:52 2006
***************
*** 83,88 ****
--- 83,89 ----
  #define NSS_LDAP_KEY_PAGESIZE		"pagesize"
  #define NSS_LDAP_KEY_INITGROUPS		"nss_initgroups"
  #define NSS_LDAP_KEY_INITGROUPS_IGNOREUSERS	"nss_initgroups_ignoreusers"
+ #define NSS_LDAP_KEY_GETGRENT_SKIPMEMBERS	"nss_getgrent_skipmembers"
  
  /* more reconnect policy fine-tuning */
  #define NSS_LDAP_KEY_RECONNECT_TRIES		"nss_reconnect_tries"