Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Apr 2002 17:22:12 -0700 (PDT)
From:      "Andrew R. Reiter" <arr@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 9414 for review
Message-ID:  <200204090022.g390MCM19438@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200204090022.g390MCM19438>