]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/security/audit/audit_arg.c
xnu-3789.41.3.tar.gz
[apple/xnu.git] / bsd / security / audit / audit_arg.c
index eb6d5d4346526f755b42eb4e3184a53f582199bf..00f65b3e0ba7b803d4f456f655ab6bb5128fd965 100644 (file)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 1999-2009 Apple Inc.
+ * Copyright (c) 1999-2016 Apple Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -75,8 +75,6 @@
 #include <kern/host.h>
 #include <kern/kalloc.h>
 #include <kern/zalloc.h>
-#include <kern/lock.h>
-#include <kern/wait_queue.h>
 #include <kern/sched_prim.h>
 
 #if CONFIG_MACF
@@ -136,6 +134,14 @@ audit_arg_len(struct kaudit_record *ar, user_size_t len)
        ARG_SET_VALID(ar, ARG_LEN);
 }
 
+void
+audit_arg_fd2(struct kaudit_record *ar, int fd)
+{
+
+       ar->k_ar.ar_arg_fd2 = fd;
+       ARG_SET_VALID(ar, ARG_FD2);
+}
+
 void
 audit_arg_fd(struct kaudit_record *ar, int fd)
 {
@@ -594,7 +600,7 @@ audit_arg_file(struct kaudit_record *ar, __unused proc_t p,
        struct sockaddr_in *sin;
        struct sockaddr_in6 *sin6;
 
-       switch (fp->f_fglob->fg_type) {
+       switch (FILEGLOB_DTYPE(fp->f_fglob)) {
        case DTYPE_VNODE:
        /* case DTYPE_FIFO: */
                audit_arg_vnpath_withref(ar,
@@ -603,15 +609,13 @@ audit_arg_file(struct kaudit_record *ar, __unused proc_t p,
 
        case DTYPE_SOCKET:
                so = (struct socket *)fp->f_fglob->fg_data;
-               if (INP_CHECK_SOCKAF(so, PF_INET)) {
+               if (SOCK_CHECK_DOM(so, PF_INET)) {
                        if (so->so_pcb == NULL)
                                break;
                        ar->k_ar.ar_arg_sockinfo.sai_type =
                            so->so_type;
-                       ar->k_ar.ar_arg_sockinfo.sai_domain =
-                           INP_SOCKAF(so);
-                       ar->k_ar.ar_arg_sockinfo.sai_protocol =
-                           so->so_proto->pr_protocol;
+                       ar->k_ar.ar_arg_sockinfo.sai_domain = SOCK_DOM(so);
+                       ar->k_ar.ar_arg_sockinfo.sai_protocol = SOCK_PROTO(so);
                        pcb = (struct inpcb *)so->so_pcb;
                        sin = (struct sockaddr_in *)
                            &ar->k_ar.ar_arg_sockinfo.sai_faddr;
@@ -623,15 +627,13 @@ audit_arg_file(struct kaudit_record *ar, __unused proc_t p,
                        sin->sin_port = pcb->inp_lport;
                        ARG_SET_VALID(ar, ARG_SOCKINFO);
                }
-               if (INP_CHECK_SOCKAF(so, PF_INET6)) {
+               if (SOCK_CHECK_DOM(so, PF_INET6)) {
                        if (so->so_pcb == NULL)
                                break;
                        ar->k_ar.ar_arg_sockinfo.sai_type =
                            so->so_type;
-                       ar->k_ar.ar_arg_sockinfo.sai_domain =
-                           INP_SOCKAF(so);
-                       ar->k_ar.ar_arg_sockinfo.sai_protocol =
-                           so->so_proto->pr_protocol;
+                       ar->k_ar.ar_arg_sockinfo.sai_domain = SOCK_DOM(so);
+                       ar->k_ar.ar_arg_sockinfo.sai_protocol = SOCK_PROTO(so);
                        pcb = (struct inpcb *)so->so_pcb;
                        sin6 = (struct sockaddr_in6 *)
                            &ar->k_ar.ar_arg_sockinfo.sai_faddr;