dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / libbsm / common / audit_mountd.c
blobefca6d64a7182ea330a063caab560adf95404913
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
28 #include <sys/types.h>
29 #include <stdio.h>
30 #include <sys/fcntl.h>
31 #include <bsm/audit.h>
32 #include <bsm/audit_record.h>
33 #include <bsm/audit_uevents.h>
34 #include <bsm/libbsm.h>
35 #include <bsm/audit_private.h>
36 #include <stdlib.h>
37 #include <string.h>
38 #include <syslog.h>
39 #include <netinet/in.h>
40 #include <unistd.h>
41 #include <synch.h>
42 #include <generic.h>
44 #ifdef C2_DEBUG2
45 #define dprintf(x) { (void) printf x; }
46 #else
47 #define dprintf(x)
48 #endif
50 static mutex_t audit_mountd_lock = DEFAULTMUTEX;
51 static int cannotaudit = 0;
54 * This setup call is made only once at the start of mountd.
55 * The call sets the auditing state off if appropriate, and is
56 * made in single threaded code, hence no locking is required.
58 void
59 audit_mountd_setup()
61 dprintf(("audit_mountd_setup()\n"));
64 if (cannot_audit(0))
65 cannotaudit = 1;
68 void
69 audit_mountd_mount(clname, path, sorf)
70 char *clname; /* client name */
71 char *path; /* mount path */
72 int sorf; /* flag for success or failure */
74 uint32_t buf[4], type;
75 dprintf(("audit_mountd_mount()\n"));
77 if (cannotaudit)
78 return;
80 (void) mutex_lock(&audit_mountd_lock);
82 (void) aug_save_namask();
84 (void) aug_save_me();
85 aug_save_event(AUE_mountd_mount);
86 aug_save_sorf(sorf);
87 aug_save_text(clname);
88 aug_save_path(path);
89 (void) aug_get_machine(clname, buf, &type);
90 aug_save_tid_ex(aug_get_port(), buf, type);
91 (void) aug_audit();
92 (void) mutex_unlock(&audit_mountd_lock);
95 void
96 audit_mountd_umount(clname, path)
97 char *clname; /* client name */
98 char *path; /* mount path */
100 uint32_t buf[4], type;
102 dprintf(("audit_mountd_mount()\n"));
104 if (cannotaudit)
105 return;
107 (void) mutex_lock(&audit_mountd_lock);
109 (void) aug_save_namask();
111 (void) aug_save_me();
112 aug_save_event(AUE_mountd_umount);
113 aug_save_sorf(0);
114 aug_save_text(clname);
115 aug_save_path(path);
116 (void) aug_get_machine(clname, buf, &type);
117 aug_save_tid_ex(aug_get_port(), buf, type);
118 (void) aug_audit();
119 (void) mutex_unlock(&audit_mountd_lock);