Date: Sat, 24 Sep 2005 13:05:39 GMT From: Robert Watson <rwatson@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 84202 for review Message-ID: <200509241305.j8OD5dGi089662@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200509241305.j8OD5dGi089662>