Print this page
*** NO COMMENTS ***

@@ -21,23 +21,22 @@
  */
 
 /*
  * Copyright (c) 1996, by Sun Microsystems, Inc.
  * All rights reserved.
+ *
+ * Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
  */
                                                             
-#ident  "%Z%%M% %I%     %E% SMI"        /* SMI4.1 1.5 */
-
+#include <stdlib.h>
 #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.

@@ -51,61 +50,39 @@
 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()
+void
+freegrouplist(revhandle_t *hdl)
 {
-        struct grouplist *gl;
+        struct grouplist *gl, *next;
 
-        for (gl = grouplist; gl != NULL; gl = gl->gl_nxt) {
+        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);
         }
-        grouplist = NULL;
+        hdl->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;
+void
+doit(char *group, struct list *list, revhandle_t *hdl)
 {
         register char *p, *q;
         register struct list *ls;
         struct list tmplist;
         char *val;

@@ -113,11 +90,11 @@
 
 
         /*
          * check for non-existing groups
          */
-        if ((val = match(group)) == NULL) {
+        if ((val = match(group, hdl)) == NULL) {
                 return;
         }
 
 
         /*

@@ -155,18 +132,18 @@
                                 goto syntax_error;
                         }
                         if (!(p = fill(p, &gpls->gl_domain, ')'))) {
                                 goto syntax_error;
                         }
-                        gpls->gl_nxt = grouplist;
-                        grouplist = gpls;
+                        gpls->gl_nxt = hdl->grouplist;
+                        hdl->grouplist = gpls;
                 } else {
                         q = any(p, " \t\n#");
                         if (q && *q == '#')
                                 break;
                         *q = EOS;
-                        doit(p, list);
+                        doit(p, list, hdl);
                         *q = ' ';
                 }
                 p = any(p, " \t");
         }
         return;

@@ -240,10 +217,9 @@
 
 /*
  * The equivalent of yp_match. Returns the match, or NULL if there is none.
  */
 static char *
-match(group)
-        char *group;
+match(char *group, revhandle_t *hdl)
 {
-        return (lookup(ngtable, group));
+        return (lookup(hdl->ngtable, group));
 }