xref: /titanic_41/usr/src/lib/nsswitch/nis/common/getpwnam.c (revision fa9e4066f08beec538e775443c5be79dd423fcab)
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-1992 Sun Microsystems Inc
24  *	All Rights Reserved.
25  *
26  *	nis/getpwnam.c -- "nis" backend for nsswitch "passwd" database
27  */
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <pwd.h>
32 #include "nis_common.h"
33 
34 static nss_status_t
35 getbyname(be, a)
36 	nis_backend_ptr_t	be;
37 	void			*a;
38 {
39 	nss_XbyY_args_t		*argp = (nss_XbyY_args_t *) a;
40 
41 	return (_nss_nis_lookup(be, argp, 0,
42 				"passwd.byname", argp->key.name, 0));
43 }
44 
45 static nss_status_t
46 getbyuid(be, a)
47 	nis_backend_ptr_t	be;
48 	void			*a;
49 {
50 	nss_XbyY_args_t		*argp = (nss_XbyY_args_t *) a;
51 	char			uidstr[12];	/* More than enough */
52 
53 	sprintf(uidstr, "%d", argp->key.uid);
54 	return (_nss_nis_lookup(be, argp, 0, "passwd.byuid", uidstr, 0));
55 }
56 
57 static nis_backend_op_t passwd_ops[] = {
58 	_nss_nis_destr,
59 	_nss_nis_endent,
60 	_nss_nis_setent,
61 	_nss_nis_getent_rigid,
62 	getbyname,
63 	getbyuid
64 };
65 
66 /*ARGSUSED*/
67 nss_backend_t *
68 _nss_nis_passwd_constr(dummy1, dummy2, dummy3)
69 	const char	*dummy1, *dummy2, dummy3;
70 {
71 	return (_nss_nis_constr(passwd_ops,
72 				sizeof (passwd_ops) / sizeof (passwd_ops[0]),
73 				"passwd.byname"));
74 }
75