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]
22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #include <sys/types.h>
27 #include <sys/param.h>
29 #include <sys/fcntl.h>
30 #include <bsm/audit.h>
31 #include <bsm/audit_record.h>
32 #include <bsm/audit_uevents.h>
33 #include <bsm/libbsm.h>
37 #include <netinet/in.h>
38 #include <sys/socket.h>
46 #define dprintf(x) { (void) printf x; }
54 * Given an endpt in netbuf form, return the port and machine.
55 * kadmind (currently) only works over IPv4, so only handle IPv4 addresses.
63 struct sockaddr_in sin4
;
66 syslog(LOG_DEBUG
, "netbuf2pm: addr == NULL");
71 syslog(LOG_DEBUG
, "netbuf2pm: addr->buf == NULL");
75 (void) memcpy(&sin4
, addr
->buf
, sizeof (struct sockaddr_in
));
76 if (sin4
.sin_family
== AF_INET
) {
78 *machine
= sin4
.sin_addr
.s_addr
;
80 *port
= sin4
.sin_port
;
82 dprintf(("netbuf2pm: unknown caller IP address family %d",
85 "netbuf2pm: unknown caller IP address family %d",
90 #define AUD_NULL_STR(s) ((s) ? (s) : "(null)")
94 au_event_t event
, /* audit event */
95 SVCXPRT
*xprt
, /* net transport handle */
96 in_port_t l_port
, /* local port */
97 char *op
, /* requested operation */
98 char *prime_arg
, /* argument for op */
99 char *clnt_name
, /* client principal name */
100 int sorf
) /* flag for success or failure */
104 in_port_t r_port
= 0;
106 uint32_t machine
= 0;
109 dprintf(("common_audit() start\n"));
111 /* if auditing turned off, then don't do anything */
115 (void) aug_save_namask();
118 * set default values. We will overwrite them if appropriate.
124 aug_save_auid(ai
.ai_auid
); /* Audit ID */
125 aug_save_uid(getuid()); /* User ID */
126 aug_save_euid(geteuid()); /* Effective User ID */
127 aug_save_gid(getgid()); /* Group ID */
128 aug_save_egid(getegid()); /* Effective Group ID */
129 aug_save_pid(getpid()); /* process ID */
130 aug_save_asid(getpid()); /* session ID */
132 aug_save_event(event
);
135 (void) snprintf(text_buf
, sizeof (text_buf
), "Op: %s",
137 aug_save_text(text_buf
);
138 (void) snprintf(text_buf
, sizeof (text_buf
), "Arg: %s",
139 AUD_NULL_STR(prime_arg
));
140 aug_save_text1(text_buf
);
141 (void) snprintf(text_buf
, sizeof (text_buf
), "Client: %s",
142 AUD_NULL_STR(clnt_name
));
143 aug_save_text2(text_buf
);
145 netbuf2pm(svc_getrpccaller(xprt
), &r_port
, &machine
);
147 dprintf(("common_audit(): l_port=%d, r_port=%d,\n",
148 ntohs(l_port
), ntohs(r_port
)));
150 port
= (r_port
<<16 | l_port
);
152 aug_save_tid_ex(port
, &machine
, AU_IPv4
);
166 common_audit(AUE_kadmind_auth
, xprt
, l_port
, op
, prime_arg
,
171 audit_kadmind_unauth(
178 common_audit(AUE_kadmind_unauth
, xprt
, l_port
, op
, prime_arg
,