From owner-p4-projects@FreeBSD.ORG Sat Sep 24 13:05:41 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 6E78A16A41F; Sat, 24 Sep 2005 13:05:41 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2FD3C16A41F for ; Sat, 24 Sep 2005 13:05:41 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 96FFE43D5C for ; Sat, 24 Sep 2005 13:05:39 +0000 (GMT) (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j8OD5dIO089665 for ; Sat, 24 Sep 2005 13:05:39 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j8OD5dGi089662 for perforce@freebsd.org; Sat, 24 Sep 2005 13:05:39 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Sat, 24 Sep 2005 13:05:39 GMT Message-Id: <200509241305.j8OD5dGi089662@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to bb+lists.freebsd.perforce@cyrus.watson.org using -f From: Robert Watson To: Perforce Change Reviews Cc: Subject: PERFORCE change 84202 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 24 Sep 2005 13:05:42 -0000 http://perforce.freebsd.org/chv.cgi?CH=84202 Change 84202 by rwatson@rwatson_peppercorn on 2005/09/24 13:05:05 staticize audit_init(), audit_shutdown(), since in FreeBSD they are able to register themselves using linker sets rather than explicit calls in centralized boot/shutdown code. Register audit_shutdown() with the pre-sync shutdown code so that auditing is turned off and the vnode unreferenced before file systems are unmounted, which can otherwise result in a long delay during shutdown. Affected files ... .. //depot/projects/trustedbsd/audit3/sys/bsm/audit_kernel.h#16 edit .. //depot/projects/trustedbsd/audit3/sys/security/audit/kern_audit.c#37 edit Differences ... ==== //depot/projects/trustedbsd/audit3/sys/bsm/audit_kernel.h#16 (text+ko) ==== @@ -240,8 +240,6 @@ void audit_abort(struct kaudit_record *ar); void audit_commit(struct kaudit_record *ar, int error, int retval); -void audit_init(void); -void audit_shutdown(void); struct kaudit_record *audit_new(int event, struct thread *td); ==== //depot/projects/trustedbsd/audit3/sys/security/audit/kern_audit.c#37 (text+ko) ==== @@ -206,6 +206,11 @@ static int audit_isopen = 0; static TAILQ_HEAD(, trigger_info) trigger_list; +/* + * Forward declarations of static functions. + */ +static void audit_shutdown(void *arg, int howto); + static int audit_open(struct cdev *dev, int oflags, int devtype, struct thread *td) { @@ -723,7 +728,7 @@ * synchronization primitives, worker thread, and trigger device node. Also * call into the BSM assembly code to initialize it. */ -void +static void audit_init(void) { int error; @@ -754,12 +759,16 @@ /* Initialize the BSM audit subsystem. */ kau_init(); + TAILQ_INIT(&trigger_list); + + /* Register shutdown handler. */ + EVENTHANDLER_REGISTER(shutdown_pre_sync, audit_shutdown, NULL, + SHUTDOWN_PRI_FIRST); + error = kthread_create(audit_worker, NULL, &audit_thread, RFHIGHPID, 0, "audit_worker"); if (error != 0) panic("audit_init: kthread_create returned %d", error); - - TAILQ_INIT(&trigger_list); } static void @@ -842,10 +851,12 @@ } /* - * Drain the audit queue and close the log at shutdown. + * Drain the audit queue and close the log at shutdown. Note that this can + * be called both from the system shutdown path and also from audit + * configuration syscalls, so 'arg' and 'howto' are ignored. */ -void -audit_shutdown(void) +static void +audit_shutdown(void *arg, int howto) { audit_rotate_vnode(NULL, NULL); @@ -1065,7 +1076,7 @@ audit_suspended = 0; if (udata.au_cond == AUC_DISABLED) { audit_suspended = 1; - audit_shutdown(); + audit_shutdown(NULL, 0); } break; case A_GETCLASS: @@ -2448,18 +2459,6 @@ #else /* !AUDIT */ -void -audit_init(void) -{ - -} - -void -audit_shutdown(void) -{ - -} - int audit(struct thread *td, struct audit_args *uap) {