From owner-p4-projects Mon Apr 8 17:22:30 2002 Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 0E78937B41D; Mon, 8 Apr 2002 17:22:14 -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 2BDF937B41A for ; Mon, 8 Apr 2002 17:22:13 -0700 (PDT) Received: (from perforce@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g390MCM19438 for perforce@freebsd.org; Mon, 8 Apr 2002 17:22:12 -0700 (PDT) (envelope-from arr@freebsd.org) Date: Mon, 8 Apr 2002 17:22:12 -0700 (PDT) Message-Id: <200204090022.g390MCM19438@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 9414 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=9414 Change 9414 by arr@arr_shibby on 2002/04/08 17:22:12 - Add SYSUNINIT; this will be a basis for shutdown log writing. - Static-ize some variables. - Make use of ai_lname. Affected files ... ... //depot/projects/trustedbsd/audit/sys/kern/kern_audit.c#16 edit Differences ... ==== //depot/projects/trustedbsd/audit/sys/kern/kern_audit.c#16 (text+ko) ==== @@ -52,13 +52,12 @@ static __inline void audit_record_free(audit_record_t *, vm_zone_t, u_long *); static __inline audit_id_t audit_record_generate_id(audit_id_t *); -struct audit_info ainfo; -const char *audit_file = "/var/log/audit"; /* XXX */ -struct audit_record_list record_queue; -struct mtx record_queue_mtx; -int audit_shutdown_flag = 0; -size_t audit_system_state = 0; -size_t pool_size = 32; +static struct audit_info ainfo; +static struct audit_record_list record_queue; +static struct mtx record_queue_mtx; + +static int audit_shutdown_flag = 0; +static size_t pool_size = 32; SYSCTL_DECL(_security); SYSCTL_NODE(_security, OID_AUTO, audit, CTLFLAG_RW, 0, ""); @@ -124,21 +123,24 @@ * Executed when the audit system is turned on. */ void -audit_init(int what, void *arg, struct thread *td) +audit_init(void) { - struct audit_info *ai = arg; + struct audit_info *ai; struct ucred *cred; struct vnode *vp; vm_zone_t zone; + char *sptr; int err = 0; - if (audit_system_state != 0) - return; + ai = &ainfo; bzero(ai, sizeof(*ai)); mtx_init(&ai->ai_mtx, "audit info lock", 0, MTX_DEF); - vp = audit_write_init(audit_file, td, &cred); + sptr = malloc(strlen(AUDLOG), M_TEMP, M_WAITOK|M_ZERO); + strcpy(sptr, AUDLOG); + + vp = audit_write_init(sptr, td, &cred); if (vp == NULL) panic("Unable to init audit system.\n"); @@ -150,6 +152,7 @@ ai->ai_cred = cred; ai->ai_vp = vp; ai->ai_zone = zone; + ai->ai_lname = sptr; AINFO_UNLOCK(ai); mtx_init(&record_queue_mtx, "audit record queue lock", MTX_DEF); @@ -170,22 +173,23 @@ struct ucred *cred; struct vnode *vp; vm_zone_t zone = NULL; + char *ptr; - if (!audit_system_state) - return; - audit_shutdown_flag = 1; AINFO_LOCK(ai); cred = ai->ai_cred; vp = ai->ai_vp; zone = ai->ai_zone; + ptr = ai->ai_lname; AINFO_UNLOCK(ai); mtx_destroy(&ai->ai_mtx); bzero(ai, sizeof(*ai)); + free(ptr, M_TEMP); audit_write_shutdown(vp, td, cred); zdestroy(zone); } +SYSUNINIT(tbsd_audit, SI_ORDER_ANY, SI_SUB_MAC, &audit_shutdown, NULL); static void audit_record_enqueue(audit_record_t *ar) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message