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#93 |
34 */ 35 36#include <sys/cdefs.h> |
37__FBSDID("$FreeBSD: head/sys/security/audit/audit_bsm_token.c 195740 2009-07-17 14:02:20Z 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> --- 879 unchanged lines hidden (view full) --- 925 926 return (t); 927} 928#endif 929 930/* 931 * token ID 1 byte 932 * socket family 2 bytes |
933 * path (up to) 104 bytes + NULL (NULL terminated string) |
934 */ 935token_t * 936au_to_sock_unix(struct sockaddr_un *so) 937{ 938 token_t *t; 939 u_char *dptr; 940 941 GET_TOKEN_AREA(t, dptr, 3 * sizeof(u_char) + strlen(so->sun_path) + 1); --- 241 unchanged lines hidden (view full) --- 1183/* 1184 * Collects audit information for the current process and creates a subject 1185 * token from it. 1186 */ 1187token_t * 1188au_to_me(void) 1189{ 1190 auditinfo_t auinfo; |
1191 auditinfo_addr_t aia; |
1192 |
1193 /* 1194 * Try to use getaudit_addr(2) first. If this kernel does not support 1195 * it, then fall back on to getaudit(2). 1196 */ 1197 if (getaudit_addr(&aia, sizeof(aia)) != 0) { 1198 if (errno == ENOSYS) { 1199 if (getaudit(&auinfo) != 0) 1200 return (NULL); 1201 return (au_to_subject32(auinfo.ai_auid, geteuid(), 1202 getegid(), getuid(), getgid(), getpid(), 1203 auinfo.ai_asid, &auinfo.ai_termid)); 1204 } else { 1205 /* getaudit_addr(2) failed for some other reason. */ 1206 return (NULL); 1207 } 1208 } |
1209 |
1210 return (au_to_subject32_ex(aia.ai_auid, geteuid(), getegid(), getuid(), 1211 getgid(), getpid(), aia.ai_asid, &aia.ai_termid)); |
1212} 1213#endif 1214 1215#if defined(_KERNEL) || defined(KERNEL) 1216static token_t * 1217au_to_exec_strings(char *strs, int count, u_char type) 1218{ 1219 token_t *t; --- 326 unchanged lines hidden --- |