From owner-p4-projects@FreeBSD.ORG Sat Mar 28 17:36:52 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 507B6106566B; Sat, 28 Mar 2009 17:36:52 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E4EBB1065674 for ; Sat, 28 Mar 2009 17:36:51 +0000 (UTC) (envelope-from sson@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id B8D458FC0C for ; Sat, 28 Mar 2009 17:36:51 +0000 (UTC) (envelope-from sson@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n2SHap0K067708 for ; Sat, 28 Mar 2009 17:36:51 GMT (envelope-from sson@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n2SHapKL067706 for perforce@freebsd.org; Sat, 28 Mar 2009 17:36:51 GMT (envelope-from sson@FreeBSD.org) Date: Sat, 28 Mar 2009 17:36:51 GMT Message-Id: <200903281736.n2SHapKL067706@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sson@FreeBSD.org using -f From: Stacey Son To: Perforce Change Reviews Cc: Subject: PERFORCE change 159952 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: Sat, 28 Mar 2009 17:36:53 -0000 http://perforce.freebsd.org/chv.cgi?CH=159952 Change 159952 by sson@sson_amd64 on 2009/03/28 17:36:37 Bug fixes for 'audit -s'. 'audit -s' didn't rotate the audit trail file and the kernel masks didn't get updated in the kernel. When audit_control go updated it was not re- read properly. Affected files ... .. //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.c#46 edit .. //depot/projects/trustedbsd/openbsm/libbsm/bsm_control.c#32 edit Differences ... ==== //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.c#46 (text+ko) ==== @@ -26,7 +26,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $P4: //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.c#45 $ + * $P4: //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.c#46 $ */ #include @@ -537,9 +537,12 @@ case AUDIT_TRIGGER_READ_FILE: auditd_log_info("Got read file trigger"); - if (au_state == AUD_STATE_ENABLED && - auditd_config_controls() == -1) - auditd_log_err("Error setting audit controls"); + if (au_state == AUD_STATE_ENABLED) { + if (auditd_config_controls() == -1) + auditd_log_err("Error setting audit controls"); + else if (do_trail_file() == -1) + auditd_log_err("Error swapping audit file"); + } break; case AUDIT_TRIGGER_CLOSE_AND_DIE: ==== //depot/projects/trustedbsd/openbsm/libbsm/bsm_control.c#32 (text+ko) ==== @@ -27,7 +27,7 @@ * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_control.c#31 $ + * $P4: //depot/projects/trustedbsd/openbsm/libbsm/bsm_control.c#32 $ */ #include @@ -50,6 +50,8 @@ #include #endif +#include + /* * Parse the contents of the audit_control file to return the audit control * parameters. These static fields are protected by 'mutex'. @@ -287,10 +289,27 @@ static void setac_locked(void) { + static time_t lastctime = 0; + struct stat sbuf; ptrmoved = 1; - if (fp != NULL) + if (fp != NULL) { + /* + * Check to see if the file on disk has changed. If so, + * force a re-read of the file by closing it. + */ + if (fstat(fileno(fp), &sbuf) < 0) + goto closefp; + if (lastctime != sbuf.st_ctimespec.tv_sec) { + lastctime = sbuf.st_ctimespec.tv_sec; +closefp: + fclose(fp); + fp = NULL; + return; + } + fseek(fp, 0, SEEK_SET); + } } void