Home | History | Annotate | Line # | Download | only in irs
nis_gr.c revision 1.1.1.1.6.2
      1  1.1.1.1.6.2  riz /*	$NetBSD: nis_gr.c,v 1.1.1.1.6.2 2011/01/09 20:42:56 riz Exp $	*/
      2  1.1.1.1.6.2  riz 
      3  1.1.1.1.6.2  riz /*
      4  1.1.1.1.6.2  riz  * Copyright (c) 1989, 1993, 1995
      5  1.1.1.1.6.2  riz  *	The Regents of the University of California.  All rights reserved.
      6  1.1.1.1.6.2  riz  *
      7  1.1.1.1.6.2  riz  * Redistribution and use in source and binary forms, with or without
      8  1.1.1.1.6.2  riz  * modification, are permitted provided that the following conditions
      9  1.1.1.1.6.2  riz  * are met:
     10  1.1.1.1.6.2  riz  * 1. Redistributions of source code must retain the above copyright
     11  1.1.1.1.6.2  riz  *    notice, this list of conditions and the following disclaimer.
     12  1.1.1.1.6.2  riz  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1.1.1.6.2  riz  *    notice, this list of conditions and the following disclaimer in the
     14  1.1.1.1.6.2  riz  *    documentation and/or other materials provided with the distribution.
     15  1.1.1.1.6.2  riz  * 3. All advertising materials mentioning features or use of this software
     16  1.1.1.1.6.2  riz  *    must display the following acknowledgement:
     17  1.1.1.1.6.2  riz  *	This product includes software developed by the University of
     18  1.1.1.1.6.2  riz  *	California, Berkeley and its contributors.
     19  1.1.1.1.6.2  riz  * 4. Neither the name of the University nor the names of its contributors
     20  1.1.1.1.6.2  riz  *    may be used to endorse or promote products derived from this software
     21  1.1.1.1.6.2  riz  *    without specific prior written permission.
     22  1.1.1.1.6.2  riz  *
     23  1.1.1.1.6.2  riz  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24  1.1.1.1.6.2  riz  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  1.1.1.1.6.2  riz  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  1.1.1.1.6.2  riz  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27  1.1.1.1.6.2  riz  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  1.1.1.1.6.2  riz  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  1.1.1.1.6.2  riz  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  1.1.1.1.6.2  riz  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  1.1.1.1.6.2  riz  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  1.1.1.1.6.2  riz  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  1.1.1.1.6.2  riz  * SUCH DAMAGE.
     34  1.1.1.1.6.2  riz  */
     35  1.1.1.1.6.2  riz 
     36  1.1.1.1.6.2  riz /*
     37  1.1.1.1.6.2  riz  * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
     38  1.1.1.1.6.2  riz  * Portions Copyright (c) 1996-1999 by Internet Software Consortium.
     39  1.1.1.1.6.2  riz  *
     40  1.1.1.1.6.2  riz  * Permission to use, copy, modify, and distribute this software for any
     41  1.1.1.1.6.2  riz  * purpose with or without fee is hereby granted, provided that the above
     42  1.1.1.1.6.2  riz  * copyright notice and this permission notice appear in all copies.
     43  1.1.1.1.6.2  riz  *
     44  1.1.1.1.6.2  riz  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
     45  1.1.1.1.6.2  riz  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
     46  1.1.1.1.6.2  riz  * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
     47  1.1.1.1.6.2  riz  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
     48  1.1.1.1.6.2  riz  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
     49  1.1.1.1.6.2  riz  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
     50  1.1.1.1.6.2  riz  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
     51  1.1.1.1.6.2  riz  */
     52  1.1.1.1.6.2  riz 
     53  1.1.1.1.6.2  riz #if defined(LIBC_SCCS) && !defined(lint)
     54  1.1.1.1.6.2  riz static const char rcsid[] = "Id: nis_gr.c,v 1.4 2005/04/27 04:56:32 sra Exp";
     55  1.1.1.1.6.2  riz /* from getgrent.c 8.2 (Berkeley) 3/21/94"; */
     56  1.1.1.1.6.2  riz /* from BSDI Id: getgrent.c,v 2.8 1996/05/28 18:15:14 bostic Exp $	*/
     57  1.1.1.1.6.2  riz #endif /* LIBC_SCCS and not lint */
     58  1.1.1.1.6.2  riz 
     59  1.1.1.1.6.2  riz /* Imports */
     60  1.1.1.1.6.2  riz 
     61  1.1.1.1.6.2  riz #include "port_before.h"
     62  1.1.1.1.6.2  riz 
     63  1.1.1.1.6.2  riz #if !defined(WANT_IRS_GR) || !defined(WANT_IRS_NIS)
     64  1.1.1.1.6.2  riz static int __bind_irs_gr_unneeded;
     65  1.1.1.1.6.2  riz #else
     66  1.1.1.1.6.2  riz 
     67  1.1.1.1.6.2  riz #include <sys/param.h>
     68  1.1.1.1.6.2  riz #include <sys/types.h>
     69  1.1.1.1.6.2  riz #include <netinet/in.h>
     70  1.1.1.1.6.2  riz #include <arpa/nameser.h>
     71  1.1.1.1.6.2  riz #include <resolv.h>
     72  1.1.1.1.6.2  riz #include <isc/memcluster.h>
     73  1.1.1.1.6.2  riz 
     74  1.1.1.1.6.2  riz #include <rpc/rpc.h>
     75  1.1.1.1.6.2  riz #include <rpc/xdr.h>
     76  1.1.1.1.6.2  riz #include <rpcsvc/yp_prot.h>
     77  1.1.1.1.6.2  riz #include <rpcsvc/ypclnt.h>
     78  1.1.1.1.6.2  riz 
     79  1.1.1.1.6.2  riz #include <errno.h>
     80  1.1.1.1.6.2  riz #include <grp.h>
     81  1.1.1.1.6.2  riz #include <stdio.h>
     82  1.1.1.1.6.2  riz #include <stdlib.h>
     83  1.1.1.1.6.2  riz #include <string.h>
     84  1.1.1.1.6.2  riz #include <unistd.h>
     85  1.1.1.1.6.2  riz 
     86  1.1.1.1.6.2  riz #include <isc/memcluster.h>
     87  1.1.1.1.6.2  riz 
     88  1.1.1.1.6.2  riz #include <irs.h>
     89  1.1.1.1.6.2  riz 
     90  1.1.1.1.6.2  riz #include "port_after.h"
     91  1.1.1.1.6.2  riz 
     92  1.1.1.1.6.2  riz #include "irs_p.h"
     93  1.1.1.1.6.2  riz #include "nis_p.h"
     94  1.1.1.1.6.2  riz 
     95  1.1.1.1.6.2  riz /* Definitions */
     96  1.1.1.1.6.2  riz 
     97  1.1.1.1.6.2  riz struct pvt {
     98  1.1.1.1.6.2  riz 	int		needrewind;
     99  1.1.1.1.6.2  riz 	char *		nis_domain;
    100  1.1.1.1.6.2  riz 	char *		curkey_data;
    101  1.1.1.1.6.2  riz 	int		curkey_len;
    102  1.1.1.1.6.2  riz 	char *		curval_data;
    103  1.1.1.1.6.2  riz 	int		curval_len;
    104  1.1.1.1.6.2  riz 	/*%<
    105  1.1.1.1.6.2  riz 	 * Need space to store the entries read from the group file.
    106  1.1.1.1.6.2  riz 	 * The members list also needs space per member, and the
    107  1.1.1.1.6.2  riz 	 * strings making up the user names must be allocated
    108  1.1.1.1.6.2  riz 	 * somewhere.  Rather than doing lots of small allocations,
    109  1.1.1.1.6.2  riz 	 * we keep one buffer and resize it as needed.
    110  1.1.1.1.6.2  riz 	 */
    111  1.1.1.1.6.2  riz 	struct group	group;
    112  1.1.1.1.6.2  riz 	size_t		nmemb;		/*%< Malloc'd max index of gr_mem[]. */
    113  1.1.1.1.6.2  riz 	char *		membuf;
    114  1.1.1.1.6.2  riz 	size_t		membufsize;
    115  1.1.1.1.6.2  riz };
    116  1.1.1.1.6.2  riz 
    117  1.1.1.1.6.2  riz enum do_what { do_none = 0x0, do_key = 0x1, do_val = 0x2, do_all = 0x3 };
    118  1.1.1.1.6.2  riz 
    119  1.1.1.1.6.2  riz static /*const*/ char group_bygid[] =	"group.bygid";
    120  1.1.1.1.6.2  riz static /*const*/ char group_byname[] =	"group.byname";
    121  1.1.1.1.6.2  riz 
    122  1.1.1.1.6.2  riz /* Forward */
    123  1.1.1.1.6.2  riz 
    124  1.1.1.1.6.2  riz static void		gr_close(struct irs_gr *);
    125  1.1.1.1.6.2  riz static struct group *	gr_next(struct irs_gr *);
    126  1.1.1.1.6.2  riz static struct group *	gr_byname(struct irs_gr *, const char *);
    127  1.1.1.1.6.2  riz static struct group *	gr_bygid(struct irs_gr *, gid_t);
    128  1.1.1.1.6.2  riz static void		gr_rewind(struct irs_gr *);
    129  1.1.1.1.6.2  riz static void		gr_minimize(struct irs_gr *);
    130  1.1.1.1.6.2  riz 
    131  1.1.1.1.6.2  riz static struct group *	makegroupent(struct irs_gr *);
    132  1.1.1.1.6.2  riz static void		nisfree(struct pvt *, enum do_what);
    133  1.1.1.1.6.2  riz 
    134  1.1.1.1.6.2  riz /* Public */
    135  1.1.1.1.6.2  riz 
    136  1.1.1.1.6.2  riz struct irs_gr *
    137  1.1.1.1.6.2  riz irs_nis_gr(struct irs_acc *this) {
    138  1.1.1.1.6.2  riz 	struct irs_gr *gr;
    139  1.1.1.1.6.2  riz 	struct pvt *pvt;
    140  1.1.1.1.6.2  riz 
    141  1.1.1.1.6.2  riz 	if (!(gr = memget(sizeof *gr))) {
    142  1.1.1.1.6.2  riz 		errno = ENOMEM;
    143  1.1.1.1.6.2  riz 		return (NULL);
    144  1.1.1.1.6.2  riz 	}
    145  1.1.1.1.6.2  riz 	memset(gr, 0x5e, sizeof *gr);
    146  1.1.1.1.6.2  riz 	if (!(pvt = memget(sizeof *pvt))) {
    147  1.1.1.1.6.2  riz 		memput(gr, sizeof *gr);
    148  1.1.1.1.6.2  riz 		errno = ENOMEM;
    149  1.1.1.1.6.2  riz 		return (NULL);
    150  1.1.1.1.6.2  riz 	}
    151  1.1.1.1.6.2  riz 	memset(pvt, 0, sizeof *pvt);
    152  1.1.1.1.6.2  riz 	pvt->needrewind = 1;
    153  1.1.1.1.6.2  riz 	pvt->nis_domain = ((struct nis_p *)this->private)->domain;
    154  1.1.1.1.6.2  riz 	gr->private = pvt;
    155  1.1.1.1.6.2  riz 	gr->close = gr_close;
    156  1.1.1.1.6.2  riz 	gr->next = gr_next;
    157  1.1.1.1.6.2  riz 	gr->byname = gr_byname;
    158  1.1.1.1.6.2  riz 	gr->bygid = gr_bygid;
    159  1.1.1.1.6.2  riz 	gr->rewind = gr_rewind;
    160  1.1.1.1.6.2  riz 	gr->list = make_group_list;
    161  1.1.1.1.6.2  riz 	gr->minimize = gr_minimize;
    162  1.1.1.1.6.2  riz 	gr->res_get = NULL;
    163  1.1.1.1.6.2  riz 	gr->res_set = NULL;
    164  1.1.1.1.6.2  riz 	return (gr);
    165  1.1.1.1.6.2  riz }
    166  1.1.1.1.6.2  riz 
    167  1.1.1.1.6.2  riz /* Methods */
    168  1.1.1.1.6.2  riz 
    169  1.1.1.1.6.2  riz static void
    170  1.1.1.1.6.2  riz gr_close(struct irs_gr *this) {
    171  1.1.1.1.6.2  riz 	struct pvt *pvt = (struct pvt *)this->private;
    172  1.1.1.1.6.2  riz 
    173  1.1.1.1.6.2  riz 	if (pvt->group.gr_mem)
    174  1.1.1.1.6.2  riz 		free(pvt->group.gr_mem);
    175  1.1.1.1.6.2  riz 	if (pvt->membuf)
    176  1.1.1.1.6.2  riz 		free(pvt->membuf);
    177  1.1.1.1.6.2  riz 	memput(pvt, sizeof *pvt);
    178  1.1.1.1.6.2  riz 	memput(this, sizeof *this);
    179  1.1.1.1.6.2  riz }
    180  1.1.1.1.6.2  riz 
    181  1.1.1.1.6.2  riz static struct group *
    182  1.1.1.1.6.2  riz gr_next(struct irs_gr *this) {
    183  1.1.1.1.6.2  riz 	struct pvt *pvt = (struct pvt *)this->private;
    184  1.1.1.1.6.2  riz 	struct group *rval;
    185  1.1.1.1.6.2  riz 	int r;
    186  1.1.1.1.6.2  riz 
    187  1.1.1.1.6.2  riz 	do {
    188  1.1.1.1.6.2  riz 		if (pvt->needrewind) {
    189  1.1.1.1.6.2  riz 			nisfree(pvt, do_all);
    190  1.1.1.1.6.2  riz 			r = yp_first(pvt->nis_domain, group_byname,
    191  1.1.1.1.6.2  riz 				     &pvt->curkey_data, &pvt->curkey_len,
    192  1.1.1.1.6.2  riz 				     &pvt->curval_data, &pvt->curval_len);
    193  1.1.1.1.6.2  riz 			pvt->needrewind = 0;
    194  1.1.1.1.6.2  riz 		} else {
    195  1.1.1.1.6.2  riz 			char *newkey_data;
    196  1.1.1.1.6.2  riz 			int newkey_len;
    197  1.1.1.1.6.2  riz 
    198  1.1.1.1.6.2  riz 			nisfree(pvt, do_val);
    199  1.1.1.1.6.2  riz 			r = yp_next(pvt->nis_domain, group_byname,
    200  1.1.1.1.6.2  riz 				    pvt->curkey_data, pvt->curkey_len,
    201  1.1.1.1.6.2  riz 				    &newkey_data, &newkey_len,
    202  1.1.1.1.6.2  riz 				    &pvt->curval_data, &pvt->curval_len);
    203  1.1.1.1.6.2  riz 			nisfree(pvt, do_key);
    204  1.1.1.1.6.2  riz 			pvt->curkey_data = newkey_data;
    205  1.1.1.1.6.2  riz 			pvt->curkey_len = newkey_len;
    206  1.1.1.1.6.2  riz 		}
    207  1.1.1.1.6.2  riz 		if (r != 0) {
    208  1.1.1.1.6.2  riz 			errno = ENOENT;
    209  1.1.1.1.6.2  riz 			return (NULL);
    210  1.1.1.1.6.2  riz 		}
    211  1.1.1.1.6.2  riz 		rval = makegroupent(this);
    212  1.1.1.1.6.2  riz 	} while (rval == NULL);
    213  1.1.1.1.6.2  riz 	return (rval);
    214  1.1.1.1.6.2  riz }
    215  1.1.1.1.6.2  riz 
    216  1.1.1.1.6.2  riz static struct group *
    217  1.1.1.1.6.2  riz gr_byname(struct irs_gr *this, const char *name) {
    218  1.1.1.1.6.2  riz 	struct pvt *pvt = (struct pvt *)this->private;
    219  1.1.1.1.6.2  riz 	int r;
    220  1.1.1.1.6.2  riz 
    221  1.1.1.1.6.2  riz 	nisfree(pvt, do_val);
    222  1.1.1.1.6.2  riz 	r = yp_match(pvt->nis_domain, group_byname, name, strlen(name),
    223  1.1.1.1.6.2  riz 		     &pvt->curval_data, &pvt->curval_len);
    224  1.1.1.1.6.2  riz 	if (r != 0) {
    225  1.1.1.1.6.2  riz 		errno = ENOENT;
    226  1.1.1.1.6.2  riz 		return (NULL);
    227  1.1.1.1.6.2  riz 	}
    228  1.1.1.1.6.2  riz 	return (makegroupent(this));
    229  1.1.1.1.6.2  riz }
    230  1.1.1.1.6.2  riz 
    231  1.1.1.1.6.2  riz static struct group *
    232  1.1.1.1.6.2  riz gr_bygid(struct irs_gr *this, gid_t gid) {
    233  1.1.1.1.6.2  riz 	struct pvt *pvt = (struct pvt *)this->private;
    234  1.1.1.1.6.2  riz 	char tmp[sizeof "4294967295"];
    235  1.1.1.1.6.2  riz 	int r;
    236  1.1.1.1.6.2  riz 
    237  1.1.1.1.6.2  riz 	nisfree(pvt, do_val);
    238  1.1.1.1.6.2  riz 	(void) sprintf(tmp, "%u", (unsigned int)gid);
    239  1.1.1.1.6.2  riz 	r = yp_match(pvt->nis_domain, group_bygid, tmp, strlen(tmp),
    240  1.1.1.1.6.2  riz 		     &pvt->curval_data, &pvt->curval_len);
    241  1.1.1.1.6.2  riz 	if (r != 0) {
    242  1.1.1.1.6.2  riz 		errno = ENOENT;
    243  1.1.1.1.6.2  riz 		return (NULL);
    244  1.1.1.1.6.2  riz 	}
    245  1.1.1.1.6.2  riz 	return (makegroupent(this));
    246  1.1.1.1.6.2  riz }
    247  1.1.1.1.6.2  riz 
    248  1.1.1.1.6.2  riz static void
    249  1.1.1.1.6.2  riz gr_rewind(struct irs_gr *this) {
    250  1.1.1.1.6.2  riz 	struct pvt *pvt = (struct pvt *)this->private;
    251  1.1.1.1.6.2  riz 
    252  1.1.1.1.6.2  riz 	pvt->needrewind = 1;
    253  1.1.1.1.6.2  riz }
    254  1.1.1.1.6.2  riz 
    255  1.1.1.1.6.2  riz static void
    256  1.1.1.1.6.2  riz gr_minimize(struct irs_gr *this) {
    257  1.1.1.1.6.2  riz 	UNUSED(this);
    258  1.1.1.1.6.2  riz 	/* NOOP */
    259  1.1.1.1.6.2  riz }
    260  1.1.1.1.6.2  riz 
    261  1.1.1.1.6.2  riz /* Private */
    262  1.1.1.1.6.2  riz 
    263  1.1.1.1.6.2  riz static struct group *
    264  1.1.1.1.6.2  riz makegroupent(struct irs_gr *this) {
    265  1.1.1.1.6.2  riz 	struct pvt *pvt = (struct pvt *)this->private;
    266  1.1.1.1.6.2  riz 	unsigned int num_members = 0;
    267  1.1.1.1.6.2  riz 	char *cp, **new;
    268  1.1.1.1.6.2  riz 	u_long t;
    269  1.1.1.1.6.2  riz 
    270  1.1.1.1.6.2  riz 	if (pvt->group.gr_mem) {
    271  1.1.1.1.6.2  riz 		free(pvt->group.gr_mem);
    272  1.1.1.1.6.2  riz 		pvt->group.gr_mem = NULL;
    273  1.1.1.1.6.2  riz 		pvt->nmemb = 0;
    274  1.1.1.1.6.2  riz 	}
    275  1.1.1.1.6.2  riz 	if (pvt->membuf)
    276  1.1.1.1.6.2  riz 		free(pvt->membuf);
    277  1.1.1.1.6.2  riz 	pvt->membuf = pvt->curval_data;
    278  1.1.1.1.6.2  riz 	pvt->curval_data = NULL;
    279  1.1.1.1.6.2  riz 
    280  1.1.1.1.6.2  riz 	cp = pvt->membuf;
    281  1.1.1.1.6.2  riz 	pvt->group.gr_name = cp;
    282  1.1.1.1.6.2  riz 	if (!(cp = strchr(cp, ':')))
    283  1.1.1.1.6.2  riz 		goto cleanup;
    284  1.1.1.1.6.2  riz 	*cp++ = '\0';
    285  1.1.1.1.6.2  riz 
    286  1.1.1.1.6.2  riz 	pvt->group.gr_passwd = cp;
    287  1.1.1.1.6.2  riz 	if (!(cp = strchr(cp, ':')))
    288  1.1.1.1.6.2  riz 		goto cleanup;
    289  1.1.1.1.6.2  riz 	*cp++ = '\0';
    290  1.1.1.1.6.2  riz 
    291  1.1.1.1.6.2  riz 	errno = 0;
    292  1.1.1.1.6.2  riz 	t = strtoul(cp, NULL, 10);
    293  1.1.1.1.6.2  riz 	if (errno == ERANGE)
    294  1.1.1.1.6.2  riz 		goto cleanup;
    295  1.1.1.1.6.2  riz 	pvt->group.gr_gid = (gid_t) t;
    296  1.1.1.1.6.2  riz 	if (!(cp = strchr(cp, ':')))
    297  1.1.1.1.6.2  riz 		goto cleanup;
    298  1.1.1.1.6.2  riz 	cp++;
    299  1.1.1.1.6.2  riz 
    300  1.1.1.1.6.2  riz         if (*cp && cp[strlen(cp)-1] == '\n')
    301  1.1.1.1.6.2  riz           cp[strlen(cp)-1] = '\0';
    302  1.1.1.1.6.2  riz 
    303  1.1.1.1.6.2  riz 	/*
    304  1.1.1.1.6.2  riz 	 * Parse the members out.
    305  1.1.1.1.6.2  riz 	 */
    306  1.1.1.1.6.2  riz 	while (*cp) {
    307  1.1.1.1.6.2  riz 		if (num_members+1 >= pvt->nmemb || pvt->group.gr_mem == NULL) {
    308  1.1.1.1.6.2  riz 			pvt->nmemb += 10;
    309  1.1.1.1.6.2  riz 			new = realloc(pvt->group.gr_mem,
    310  1.1.1.1.6.2  riz 				      pvt->nmemb * sizeof(char *));
    311  1.1.1.1.6.2  riz 			if (new == NULL)
    312  1.1.1.1.6.2  riz 				goto cleanup;
    313  1.1.1.1.6.2  riz 			pvt->group.gr_mem = new;
    314  1.1.1.1.6.2  riz 		}
    315  1.1.1.1.6.2  riz 		pvt->group.gr_mem[num_members++] = cp;
    316  1.1.1.1.6.2  riz 		if (!(cp = strchr(cp, ',')))
    317  1.1.1.1.6.2  riz 			break;
    318  1.1.1.1.6.2  riz 		*cp++ = '\0';
    319  1.1.1.1.6.2  riz 	}
    320  1.1.1.1.6.2  riz 	if (pvt->group.gr_mem == NULL) {
    321  1.1.1.1.6.2  riz 		pvt->group.gr_mem = malloc(sizeof(char*));
    322  1.1.1.1.6.2  riz 		if (!pvt->group.gr_mem)
    323  1.1.1.1.6.2  riz 			goto cleanup;
    324  1.1.1.1.6.2  riz 		pvt->nmemb = 1;
    325  1.1.1.1.6.2  riz 	}
    326  1.1.1.1.6.2  riz 	pvt->group.gr_mem[num_members] = NULL;
    327  1.1.1.1.6.2  riz 
    328  1.1.1.1.6.2  riz 	return (&pvt->group);
    329  1.1.1.1.6.2  riz 
    330  1.1.1.1.6.2  riz  cleanup:
    331  1.1.1.1.6.2  riz 	if (pvt->group.gr_mem) {
    332  1.1.1.1.6.2  riz 		free(pvt->group.gr_mem);
    333  1.1.1.1.6.2  riz 		pvt->group.gr_mem = NULL;
    334  1.1.1.1.6.2  riz 		pvt->nmemb = 0;
    335  1.1.1.1.6.2  riz 	}
    336  1.1.1.1.6.2  riz 	if (pvt->membuf) {
    337  1.1.1.1.6.2  riz 		free(pvt->membuf);
    338  1.1.1.1.6.2  riz 		pvt->membuf = NULL;
    339  1.1.1.1.6.2  riz 	}
    340  1.1.1.1.6.2  riz 	return (NULL);
    341  1.1.1.1.6.2  riz }
    342  1.1.1.1.6.2  riz 
    343  1.1.1.1.6.2  riz static void
    344  1.1.1.1.6.2  riz nisfree(struct pvt *pvt, enum do_what do_what) {
    345  1.1.1.1.6.2  riz 	if ((do_what & do_key) && pvt->curkey_data) {
    346  1.1.1.1.6.2  riz 		free(pvt->curkey_data);
    347  1.1.1.1.6.2  riz 		pvt->curkey_data = NULL;
    348  1.1.1.1.6.2  riz 	}
    349  1.1.1.1.6.2  riz 	if ((do_what & do_val) && pvt->curval_data) {
    350  1.1.1.1.6.2  riz 		free(pvt->curval_data);
    351  1.1.1.1.6.2  riz 		pvt->curval_data = NULL;
    352  1.1.1.1.6.2  riz 	}
    353  1.1.1.1.6.2  riz }
    354  1.1.1.1.6.2  riz 
    355  1.1.1.1.6.2  riz #endif /* WANT_IRS_GR && WANT_IRS_NIS */
    356  1.1.1.1.6.2  riz /*! \file */
    357