xref: /titanic_52/usr/src/lib/nsswitch/files/common/getauthattr.c (revision d58fda4376e4bf67072ce2e69f6f47036f9dbb68)
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) 1999-2001 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 
30 #include "files_common.h"
31 #include <auth_attr.h>
32 #include <string.h>
33 
34 /*
35  *    files/getauthattr.c --
36  *           "files" backend for nsswitch "auth_attr" database
37  */
38 static int
39 check_name(nss_XbyY_args_t *args)
40 {
41 	authstr_t *auth = (authstr_t *)args->returnval;
42 	const char *name    = args->key.name;
43 
44 	if (strcmp(auth->name, name) == 0) {
45 		return (1);
46 	}
47 	return (0);
48 }
49 
50 static nss_status_t
51 getbyname(files_backend_ptr_t be, void *a)
52 {
53 	nss_XbyY_args_t *argp = (nss_XbyY_args_t *)a;
54 
55 	return (_nss_files_XY_all(be, argp, 1, argp->key.name, check_name));
56 }
57 
58 static files_backend_op_t authattr_ops[] = {
59 	_nss_files_destr,
60 	_nss_files_endent,
61 	_nss_files_setent,
62 	_nss_files_getent_netdb,
63 	getbyname
64 };
65 
66 nss_backend_t *
67 _nss_files_auth_attr_constr(const char *dummy1,
68     const char *dummy2,
69     const char *dummy3,
70     const char *dummy4,
71     const char *dummy5,
72     const char *dummy6)
73 {
74 	return (_nss_files_constr(authattr_ops,
75 	    sizeof (authattr_ops) / sizeof (authattr_ops[0]),
76 	    AUTHATTR_FILENAME,
77 	    NSS_LINELEN_AUTHATTR,
78 	    NULL));
79 }
80