From owner-p4-projects@FreeBSD.ORG Tue Jan 31 12:38:51 2006 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 94B0C16A423; Tue, 31 Jan 2006 12:38:50 +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 3A86F16A420 for ; Tue, 31 Jan 2006 12:38:50 +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 F3A3243D46 for ; Tue, 31 Jan 2006 12:38:49 +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 k0VCcnkt029375 for ; Tue, 31 Jan 2006 12:38:49 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 k0VCcnXq029372 for perforce@freebsd.org; Tue, 31 Jan 2006 12:38:49 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Tue, 31 Jan 2006 12:38:49 GMT Message-Id: <200601311238.k0VCcnXq029372@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 90781 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: Tue, 31 Jan 2006 12:38:51 -0000 http://perforce.freebsd.org/chv.cgi?CH=90781 Change 90781 by rwatson@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 @@ -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;