From owner-p4-projects@FreeBSD.ORG Tue Jan 31 15:15:17 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 A4F7716A426; Tue, 31 Jan 2006 15:15:16 +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 34E9816A423 for ; Tue, 31 Jan 2006 15:15:16 +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 9CD3543D8F for ; Tue, 31 Jan 2006 15:15:00 +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 k0VFF0fa044447 for ; Tue, 31 Jan 2006 15:15:00 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 k0VFF0lL044436 for perforce@freebsd.org; Tue, 31 Jan 2006 15:15:00 GMT (envelope-from bb+lists.freebsd.perforce@cyrus.watson.org) Date: Tue, 31 Jan 2006 15:15:00 GMT Message-Id: <200601311515.k0VFF0lL044436@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 90786 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 15:15:17 -0000 http://perforce.freebsd.org/chv.cgi?CH=90786 Change 90786 by rwatson@rwatson_zoo on 2006/01/31 15:14:04 Convert local 'flags' to 'global_flags' and make global, so that the flags generated from the command line are accessible after auditd has started. Add handle_sighup(), which calls config_audit_controls() to update the auditd configuration in the event that SIGHUP is received. If EINTR is returned by the read on the device or fifo, continue rather than logging that -1 was received. Affected files ... .. //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.c#7 edit Differences ... ==== //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.c#7 (text+ko) ==== @@ -30,7 +30,7 @@ * * @APPLE_BSD_LICENSE_HEADER_END@ * - * $P4: //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.c#6 $ + * $P4: //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.c#7 $ */ #include @@ -64,9 +64,12 @@ static int triggerfd = 0; static int sighups, sighups_handled; static int sigterms, sigterms_handled; +static long global_flags; static TAILQ_HEAD(, dir_ent) dir_q; +static int config_audit_controls(void); + /* * Error starting auditd */ @@ -525,6 +528,14 @@ } } +static void +handle_sighup(void) +{ + + sighups_handled = sighups; + config_audit_controls(); +} + /* * Read the control file for triggers and handle appropriately. */ @@ -540,14 +551,20 @@ syslog(LOG_ERR, "%s: error %d\n", __FUNCTION__, errno); return (-1); } + if (sigterms != sigterms_handled) { + syslog(LOG_INFO, "%s: SIGTERM", __FUNCTION__); + break; + } + if (sighups != sighups_handled) { + syslog(LOG_INFO, "%s: SIGHUP", __FUNCTION__); + handle_sighup(); + } + if ((num == -1) && (errno == EINTR)) + continue; if (num == 0) { 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; @@ -582,7 +599,7 @@ * kernel preselection mask, etc. */ static int -config_audit_controls(long flags) +config_audit_controls(void) { au_event_ent_t ev, *evp; au_evclass_map_t evc_map; @@ -646,14 +663,14 @@ /* * Set the audit policy flags based on passed in parameter values. */ - if (auditon(A_SETPOLICY, &flags, sizeof(flags))) + if (auditon(A_SETPOLICY, &global_flags, sizeof(global_flags))) syslog(LOG_ERR, "Failed to set audit policy."); return (0); } static void -setup(long flags) +setup(void) { int aufd; token_t *tok; @@ -680,7 +697,7 @@ "Could not close audit startup event.\n"); } - if (config_audit_controls(flags) == 0) + if (config_audit_controls() == 0) syslog(LOG_INFO, "Audit controls init successful\n"); else syslog(LOG_INFO, "Audit controls init failed\n"); @@ -690,10 +707,10 @@ main(int argc, char **argv) { char ch; - long flags = AUDIT_CNT; int debug = 0; int rc; + global_flags |= AUDIT_CNT; while ((ch = getopt(argc, argv, "dhs")) != -1) { switch(ch) { case 'd': @@ -703,12 +720,12 @@ case 's': /* Fail-stop option. */ - flags &= ~(AUDIT_CNT); + global_flags &= ~(AUDIT_CNT); break; case 'h': /* Halt-stop option. */ - flags |= AUDIT_AHLT; + global_flags |= AUDIT_AHLT; break; case '?': @@ -732,7 +749,7 @@ exit(1); } - setup(flags); + setup(); rc = wait_for_triggers(); syslog(LOG_INFO, "auditd exiting.\n");