PERFORCE change 90781 for review

Robert Watson rwatson at FreeBSD.org
Tue Jan 31 12:38:49 GMT 2006


http://perforce.freebsd.org/chv.cgi?CH=90781

Change 90781 by rwatson at rwatson_peppercorn on 2006/01/31 12:38:17

	Listen for SIGTERM instead of SIGHUP for exit -- this will result
	in greater happiness if init is killing everything.  HUP is more
	traditionally use for reloading configuration information.  When
	this is integrated to audit3, the rc.d script will need updating.
	
	Use setauevent() to reset the event pointer before starting.

Affected files ...

.. //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.8#5 edit
.. //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.c#6 edit

Differences ...

==== //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.8#5 (text+ko) ====

@@ -29,7 +29,7 @@
 .\"
 .\" @APPLE_BSD_LICENSE_HEADER_END@
 .\"
-.\" $P4: //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.8#4 $
+.\" $P4: //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.8#5 $
 .\"
 .Dd Jan 24, 2004
 .Dt AUDITD 8
@@ -67,7 +67,10 @@
 should be used to inform the daemon to change state/configuration after altering
 the audit_control file.
 .Pp
-Sending a SIGHUP to a running
+.\" Sending a SIGHUP to a running
+.\" .Nm auditd
+.\" daemon will force it to exit.
+Sending a SIGTERM to a running
 .Nm auditd
 daemon will force it to exit.
 .Sh FILES

==== //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.c#6 (text+ko) ====

@@ -30,7 +30,7 @@
  *
  * @APPLE_BSD_LICENSE_HEADER_END@
  *
- * $P4: //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.c#5 $
+ * $P4: //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.c#6 $
  */
 
 #include <sys/dirent.h>
@@ -62,6 +62,8 @@
 static char	*lastfile = NULL;
 static int	 allhardcount = 0;
 static int	 triggerfd = 0;
+static int	 sighups, sighups_handled;
+static int	 sigterms, sigterms_handled;
 
 static TAILQ_HEAD(, dir_ent)	dir_q;
 
@@ -351,12 +353,15 @@
  * be done in the signal handler itself.  Instead,  we send a message to the
  * main servicing loop to do proper handling from a non-signal-handler
  * context.
- *
- * XXXRW: I don't see that happening here.
  */
 static void
 relay_signal(int signal)
 {
+
+	if (signal == SIGHUP)
+		sighups++;
+	if (signal == SIGTERM)
+		sigterms++;
 }
 
 /*
@@ -380,6 +385,11 @@
 		    "Could not set signal handler for SIGCHLD\n");
 		fail_exit();
 	}
+	if (signal(SIGHUP, relay_signal) == SIG_ERR) {
+		syslog(LOG_ERR,
+		    "Could not set signal handler for SIGHUP\n");
+		fail_exit();
+	}
 
 	if ((pidfile = fopen(AUDITD_PIDFILE, "a")) == NULL) {
 		syslog(LOG_ERR,
@@ -534,6 +544,10 @@
 			syslog(LOG_INFO, "%s: read EOF\n", __FUNCTION__);
 			return (-1);
 		}
+		if (sigterms != sigterms_handled) {
+			syslog(LOG_INFO, "%s: SIGTERM", __FUNCTION__);
+			break;
+		}
 		syslog(LOG_INFO, "%s: read %d\n", __FUNCTION__, trigger);
 		if (trigger == AUDIT_TRIGGER_CLOSE_AND_DIE)
 			break;
@@ -592,6 +606,7 @@
 		return (-1);
 	}
 	evp = &ev;
+	setauevent();
 	while ((evp = getauevent_r(evp)) != NULL) {
 		evc_map.ec_number = evp->ae_number;
 		evc_map.ec_class = evp->ae_class;
To Unsubscribe: send mail to majordomo at trustedbsd.org
with "unsubscribe trustedbsd-cvs" in the body of the message



More information about the trustedbsd-cvs mailing list