Received: by taz.hyperreal.com (8.6.12/8.6.5) id QAA27098; Wed, 25 Oct 1995 16:51:21 -0700 Received: from life.ai.mit.edu by taz.hyperreal.com (8.6.12/8.6.5) with SMTP id QAA27088; Wed, 25 Oct 1995 16:51:11 -0700 Received: from volterra.ai.mit.edu by life.ai.mit.edu (4.1/AI-4.10) for new-httpd@hyperreal.com id AA24321; Wed, 25 Oct 95 19:51:10 EDT From: rst@ai.mit.edu (Robert S. Thau) Received: by volterra.ai.mit.edu (8.6.12/AI-4.10) id TAA15238; Wed, 25 Oct 1995 19:51:08 -0400 Date: Wed, 25 Oct 1995 19:51:08 -0400 Message-Id: <199510252351.TAA15238@volterra.ai.mit.edu> To: new-httpd@hyperreal.com Subject: Another patch for groups with multiple lines in .htgroup Sender: owner-new-httpd@apache.org Precedence: bulk Reply-To: new-httpd@apache.org Here's a substantially simpler patch for the .htgroups problem. It reuses the existing code wherever possible, and introduces relatively little entirely new stuff. This patch cuts back dramatically on consing for .htgroups reading (only allocating enough memory for a single line). For simplicity's sake, it retains the 8K restriction on the length of single lines in the .htgroups file; this is at least backwards compatible with everybody, and I don't expect it to pose a serious problem for anyone in practice. From: rst@ai.mit.edu Subject: Fix problem with multiple lines in htgroup for same group Affects: mod_auth.c ChangeLog: Fixes problem with multiple lines in htgroup for same group *** mod_auth.c.old Tue Oct 10 18:00:29 1995 --- mod_auth.c Wed Oct 25 17:07:27 1995 *************** *** 110,149 **** return NULL; } ! table *init_group(pool *p, char *grpfile) { FILE *f; table *grps = make_table (p, 15); char l[MAX_STRING_LEN]; ! char *name, *ll; if(!(f=pfopen(p, grpfile, "r"))) return NULL; while(!(cfg_getline(l,MAX_STRING_LEN,f))) { if((l[0] == '#') || (!l[0])) continue; ll = l; ! name = getword(p, &ll, ':'); ! table_set (grps, name, ll); } pfclose(p, f); return grps; } - int in_group(pool *p, char *user, char *group, table *grps) { - char *l = table_get (grps, group); - char *w; - - if (!l) return 0; - - while(l[0]) { - w = getword_conf (p, &l); - if(!strcmp(w,user)) - return 1; - } - - return 0; - } - /* These functions return 0 if client is OK, and proper error status * if not... either AUTH_REQUIRED, if we made a check, and it failed, or * SERVER_ERROR, if things are so totally confused that we couldn't --- 110,147 ---- return NULL; } ! table *groups_for_user (pool *p, char *user, char *grpfile) { FILE *f; table *grps = make_table (p, 15); + pool *sp; char l[MAX_STRING_LEN]; ! char *group_name, *ll, *w; if(!(f=pfopen(p, grpfile, "r"))) return NULL; + sp = make_sub_pool (p); + while(!(cfg_getline(l,MAX_STRING_LEN,f))) { if((l[0] == '#') || (!l[0])) continue; ll = l; ! clear_pool (sp); ! ! group_name = getword(sp, &ll, ':'); ! ! while(ll[0]) { ! w = getword_conf (sp, &ll); ! if(!strcmp(w,user)) { ! table_set (grps, group_name, "in"); ! break; ! } ! } } pfclose(p, f); + destroy_pool (sp); return grps; } /* These functions return 0 if client is OK, and proper error status * if not... either AUTH_REQUIRED, if we made a check, and it failed, or * SERVER_ERROR, if things are so totally confused that we couldn't *************** *** 204,210 **** table *grpstatus; if(sec->auth_grpfile) ! grpstatus = init_group(r->pool, sec->auth_grpfile); else grpstatus = NULL; --- 202,208 ---- table *grpstatus; if(sec->auth_grpfile) ! grpstatus = groups_for_user (r->pool, user, sec->auth_grpfile); else grpstatus = NULL; *************** *** 229,235 **** while(t[0]) { w = getword_conf(r->pool, &t); ! if(in_group(r->pool, user, w, grpstatus)) return OK; } } --- 227,233 ---- while(t[0]) { w = getword_conf(r->pool, &t); ! if(table_get (grpstatus, w)) return OK; } }