2
* Copyright 1990 - 1994, Julianne Frances Haugh
2
* Copyright (c) 1990 - 1994, Julianne Frances Haugh
3
* Copyright (c) 1996 - 1998, Marek Michałkiewicz
4
* Copyright (c) 2005 , Tomasz Kłoczko
5
* Copyright (c) 2008 , Nicolas François
3
6
* All rights reserved.
5
8
* Redistribution and use in source and binary forms, with or without
10
13
* 2. Redistributions in binary form must reproduce the above copyright
11
14
* notice, this list of conditions and the following disclaimer in the
12
15
* documentation and/or other materials provided with the distribution.
13
* 3. Neither the name of Julianne F. Haugh nor the names of its contributors
14
* may be used to endorse or promote products derived from this software
15
* without specific prior written permission.
16
* 3. The name of the copyright holders or contributors may not be used to
17
* endorse or promote products derived from this software without
18
* specific prior written permission.
17
* THIS SOFTWARE IS PROVIDED BY JULIE HAUGH AND CONTRIBUTORS ``AS IS'' AND
18
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
* ARE DISCLAIMED. IN NO EVENT SHALL JULIE HAUGH OR CONTRIBUTORS BE LIABLE
21
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
20
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
33
#include <config.h>
97
87
while (s != NULL && *s != '\0') {
98
88
size = (nelem + 1) * sizeof (ptr);
99
if ((ptr = realloc (*list, size)) != NULL) {
89
ptr = realloc (*list, size);
103
if ((s = strchr (s, ',')))
107
102
size = (nelem + 1) * sizeof (ptr);
108
if ((ptr = realloc (*list, size)) != NULL) {
103
ptr = realloc (*list, size);
140
strncpy (sgrbuf, string, (int) sizeof sgrbuf - 1);
138
strncpy (sgrbuf, string, sizeof sgrbuf - 1);
141
139
sgrbuf[sizeof sgrbuf - 1] = '\0';
143
if ((cp = strrchr (sgrbuf, '\n')))
141
cp = strrchr (sgrbuf, '\n');
147
147
* There should be exactly 4 colon separated fields. Find
148
148
* all 4 of them and save the starting addresses in fields[].
151
for (cp = sgrbuf, i = 0; i < FIELDS && cp; i++) {
151
for (cp = sgrbuf, i = 0; (i < FIELDS) && (NULL != cp); i++) {
153
if ((cp = strchr (cp, ':')))
153
cp = strchr (cp, ':');
199
202
char buf[sizeof sgrbuf];
206
while (fgetsx (buf, sizeof buf, fp) != (char *) 0)
210
while (fgetsx (buf, (int) sizeof buf, fp) != (char *) 0)
208
if (fgetsx (buf, sizeof buf, fp) != (char *) 0)
212
if (fgetsx (buf, (int) sizeof buf, fp) != (char *) 0)
211
if ((cp = strchr (buf, '\n')))
215
cp = strchr (buf, '\n');
214
if (nis_ignore && IS_NISCHAR (buf[0]))
220
if (nis_ignore && IS_NISCHAR (buf[0])) {
217
224
return (sgetsgent (buf));
267
278
* use a NIS map, it must be a regular local group.
270
if (nis_1_group == 0 && nis_state != start)
281
if (!nis_1_group && (nis_state != start)) {
274
286
* If this is an escape to use an NIS map, switch over to
275
287
* that bunch of code.
278
if (nis_state == start)
290
if (nis_state == start) {
282
295
* NEEDSWORK. Here we substitute pieces-parts of this entry.
345
359
if (yp_match (nis_domain, "gshadow.byname", name,
346
360
strlen (name), &nis_val,
347
361
&nis_vallen) == 0) {
348
if (cp = strchr (nis_val, '\n'))
362
cp = strchr (nis_val, '\n');
351
367
nis_state = middle;
352
if (sgrp = sgetsgent (nis_val)) {
368
sgrp = sgetsgent (nis_val);
353
370
strcpy (save_name, sgrp->sg_name);
354
371
nis_key = save_name;
355
372
nis_keylen = strlen (save_name);
411
if ((NULL == fp) || (NULL == sgrp)) {
398
415
/* calculate the required buffer size */
399
416
size = strlen (sgrp->sg_name) + strlen (sgrp->sg_passwd) + 10;
400
for (i = 0; sgrp->sg_adm && sgrp->sg_adm[i]; i++)
417
for (i = 0; (NULL != sgrp->sg_adm) && (NULL != sgrp->sg_adm[i]); i++) {
401
418
size += strlen (sgrp->sg_adm[i]) + 1;
402
for (i = 0; sgrp->sg_mem && sgrp->sg_mem[i]; i++)
420
for (i = 0; (NULL != sgrp->sg_mem) && (NULL != sgrp->sg_mem[i]); i++) {
403
421
size += strlen (sgrp->sg_mem[i]) + 1;
405
424
buf = malloc (size);