xref: /titanic_41/usr/src/lib/nsswitch/files/common/getauuser.c (revision c138f478d2bc94e73ab8f6a084e323bec25e62f5)
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 <bsm/libbsm.h>
32 #include <string.h>
33 
34 /*
35  *    files/getauuser.c --
36  *           "files" backend for nsswitch "audit_user" database
37  */
38 static int
39 check_name(nss_XbyY_args_t *args)
40 {
41 	au_user_str_t *au_user = (au_user_str_t *)args->returnval;
42 	const char *name = args->key.name;
43 
44 	if (strcmp(au_user->au_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 auuser_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_audit_user_constr(const char *dummy1, const char *dummy2,
68     const char *dummy3)
69 {
70 	return (_nss_files_constr(auuser_ops,
71 	    sizeof (auuser_ops) / sizeof (auuser_ops[0]),
72 	    AUDITUSER_FILENAME,
73 	    NSS_LINELEN_AUDITUSER,
74 	    NULL));
75 }
76