bsm_token.c (187214) | bsm_token.c (189279) |
---|---|
1/*- | 1/*- |
2 * Copyright (c) 2004-2008 Apple Inc. | 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 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions --- 14 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 * | 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 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions --- 14 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/types.h> 37 38#include <config/config.h> 39#if defined(HAVE_SYS_ENDIAN_H) && defined(HAVE_BE32ENC) 40#include <sys/endian.h> 41#else /* !HAVE_SYS_ENDIAN_H || !HAVE_BE32ENC */ --- 121 unchanged lines hidden (view full) --- 163 * device 4 bytes/8 bytes (32-bit/64-bit) 164 */ 165token_t * 166au_to_attr32(struct vnode_au_info *vni) 167{ 168 token_t *t; 169 u_char *dptr = NULL; 170 u_int16_t pad0_16 = 0; | 34 */ 35 36#include <sys/types.h> 37 38#include <config/config.h> 39#if defined(HAVE_SYS_ENDIAN_H) && defined(HAVE_BE32ENC) 40#include <sys/endian.h> 41#else /* !HAVE_SYS_ENDIAN_H || !HAVE_BE32ENC */ --- 121 unchanged lines hidden (view full) --- 163 * device 4 bytes/8 bytes (32-bit/64-bit) 164 */ 165token_t * 166au_to_attr32(struct vnode_au_info *vni) 167{ 168 token_t *t; 169 u_char *dptr = NULL; 170 u_int16_t pad0_16 = 0; |
171 u_int16_t pad0_32 = 0; | 171 u_int32_t pad0_32 = 0; |
172 173 GET_TOKEN_AREA(t, dptr, sizeof(u_char) + 2 * sizeof(u_int16_t) + 174 3 * sizeof(u_int32_t) + sizeof(u_int64_t) + sizeof(u_int32_t)); 175 if (t == NULL) 176 return (NULL); 177 178 ADD_U_CHAR(dptr, AUT_ATTR32); 179 --- 32 unchanged lines hidden (view full) --- 212} 213 214token_t * 215au_to_attr64(struct vnode_au_info *vni) 216{ 217 token_t *t; 218 u_char *dptr = NULL; 219 u_int16_t pad0_16 = 0; | 172 173 GET_TOKEN_AREA(t, dptr, sizeof(u_char) + 2 * sizeof(u_int16_t) + 174 3 * sizeof(u_int32_t) + sizeof(u_int64_t) + sizeof(u_int32_t)); 175 if (t == NULL) 176 return (NULL); 177 178 ADD_U_CHAR(dptr, AUT_ATTR32); 179 --- 32 unchanged lines hidden (view full) --- 212} 213 214token_t * 215au_to_attr64(struct vnode_au_info *vni) 216{ 217 token_t *t; 218 u_char *dptr = NULL; 219 u_int16_t pad0_16 = 0; |
220 u_int16_t pad0_32 = 0; | 220 u_int32_t pad0_32 = 0; |
221 222 GET_TOKEN_AREA(t, dptr, sizeof(u_char) + 2 * sizeof(u_int16_t) + 223 3 * sizeof(u_int32_t) + sizeof(u_int64_t) * 2); 224 if (t == NULL) 225 return (NULL); 226 227 ADD_U_CHAR(dptr, AUT_ATTR64); 228 --- 253 unchanged lines hidden (view full) --- 482 */ 483token_t * 484au_to_ipc_perm(struct ipc_perm *perm) 485{ 486 token_t *t; 487 u_char *dptr = NULL; 488 u_int16_t pad0 = 0; 489 | 221 222 GET_TOKEN_AREA(t, dptr, sizeof(u_char) + 2 * sizeof(u_int16_t) + 223 3 * sizeof(u_int32_t) + sizeof(u_int64_t) * 2); 224 if (t == NULL) 225 return (NULL); 226 227 ADD_U_CHAR(dptr, AUT_ATTR64); 228 --- 253 unchanged lines hidden (view full) --- 482 */ 483token_t * 484au_to_ipc_perm(struct ipc_perm *perm) 485{ 486 token_t *t; 487 u_char *dptr = NULL; 488 u_int16_t pad0 = 0; 489 |
490 GET_TOKEN_AREA(t, dptr, 12 * sizeof(u_int16_t) + sizeof(u_int32_t)); | 490 GET_TOKEN_AREA(t, dptr, sizeof(u_char) + 12 * sizeof(u_int16_t) + 491 sizeof(u_int32_t)); |
491 if (t == NULL) 492 return (NULL); 493 494 ADD_U_CHAR(dptr, AUT_IPC_PERM); 495 496 /* 497 * Systems vary significantly in what types they use in struct 498 * ipc_perm; at least a few still use 16-bit uid's and gid's, so --- 458 unchanged lines hidden (view full) --- 957 struct sockaddr_in *sin; 958 struct sockaddr_in6 *sin6; 959 960 if (so_domain == AF_INET) 961 GET_TOKEN_AREA(t, dptr, sizeof(u_char) + 962 5 * sizeof(u_int16_t) + 2 * sizeof(u_int32_t)); 963 else if (so_domain == AF_INET6) 964 GET_TOKEN_AREA(t, dptr, sizeof(u_char) + | 492 if (t == NULL) 493 return (NULL); 494 495 ADD_U_CHAR(dptr, AUT_IPC_PERM); 496 497 /* 498 * Systems vary significantly in what types they use in struct 499 * ipc_perm; at least a few still use 16-bit uid's and gid's, so --- 458 unchanged lines hidden (view full) --- 958 struct sockaddr_in *sin; 959 struct sockaddr_in6 *sin6; 960 961 if (so_domain == AF_INET) 962 GET_TOKEN_AREA(t, dptr, sizeof(u_char) + 963 5 * sizeof(u_int16_t) + 2 * sizeof(u_int32_t)); 964 else if (so_domain == AF_INET6) 965 GET_TOKEN_AREA(t, dptr, sizeof(u_char) + |
965 5 * sizeof(u_int16_t) + 16 * sizeof(u_int32_t)); | 966 5 * sizeof(u_int16_t) + 8 * sizeof(u_int32_t)); |
966 else { 967 errno = EINVAL; 968 return (NULL); 969 } 970 971 ADD_U_CHAR(dptr, AUT_SOCKET_EX); | 967 else { 968 errno = EINVAL; 969 return (NULL); 970 } 971 972 ADD_U_CHAR(dptr, AUT_SOCKET_EX); |
972 ADD_U_INT16(dptr, so_domain); /* XXXRW: explicitly convert? */ 973 ADD_U_INT16(dptr, so_type); /* XXXRW: explicitly convert? */ | 973 ADD_U_INT16(dptr, au_domain_to_bsm(so_domain)); 974 ADD_U_INT16(dptr, au_socket_type_to_bsm(so_type)); |
974 if (so_domain == AF_INET) { 975 ADD_U_INT16(dptr, AU_IPv4); 976 sin = (struct sockaddr_in *)sa_local; 977 ADD_MEM(dptr, &sin->sin_port, sizeof(uint16_t)); 978 ADD_MEM(dptr, &sin->sin_addr.s_addr, sizeof(uint32_t)); 979 sin = (struct sockaddr_in *)sa_remote; 980 ADD_MEM(dptr, &sin->sin_port, sizeof(uint16_t)); 981 ADD_MEM(dptr, &sin->sin_addr.s_addr, sizeof(uint32_t)); --- 593 unchanged lines hidden --- | 975 if (so_domain == AF_INET) { 976 ADD_U_INT16(dptr, AU_IPv4); 977 sin = (struct sockaddr_in *)sa_local; 978 ADD_MEM(dptr, &sin->sin_port, sizeof(uint16_t)); 979 ADD_MEM(dptr, &sin->sin_addr.s_addr, sizeof(uint32_t)); 980 sin = (struct sockaddr_in *)sa_remote; 981 ADD_MEM(dptr, &sin->sin_port, sizeof(uint16_t)); 982 ADD_MEM(dptr, &sin->sin_addr.s_addr, sizeof(uint32_t)); --- 593 unchanged lines hidden --- |