]>
git.ipfire.org Git - thirdparty/glibc.git/blob - nis/nss_nis/nis-netgrp.c
f5a73e79bb970896c43c07e2e66ca6bc67e7c03a
1 /* Copyright (C) 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@suse.de>, 1996.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23 #include <bits/libc-lock.h>
29 #include <rpcsvc/yp.h>
30 #include <rpcsvc/ypclnt.h>
34 /* Locks the static variables in this file. */
35 __libc_lock_define_initialized (static, lock
)
38 static size_t data_size
;
41 extern enum nss_status
42 _nss_netgroup_parseline (char **cursor
, struct __netgrent
*result
,
43 char *buffer
, size_t buflen
, int *errnop
);
46 _nss_nis_setnetgrent (const char *group
, struct __netgrent
*dummy
)
51 enum nss_status status
;
53 status
= NSS_STATUS_SUCCESS
;
55 if (group
== NULL
|| group
[0] == '\0')
56 return NSS_STATUS_UNAVAIL
;
58 if (yp_get_default_domain (&domain
))
59 return NSS_STATUS_UNAVAIL
;
61 __libc_lock_lock (lock
);
71 group_len
= strlen (group
);
73 status
= yperr2nss (yp_match (domain
, "netgroup", group
, group_len
,
75 if (status
== NSS_STATUS_SUCCESS
)
77 if (len
> 0 && (data
= malloc (len
+ 1)) != NULL
)
80 cursor
= strncpy (data
, result
, len
+ 1);
85 status
= NSS_STATUS_NOTFOUND
;
88 __libc_lock_unlock (lock
);
95 _nss_nis_endnetgrent (struct __netgrent
*dummy
)
97 __libc_lock_lock (lock
);
107 __libc_lock_unlock (lock
);
109 return NSS_STATUS_SUCCESS
;
113 _nss_nis_getnetgrent_r (struct __netgrent
*result
, char *buffer
, size_t buflen
,
116 enum nss_status status
;
121 return NSS_STATUS_NOTFOUND
;
124 __libc_lock_lock (lock
);
126 status
= _nss_netgroup_parseline (&cursor
, result
, buffer
, buflen
, errnop
);
128 __libc_lock_unlock (lock
);