xref: /titanic_41/usr/src/lib/nsswitch/files/common/getspent.c (revision ba2e4443695ee6a6f420a35cd4fc3d3346d22932)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  *	Copyright (c) 1988-1995 Sun Microsystems Inc
24  *	All Rights Reserved.
25  *
26  *	files/getspent.c -- "files" backend for nsswitch "shadow" database
27  */
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <shadow.h>
32 #include "files_common.h"
33 #include <strings.h>
34 
35 static int
36 check_spnamp(argp)
37 	nss_XbyY_args_t		*argp;
38 {
39 	struct spwd		*s = (struct spwd *)argp->returnval;
40 
41 	/* +/- entries valid in compat source only */
42 	if (s->sp_namp != 0 && (s->sp_namp[0] == '+' || s->sp_namp[0] == '-'))
43 		return (0);
44 	return (strcmp(s->sp_namp, argp->key.name) == 0);
45 }
46 
47 static nss_status_t
48 getbyname(be, a)
49 	files_backend_ptr_t	be;
50 	void			*a;
51 {
52 	nss_XbyY_args_t		*argp = (nss_XbyY_args_t *) a;
53 
54 	return (_nss_files_XY_all(be, argp, 0, argp->key.name, check_spnamp));
55 }
56 
57 static files_backend_op_t shadow_ops[] = {
58 	_nss_files_destr,
59 	_nss_files_endent,
60 	_nss_files_setent,
61 	_nss_files_getent_rigid,
62 	getbyname
63 };
64 
65 /*ARGSUSED*/
66 nss_backend_t *
67 _nss_files_shadow_constr(dummy1, dummy2, dummy3)
68 	const char	*dummy1, *dummy2, *dummy3;
69 {
70 	return (_nss_files_constr(shadow_ops,
71 				sizeof (shadow_ops) / sizeof (shadow_ops[0]),
72 				SHADOW,
73 				NSS_LINELEN_SHADOW,
74 				NULL));
75 }
76