1 /* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.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 Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 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 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. */
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
)
37 static char *data
= NULL
;
38 static size_t data_size
= 0;
39 static char *cursor
= NULL
;;
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 (char *group
)
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
)
79 data
= malloc (len
+ 1);
81 cursor
= strncpy (data
, result
, len
+ 1);
86 status
= NSS_STATUS_NOTFOUND
;
89 __libc_lock_unlock (lock
);
96 _nss_nis_endnetgrent (void)
98 __libc_lock_lock (lock
);
108 __libc_lock_unlock (lock
);
110 return NSS_STATUS_SUCCESS
;
114 _nss_nis_getnetgrent_r (struct __netgrent
*result
, char *buffer
, size_t buflen
,
117 enum nss_status status
;
120 return NSS_STATUS_NOTFOUND
;
122 __libc_lock_lock (lock
);
124 status
= _nss_netgroup_parseline (&cursor
, result
, buffer
, buflen
, errnop
);
126 __libc_lock_unlock (lock
);