From owner-p4-projects Mon Apr 8 21:21:27 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 52E1E37B416; Mon, 8 Apr 2002 21:21:15 -0700 (PDT) Delivered-To: perforce@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 271C337B417 for ; Mon, 8 Apr 2002 21:21:14 -0700 (PDT) Received: (from perforce@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g394LED72201 for perforce@freebsd.org; Mon, 8 Apr 2002 21:21:14 -0700 (PDT) (envelope-from arr@freebsd.org) Date: Mon, 8 Apr 2002 21:21:14 -0700 (PDT) Message-Id: <200204090421.g394LED72201@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: perforce set sender to arr@freebsd.org using -f From: "Andrew R. Reiter" Subject: PERFORCE change 9426 for review To: Perforce Change Reviews Sender: owner-p4-projects@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG http://people.freebsd.org/~peter/p4db/chv.cgi?CH=9426 Change 9426 by arr@arr_shibby on 2002/04/08 21:21:08 - Some style cleanup. - Better the usage of the record queue mutex. Affected files ... ... //depot/projects/trustedbsd/audit/sys/kern/kern_audit.c#19 edit Differences ... ==== //depot/projects/trustedbsd/audit/sys/kern/kern_audit.c#19 (text+ko) ==== @@ -63,8 +63,6 @@ SYSCTL_DECL(_security); SYSCTL_NODE(_security, OID_AUTO, audit, CTLFLAG_RW, 0, ""); -SYSCTL_OID(_security_audit, OID_AUTO, enabled, CTLFLAG_RW|CTLTYPE_UINT, - &audit_system_state, 0, sysctl_handle_enable, "IU", ""); static __inline audit_record_t * @@ -100,15 +98,16 @@ { audit_record_t *rec; audit_header_t *h; + vm_zone_t z; audit_id_t *id; u_long *lease; - vm_zone_t z; AINFO_LOCK(ai); lease = &ai->ai_leased; z = ai->ai_zone; id = &ai->ai_id; AINFO_UNLOCK(ai); + rec = audit_record_alloc(z, lease); bzero(rec, sizeof(*rec)); h = &rec->ar_hdr; @@ -117,7 +116,7 @@ h->ah_len = AUDIT_RECORD_SZ + evsz; h->ah_type = type; nanotime(&h->ah_evtime); - return(rec); + return (rec); } @@ -127,9 +126,9 @@ void audit_init(void) { + struct vnode *vp; struct audit_info *ai; struct ucred *cred; - struct vnode *vp; vm_zone_t zone; char *sptr; int err = 0; @@ -142,7 +141,8 @@ sptr = malloc(strlen(AUDLOG), M_TEMP, M_WAITOK|M_ZERO); strcpy(sptr, AUDLOG); - vp = audit_write_init(sptr, td, &cred); + /* XXX curthread */ + vp = audit_write_init(sptr, curthread, &cred); if (vp == NULL) panic("Unable to init audit system.\n"); @@ -171,9 +171,9 @@ void audit_shutdown(int what, void *arg, struct thread *td) { + struct vnode *vp; struct audit_info *ai = arg; struct ucred *cred; - struct vnode *vp; vm_zone_t zone = NULL; char *ptr; @@ -216,29 +216,22 @@ NDINIT(&ni, LOOKUP, NOFOLLOW, UIO_SYSSPACE, path, td); err = namei(&ni); if (err != 0) - return(NULL); + return (NULL); err = vn_open(&ni, &flag, S_IRUSR | S_IWUSR); if (err != 0) - return(NULL); + return (NULL); NDFREE(&ni, NDF_ONLY_PNBUF); vp = ni.ni_vp; VOP_UNLOCK(vp, 0, td); - return(vp); + return (vp); } void audit_write_shutdown(struct vnode *vp, struct thread *td, struct ucred *cred) { - struct proc *p = td->td_proc; - - /* - * XXX arr: Essentially this is a temporary function - * that here for debugging purposes. - */ vn_close(vp, 0, cred, td); crfree(cred); - return; } int @@ -267,10 +260,10 @@ lf.l_type = F_WRLCK; err = VOP_ADVLOCK(vp, (caddr_t)td->td_proc, F_SETLK, &lf, F_FLOCK); if (err != 0) - return(err); + return (err); err = vn_start_write(vp, &mp, V_NOWAIT); - if (err != 0) { + if (err != 0) /* * If we can't write to the audit file from kernel * land, then something is wrong. In the future, @@ -278,8 +271,6 @@ * but for now, we panic. */ panic("unable to write to audit log."); - - } vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, td); VOP_LEASE(vp, td, td->td_ucred, LEASE_WRITE); @@ -293,7 +284,7 @@ td->td_proc->p_ucred); VOP_UNLOCK(vp, 0, td); vn_finished_write(mp); - return(ar->ar_hdr.ah_len); + return (ar->ar_hdr.ah_len); } void @@ -304,25 +295,24 @@ u_long *lease; vm_zone_t z; - mtx_lock(&record_queue_mtx); for (;;) { ar = NULL; + mtx_lock(&record_queue_mtx); TAILQ_REMOVE(&record_queue, ar, ar_next); + mtx_unlock(&record_queue_mtx); if (ar) { - (void)audit_record_write(ar, NULL, NULL); /* XXX */ + /* XXX */ + (void)audit_record_write(ar, NULL, NULL); AINFO_LOCK(ai); z = ai->ai_zone; lease = &ai->ai_leased; AINFO_UNLOCK(ai); audit_record_free(ar, z, lease); } else if (ar == NULL && audit_shutdown_flag) { - mtx_unlock(&record_queue_mtx); mtx_destroy(&record_queue_mtx); kthread_exit(0); } if (audit_shutdown_flag) continue; - msleep(&record_queue, &record_queue_mtx, PPAUSE, - "Record queue", 0); } } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message