10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*2830Sdjl  * Common Development and Distribution License (the "License").
6*2830Sdjl  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*2830Sdjl  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23*2830Sdjl  * Use is subject to license terms.
240Sstevel@tonic-gate  *
250Sstevel@tonic-gate  *	nis/getpwnam.c -- "nis" backend for nsswitch "passwd" database
260Sstevel@tonic-gate  */
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #include <pwd.h>
310Sstevel@tonic-gate #include "nis_common.h"
320Sstevel@tonic-gate 
330Sstevel@tonic-gate static nss_status_t
340Sstevel@tonic-gate getbyname(be, a)
350Sstevel@tonic-gate 	nis_backend_ptr_t	be;
360Sstevel@tonic-gate 	void			*a;
370Sstevel@tonic-gate {
38*2830Sdjl 	nss_XbyY_args_t		*argp = (nss_XbyY_args_t *)a;
390Sstevel@tonic-gate 
400Sstevel@tonic-gate 	return (_nss_nis_lookup(be, argp, 0,
410Sstevel@tonic-gate 				"passwd.byname", argp->key.name, 0));
420Sstevel@tonic-gate }
430Sstevel@tonic-gate 
440Sstevel@tonic-gate static nss_status_t
450Sstevel@tonic-gate getbyuid(be, a)
460Sstevel@tonic-gate 	nis_backend_ptr_t	be;
470Sstevel@tonic-gate 	void			*a;
480Sstevel@tonic-gate {
49*2830Sdjl 	nss_XbyY_args_t		*argp = (nss_XbyY_args_t *)a;
500Sstevel@tonic-gate 	char			uidstr[12];	/* More than enough */
510Sstevel@tonic-gate 
52*2830Sdjl 	(void) snprintf(uidstr, 12, "%ld", argp->key.uid);
530Sstevel@tonic-gate 	return (_nss_nis_lookup(be, argp, 0, "passwd.byuid", uidstr, 0));
540Sstevel@tonic-gate }
550Sstevel@tonic-gate 
560Sstevel@tonic-gate static nis_backend_op_t passwd_ops[] = {
570Sstevel@tonic-gate 	_nss_nis_destr,
580Sstevel@tonic-gate 	_nss_nis_endent,
590Sstevel@tonic-gate 	_nss_nis_setent,
600Sstevel@tonic-gate 	_nss_nis_getent_rigid,
610Sstevel@tonic-gate 	getbyname,
620Sstevel@tonic-gate 	getbyuid
630Sstevel@tonic-gate };
640Sstevel@tonic-gate 
650Sstevel@tonic-gate /*ARGSUSED*/
660Sstevel@tonic-gate nss_backend_t *
670Sstevel@tonic-gate _nss_nis_passwd_constr(dummy1, dummy2, dummy3)
680Sstevel@tonic-gate 	const char	*dummy1, *dummy2, dummy3;
690Sstevel@tonic-gate {
700Sstevel@tonic-gate 	return (_nss_nis_constr(passwd_ops,
710Sstevel@tonic-gate 				sizeof (passwd_ops) / sizeof (passwd_ops[0]),
720Sstevel@tonic-gate 				"passwd.byname"));
730Sstevel@tonic-gate }
74