Deleted Added
full compact
bsm_token.c (187215) bsm_token.c (189279)
1/*-
2 * Copyright (c) 2004-2009 Apple Inc.
3 * Copyright (c) 2005 SPARTA, Inc.
4 * All rights reserved.
5 *
6 * This code was developed in part by Robert N. M. Watson, Senior Principal
7 * Scientist, SPARTA, Inc.
8 *

--- 16 unchanged lines hidden (view full) ---

25 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 *
1/*-
2 * Copyright (c) 2004-2009 Apple Inc.
3 * Copyright (c) 2005 SPARTA, Inc.
4 * All rights reserved.
5 *
6 * This code was developed in part by Robert N. M. Watson, Senior Principal
7 * Scientist, SPARTA, Inc.
8 *

--- 16 unchanged lines hidden (view full) ---

25 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
30 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
32 *
33 * P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_token.c#86
33 * P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_token.c#90
34 */
35
36#include <sys/cdefs.h>
34 */
35
36#include <sys/cdefs.h>
37__FBSDID("$FreeBSD: head/sys/security/audit/audit_bsm_token.c 187215 2009-01-14 12:16:14Z rwatson $");
37__FBSDID("$FreeBSD: head/sys/security/audit/audit_bsm_token.c 189279 2009-03-02 13:29:18Z rwatson $");
38
39#include <sys/types.h>
40#include <sys/endian.h>
41#include <sys/queue.h>
42#include <sys/socket.h>
43#include <sys/time.h>
44
45#include <sys/ipc.h>

--- 88 unchanged lines hidden (view full) ---

134 * device 4 bytes/8 bytes (32-bit/64-bit)
135 */
136token_t *
137au_to_attr32(struct vnode_au_info *vni)
138{
139 token_t *t;
140 u_char *dptr = NULL;
141 u_int16_t pad0_16 = 0;
38
39#include <sys/types.h>
40#include <sys/endian.h>
41#include <sys/queue.h>
42#include <sys/socket.h>
43#include <sys/time.h>
44
45#include <sys/ipc.h>

--- 88 unchanged lines hidden (view full) ---

134 * device 4 bytes/8 bytes (32-bit/64-bit)
135 */
136token_t *
137au_to_attr32(struct vnode_au_info *vni)
138{
139 token_t *t;
140 u_char *dptr = NULL;
141 u_int16_t pad0_16 = 0;
142 u_int16_t pad0_32 = 0;
142 u_int32_t pad0_32 = 0;
143
144 GET_TOKEN_AREA(t, dptr, sizeof(u_char) + 2 * sizeof(u_int16_t) +
145 3 * sizeof(u_int32_t) + sizeof(u_int64_t) + sizeof(u_int32_t));
146
147 ADD_U_CHAR(dptr, AUT_ATTR32);
148
149 /*
150 * BSD defines the size for the file mode as 2 bytes; BSM defines 4

--- 30 unchanged lines hidden (view full) ---

181}
182
183token_t *
184au_to_attr64(struct vnode_au_info *vni)
185{
186 token_t *t;
187 u_char *dptr = NULL;
188 u_int16_t pad0_16 = 0;
143
144 GET_TOKEN_AREA(t, dptr, sizeof(u_char) + 2 * sizeof(u_int16_t) +
145 3 * sizeof(u_int32_t) + sizeof(u_int64_t) + sizeof(u_int32_t));
146
147 ADD_U_CHAR(dptr, AUT_ATTR32);
148
149 /*
150 * BSD defines the size for the file mode as 2 bytes; BSM defines 4

--- 30 unchanged lines hidden (view full) ---

181}
182
183token_t *
184au_to_attr64(struct vnode_au_info *vni)
185{
186 token_t *t;
187 u_char *dptr = NULL;
188 u_int16_t pad0_16 = 0;
189 u_int16_t pad0_32 = 0;
189 u_int32_t pad0_32 = 0;
190
191 GET_TOKEN_AREA(t, dptr, sizeof(u_char) + 2 * sizeof(u_int16_t) +
192 3 * sizeof(u_int32_t) + sizeof(u_int64_t) * 2);
193
194 ADD_U_CHAR(dptr, AUT_ATTR64);
195
196 /*
197 * BSD defines the size for the file mode as 2 bytes; BSM defines 4

--- 236 unchanged lines hidden (view full) ---

434 */
435token_t *
436au_to_ipc_perm(struct ipc_perm *perm)
437{
438 token_t *t;
439 u_char *dptr = NULL;
440 u_int16_t pad0 = 0;
441
190
191 GET_TOKEN_AREA(t, dptr, sizeof(u_char) + 2 * sizeof(u_int16_t) +
192 3 * sizeof(u_int32_t) + sizeof(u_int64_t) * 2);
193
194 ADD_U_CHAR(dptr, AUT_ATTR64);
195
196 /*
197 * BSD defines the size for the file mode as 2 bytes; BSM defines 4

--- 236 unchanged lines hidden (view full) ---

434 */
435token_t *
436au_to_ipc_perm(struct ipc_perm *perm)
437{
438 token_t *t;
439 u_char *dptr = NULL;
440 u_int16_t pad0 = 0;
441
442 GET_TOKEN_AREA(t, dptr, 12 * sizeof(u_int16_t) + sizeof(u_int32_t));
442 GET_TOKEN_AREA(t, dptr, sizeof(u_char) + 12 * sizeof(u_int16_t) +
443 sizeof(u_int32_t));
443
444 ADD_U_CHAR(dptr, AUT_IPC_PERM);
445
446 /*
447 * Systems vary significantly in what types they use in struct
448 * ipc_perm; at least a few still use 16-bit uid's and gid's, so
449 * allow for that, as BSM define 32-bit values here.
450 * Some systems define the sizes for ipc_perm members as 2 bytes;

--- 413 unchanged lines hidden (view full) ---

864 struct sockaddr_in *sin;
865 struct sockaddr_in6 *sin6;
866
867 if (so_domain == AF_INET)
868 GET_TOKEN_AREA(t, dptr, sizeof(u_char) +
869 5 * sizeof(u_int16_t) + 2 * sizeof(u_int32_t));
870 else if (so_domain == AF_INET6)
871 GET_TOKEN_AREA(t, dptr, sizeof(u_char) +
444
445 ADD_U_CHAR(dptr, AUT_IPC_PERM);
446
447 /*
448 * Systems vary significantly in what types they use in struct
449 * ipc_perm; at least a few still use 16-bit uid's and gid's, so
450 * allow for that, as BSM define 32-bit values here.
451 * Some systems define the sizes for ipc_perm members as 2 bytes;

--- 413 unchanged lines hidden (view full) ---

865 struct sockaddr_in *sin;
866 struct sockaddr_in6 *sin6;
867
868 if (so_domain == AF_INET)
869 GET_TOKEN_AREA(t, dptr, sizeof(u_char) +
870 5 * sizeof(u_int16_t) + 2 * sizeof(u_int32_t));
871 else if (so_domain == AF_INET6)
872 GET_TOKEN_AREA(t, dptr, sizeof(u_char) +
872 5 * sizeof(u_int16_t) + 16 * sizeof(u_int32_t));
873 5 * sizeof(u_int16_t) + 8 * sizeof(u_int32_t));
873 else
874 return (NULL);
875
876 ADD_U_CHAR(dptr, AUT_SOCKET_EX);
874 else
875 return (NULL);
876
877 ADD_U_CHAR(dptr, AUT_SOCKET_EX);
877 ADD_U_INT16(dptr, so_domain); /* XXXRW: explicitly convert? */
878 ADD_U_INT16(dptr, so_type); /* XXXRW: explicitly convert? */
878 ADD_U_INT16(dptr, au_domain_to_bsm(so_domain));
879 ADD_U_INT16(dptr, au_socket_type_to_bsm(so_type));
879 if (so_domain == AF_INET) {
880 ADD_U_INT16(dptr, AU_IPv4);
881 sin = (struct sockaddr_in *)sa_local;
882 ADD_MEM(dptr, &sin->sin_port, sizeof(uint16_t));
883 ADD_MEM(dptr, &sin->sin_addr.s_addr, sizeof(uint32_t));
884 sin = (struct sockaddr_in *)sa_remote;
885 ADD_MEM(dptr, &sin->sin_port, sizeof(uint16_t));
886 ADD_MEM(dptr, &sin->sin_addr.s_addr, sizeof(uint32_t));

--- 643 unchanged lines hidden ---
880 if (so_domain == AF_INET) {
881 ADD_U_INT16(dptr, AU_IPv4);
882 sin = (struct sockaddr_in *)sa_local;
883 ADD_MEM(dptr, &sin->sin_port, sizeof(uint16_t));
884 ADD_MEM(dptr, &sin->sin_addr.s_addr, sizeof(uint32_t));
885 sin = (struct sockaddr_in *)sa_remote;
886 ADD_MEM(dptr, &sin->sin_port, sizeof(uint16_t));
887 ADD_MEM(dptr, &sin->sin_addr.s_addr, sizeof(uint32_t));

--- 643 unchanged lines hidden ---