Print this page
*** NO COMMENTS ***

*** 21,43 **** */ /* * Copyright (c) 1996, by Sun Microsystems, Inc. * All rights reserved. */ ! #ident "%Z%%M% %I% %E% SMI" /* SMI4.1 1.5 */ ! #include <stdio.h> #include <ctype.h> #include <string.h> #include "table.h" #include "util.h" #include "getgroup.h" - #define MAXGROUPLEN 1024 - /* * Stolen mostly, from getnetgrent.c * * my_getgroup() performs the same function as _getgroup(), but operates * on /etc/netgroup directly, rather than doing yp lookups. --- 21,42 ---- */ /* * Copyright (c) 1996, by Sun Microsystems, Inc. * All rights reserved. + * + * Copyright 2012 Nexenta Systems, Inc. All rights reserved. */ ! #include <stdlib.h> #include <stdio.h> #include <ctype.h> #include <string.h> #include "table.h" #include "util.h" #include "getgroup.h" /* * Stolen mostly, from getnetgrent.c * * my_getgroup() performs the same function as _getgroup(), but operates * on /etc/netgroup directly, rather than doing yp lookups.
*** 51,111 **** struct list { char *name; struct list *nxt; }; - - extern stringtable ngtable; /* stored info from /etc/netgroup */ - - static struct grouplist *grouplist; /* stores a list of users in a group */ - static char *any(); static char *match(); static char *fill(); - static void freegrouplist(); - static void doit(); ! ! static void ! freegrouplist() { ! struct grouplist *gl; ! for (gl = grouplist; gl != NULL; gl = gl->gl_nxt) { FREE(gl->gl_name); FREE(gl->gl_domain); FREE(gl->gl_machine); FREE(gl); } ! grouplist = NULL; } - - struct grouplist * - my_getgroup(group) - char *group; - { - freegrouplist(); - doit(group, (struct list *) NULL); - return (grouplist); - } - - - - - /* * recursive function to find the members of netgroup "group". "list" is * the path followed through the netgroups so far, to check for cycles. */ ! static void ! doit(group, list) ! char *group; ! struct list *list; { register char *p, *q; register struct list *ls; struct list tmplist; char *val; --- 50,88 ---- struct list { char *name; struct list *nxt; }; static char *any(); static char *match(); static char *fill(); ! void ! freegrouplist(revhandle_t *hdl) { ! struct grouplist *gl, *next; ! for (gl = hdl->grouplist; gl != NULL; gl = next) { ! next = gl->gl_nxt; ! FREE(gl->gl_name); FREE(gl->gl_domain); FREE(gl->gl_machine); FREE(gl); } ! hdl->grouplist = NULL; } /* * recursive function to find the members of netgroup "group". "list" is * the path followed through the netgroups so far, to check for cycles. */ ! void ! doit(char *group, struct list *list, revhandle_t *hdl) { register char *p, *q; register struct list *ls; struct list tmplist; char *val;
*** 113,123 **** /* * check for non-existing groups */ ! if ((val = match(group)) == NULL) { return; } /* --- 90,100 ---- /* * check for non-existing groups */ ! if ((val = match(group, hdl)) == NULL) { return; } /*
*** 155,172 **** goto syntax_error; } if (!(p = fill(p, &gpls->gl_domain, ')'))) { goto syntax_error; } ! gpls->gl_nxt = grouplist; ! grouplist = gpls; } else { q = any(p, " \t\n#"); if (q && *q == '#') break; *q = EOS; ! doit(p, list); *q = ' '; } p = any(p, " \t"); } return; --- 132,149 ---- goto syntax_error; } if (!(p = fill(p, &gpls->gl_domain, ')'))) { goto syntax_error; } ! gpls->gl_nxt = hdl->grouplist; ! hdl->grouplist = gpls; } else { q = any(p, " \t\n#"); if (q && *q == '#') break; *q = EOS; ! doit(p, list, hdl); *q = ' '; } p = any(p, " \t"); } return;
*** 240,249 **** /* * The equivalent of yp_match. Returns the match, or NULL if there is none. */ static char * ! match(group) ! char *group; { ! return (lookup(ngtable, group)); } --- 217,225 ---- /* * The equivalent of yp_match. Returns the match, or NULL if there is none. */ static char * ! match(char *group, revhandle_t *hdl) { ! return (lookup(hdl->ngtable, group)); }