From owner-p4-projects Tue Apr 9 12:21:21 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 70BC537B41A; Tue, 9 Apr 2002 12:21:11 -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 8121737B41B for ; Tue, 9 Apr 2002 12:21:10 -0700 (PDT) Received: (from perforce@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g39JL9R62159 for perforce@freebsd.org; Tue, 9 Apr 2002 12:21:09 -0700 (PDT) (envelope-from arr@freebsd.org) Date: Tue, 9 Apr 2002 12:21:09 -0700 (PDT) Message-Id: <200204091921.g39JL9R62159@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 9457 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=9457 Change 9457 by arr@arr_shibby on 2002/04/09 12:20:46 - Use curthread instead of a passed in thread pointer in some places. - Remember crfree() our saved cred. - Rearrange a check of the shutdown flag, so we can better handle a bad situation -- this needs to possibly lock the flag on write Affected files ... ... //depot/projects/trustedbsd/audit/sys/kern/kern_audit.c#20 edit Differences ... ==== //depot/projects/trustedbsd/audit/sys/kern/kern_audit.c#20 (text+ko) ==== @@ -87,9 +87,6 @@ audit_record_generate_id(audit_id_t *id) { - /* - * XXX - */ return(*++id); } @@ -128,7 +125,6 @@ { struct vnode *vp; struct audit_info *ai; - struct ucred *cred; vm_zone_t zone; char *sptr; int err = 0; @@ -141,8 +137,7 @@ sptr = malloc(strlen(AUDLOG), M_TEMP, M_WAITOK|M_ZERO); strcpy(sptr, AUDLOG); - /* XXX curthread */ - vp = audit_write_init(sptr, curthread, &cred); + vp = audit_write_init(sptr, curthread, curthread->td_ucred); if (vp == NULL) panic("Unable to init audit system.\n"); @@ -151,7 +146,7 @@ panic("audit_init: unable to init audit record zone"); AINFO_LOCK(ai); - ai->ai_cred = cred; + ai->ai_cred = curthread->td_ucred; ai->ai_vp = vp; ai->ai_zone = zone; ai->ai_lname = sptr; @@ -169,15 +164,17 @@ SYSINIT(tbsd_audit, SI_ORDER_ANY, SI_SUB_MAC, &audit_init, NULL); void -audit_shutdown(int what, void *arg, struct thread *td) +audit_shutdown(void) { struct vnode *vp; - struct audit_info *ai = arg; + struct audit_info *ai; struct ucred *cred; vm_zone_t zone = NULL; char *ptr; audit_shutdown_flag = 1; + ai = &ainfo; + AINFO_LOCK(ai); cred = ai->ai_cred; vp = ai->ai_vp; @@ -185,10 +182,10 @@ ptr = ai->ai_lname; AINFO_UNLOCK(ai); mtx_destroy(&ai->ai_mtx); + free(ptr, M_TEMP); bzero(ai, sizeof(*ai)); - - free(ptr, M_TEMP); - audit_write_shutdown(vp, td, cred); + audit_write_shutdown(vp, curthread, cred); /* curthread ok? */ + crfree(cred); zdestroy(zone); } SYSUNINIT(tbsd_audit, SI_ORDER_ANY, SI_SUB_MAC, &audit_shutdown, NULL); @@ -300,19 +297,20 @@ mtx_lock(&record_queue_mtx); TAILQ_REMOVE(&record_queue, ar, ar_next); mtx_unlock(&record_queue_mtx); + + /* XXX Check flag here and hope it doesnt change. */ + if (audit_shutdown_flag) { + mtx_destroy(&record_queue_mtx); + kthread_exit(0); + } + if (ar) { - /* 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_destroy(&record_queue_mtx); - kthread_exit(0); } - if (audit_shutdown_flag) - continue; } } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message