FreeBSD/sys/security/audit/audit_arg.c
/*
 * Audit information about a file, either the file's vnode info, or its
 * socket address info.
 */
Audit information about a file, either the file's vnode info, or its
socket address info.
Audit information about a file either the file ' s vnode info or its socket address info .
void
audit_arg_file(struct proc *p, struct file *fp)
{
	struct kaudit_record *ar;
	struct socket *so;
	struct inpcb *pcb;
	struct vnode *vp;
	ar = currecord();
	if (ar == NULL)
		return;
	switch (fp->f_type) {
	case DTYPE_VNODE:
	case DTYPE_FIFO:
		vp = fp->f_vnode;
		vn_lock(vp, LK_SHARED | LK_RETRY);
		audit_arg_vnode1(vp);
		VOP_UNLOCK(vp, 0);
		break;
	case DTYPE_SOCKET:
		so = (struct socket *)fp->f_data;
		if (INP_CHECK_SOCKAF(so, PF_INET)) {
			SOCK_LOCK(so);
			ar->k_ar.ar_arg_sockinfo.so_type =
			    so->so_type;
			ar->k_ar.ar_arg_sockinfo.so_domain =
			    INP_SOCKAF(so);
			ar->k_ar.ar_arg_sockinfo.so_protocol =
			    so->so_proto->pr_protocol;
			SOCK_UNLOCK(so);
			pcb = (struct inpcb *)so->so_pcb;
			INP_RLOCK(pcb);
			ar->k_ar.ar_arg_sockinfo.so_raddr =
			    pcb->inp_faddr.s_addr;
			ar->k_ar.ar_arg_sockinfo.so_laddr =
			    pcb->inp_laddr.s_addr;
			ar->k_ar.ar_arg_sockinfo.so_rport =
			    pcb->inp_fport;
			ar->k_ar.ar_arg_sockinfo.so_lport =
			    pcb->inp_lport;
			INP_RUNLOCK(pcb);
			ARG_SET_VALID(ar, ARG_SOCKINFO);
		}
		break;
	default:
		break;
	}
}
void audit_arg_file ( struct proc * p , struct file * fp ) { struct kaudit_record * ar ; struct socket * so ; struct inpcb * pcb ; struct vnode * vp ; ar = currecord ( ) ; if ( ar == NULL ) return ; switch ( fp -> f_type ) { case DTYPE_VNODE : case DTYPE_FIFO : vp = fp -> f_vnode ; vn_lock ( vp , LK_SHARED | LK_RETRY ) ; audit_arg_vnode1 ( vp ) ; VOP_UNLOCK ( vp , 0 ) ; break ; case DTYPE_SOCKET : so = ( struct socket * ) fp -> f_data ; if ( INP_CHECK_SOCKAF ( so , PF_INET ) ) { SOCK_LOCK ( so ) ; ar -> k_ar . ar_arg_sockinfo . so_type = so -> so_type ; ar -> k_ar . ar_arg_sockinfo . so_domain = INP_SOCKAF ( so ) ; ar -> k_ar . ar_arg_sockinfo . so_protocol = so -> so_proto -> pr_protocol ; SOCK_UNLOCK ( so ) ; pcb = ( struct inpcb * ) so -> so_pcb ; INP_RLOCK ( pcb ) ; ar -> k_ar . ar_arg_sockinfo . so_raddr = pcb -> inp_faddr . s_addr ; ar -> k_ar . ar_arg_sockinfo . so_laddr = pcb -> inp_laddr . s_addr ; ar -> k_ar . ar_arg_sockinfo . so_rport = pcb -> inp_fport ; ar -> k_ar . ar_arg_sockinfo . so_lport = pcb -> inp_lport ; INP_RUNLOCK ( pcb ) ; ARG_SET_VALID ( ar , ARG_SOCKINFO ) ; } break ; default : break ; } }
Audit information about a file, either the file's vnode info, or its
 socket address info.
Audit information about a file either the file ' s vnode info or its socket address info .
/*
		 * XXXAUDIT: Only possibly to record as first vnode?
		 */ /* XXXAUDIT: else? */