From nobody Thu Nov 05 15:12:44 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jL5Qh3HPvz709sL for ; Thu, 05 Nov 2026 15:12:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jL5Qh0X98z4D3W for ; Thu, 05 Nov 2026 15:12:44 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793891564; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=a1iTTuhUKT4EFbVli95gKdQ71+vdcdkcbiyeOLCgN1M=; b=MneHBoWIdF1jcGnO+7nF9J+QWsZAx8yvxVKEZg5VIvZ+dx/ji+Nwlr8gm+3jJQHlUYPwew xL51iQXJtgG5TA/iNyxWtUe8oQHr7heP/q8lR0mXwmEvWtQYCnG4yo4mvr8DUlxeueyodl KKUkyLfvHQYCn4gtAMzl+zutKz+SjSKJGysgiFhdtripCApNaX05wcZKm5Zt/y1cCyN8+/ VAYrD9+6unCviMxTEVDvzaXstI9ZKFAgP7/IOfqgfr65M6xieptwDUsQgRNl8WxaZLawoz NF14Obq3dDdzNIduQf5RrCUCLV1T80EJd0xwFYa1AmOP7aSMP5DAJkgftfSXHA== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793891564; b=V/2vP2300mdxaVvY6l0qYv8ewuMN6AC1EaGG3Ba9TBhfv9Sp27SF6GM06TfB09vQoUd7jy D97fk5xMhJzLR0N+Q1726B0aJsV2rCmylD5G1tlG5ONy7zdS6a+bENgQxVuF+dOAMXF8zb fLdSq9DHtsbnBVuiUUB+g0qyOFqu9ircBnFuwNJYp1abFQ5SN6k0U5gIbnXhmJNg1NNslC GY2izdfEC9rFr6scqfyf7n9ZEJ2el7OueyK6F5YtKHD2OJCEp3KKTFuAtcqee/Ngvf2Ore 8tZSu/3edApuNUwJIvrpoP/+ZR+TpmCiSRP1mZVXRfyVUdksvfBt8RMaRQjdBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793891564; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=a1iTTuhUKT4EFbVli95gKdQ71+vdcdkcbiyeOLCgN1M=; b=O3+yT2Hki8yA1LVLwTVeVwr/WcvHUBx4hn2f7B//kppbpNKvEkRH6j+mkn6l5PFN+OPCzd Jxwb7yGrvMXNIQfXa7vvbk6eZivFvrcZin7NEk/ry2w00XGd+T3zI/iYKr4KmYyHx2YOSM 0dgJbBAB0HT0aK77g9lKGvEt07S1J6uACDkMwa6RL0WexXtDKhd/M+9WErlufv2Cda0IgH lgbswb/oioZzKyoMiS6AD8Sk/q4RR2df4yWhADcN5hGzbuI/7lqyuCNP5VmLsTas/byc8O 0JyM+TOdrvSbQejxRFP1K7HWNHgFai5N7fWFnc0ZOT9Sy9xEGFwEu1ISeUeImw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jL5Qh0CW8zwNt for ; Thu, 05 Nov 2026 15:12:44 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 24ed8 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 05 Nov 2026 15:12:44 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: db62d5abc6d6 - stable/14 - auditd: Support logging directly to syslog List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: db62d5abc6d69b4dc5fd43bd783fd4ff61d15369 Auto-Submitted: auto-generated Date: Thu, 05 Nov 2026 15:12:44 +0000 Message-Id: <6aec9cec.24ed8.b182153@gitrepo.freebsd.org> The branch stable/14 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=db62d5abc6d69b4dc5fd43bd783fd4ff61d15369 commit db62d5abc6d69b4dc5fd43bd783fd4ff61d15369 Author: Dag-Erling Smørgrav AuthorDate: 2026-11-04 15:32:33 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-11-05 15:11:58 +0000 auditd: Support logging directly to syslog Every tenth call to auditwarnlog(), check that the audit_warn(5) script exists and is executable by us. If it is, execute it as previously; otherwise, fall back to calling syslog(3) directly. Additionally, if we choose to use the script and fail, also log the original message to syslogd, not just the fact that we failed to log. We could record the result of trying to execute the script, but that would require pausing while it runs (or at least until the execve(2) call has completed). Retesting every tenth call is a little clunky but avoids having to restart or signal auditd(8) to force it to notice a change in availability, or adding a command-line option and / or modifying the audit_control(5) syntax to let the user express a preference. MFC after: 1 week Sponsored by: Klara, Inc. Sponsored by: Qualys, Inc. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D60172 (cherry picked from commit b18489dd60980e51093f196299eb8c38b12daa20) --- contrib/openbsm/bin/auditd/audit_warn.c | 39 ++++++++++++++++++++++++++++++++- contrib/openbsm/man/audit_warn.5 | 8 ++++++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/contrib/openbsm/bin/auditd/audit_warn.c b/contrib/openbsm/bin/auditd/audit_warn.c index 04a6e1caf03c..2c237a661bcd 100644 --- a/contrib/openbsm/bin/auditd/audit_warn.c +++ b/contrib/openbsm/bin/auditd/audit_warn.c @@ -36,16 +36,52 @@ #include "auditd.h" +#define USE_SCRIPT_RECHECK 10 + /* * Write an audit-related error to the system log via syslog(3). */ static int +auditwarnsyslog(char *args[]) +{ + /* + * Don't waste time and memory assembling a log message in a + * buffer before calling syslog(3); none of our callers pass more + * than two arguments. Note that main() always calls openlog(3), + * so no additional setup is required. + */ + // assert(args[0] != NULL); + if (args[1] == NULL) { + syslog(LOG_WARNING, "audit warning: %s", args[0]); + } else { + syslog(LOG_WARNING, "audit warning: %s %s", args[0], args[1]); + // assert(args[2] == NULL); + } + return (0); +} + +/* + * Log an audit-related error + */ +static int auditwarnlog(char *args[]) { + static int use_script; char *loc_args[9]; pid_t pid; int i; + if (use_script == 0) { + if (eaccess(AUDITWARN_SCRIPT, X_OK) == 0) + use_script = USE_SCRIPT_RECHECK; + else + use_script = -USE_SCRIPT_RECHECK; + } + if (use_script < 0) { + use_script++; + return (auditwarnsyslog(args)); + } + use_script--; loc_args[0] = AUDITWARN_SCRIPT; for (i = 0; args[i] != NULL && i < 8; i++) loc_args[i+1] = args[i]; @@ -64,7 +100,8 @@ auditwarnlog(char *args[]) execv(AUDITWARN_SCRIPT, loc_args); syslog(LOG_ERR, "Could not exec %s (%m)\n", AUDITWARN_SCRIPT); - exit(1); + (void)auditwarnsyslog(args); + _Exit(1); } /* * Parent. diff --git a/contrib/openbsm/man/audit_warn.5 b/contrib/openbsm/man/audit_warn.5 index 6db1d20334d0..ef58bff818db 100644 --- a/contrib/openbsm/man/audit_warn.5 +++ b/contrib/openbsm/man/audit_warn.5 @@ -47,6 +47,11 @@ Administrators may replace this script: a more comprehensive one would take different actions based on the type of warning. For example, a low-space warning could result in an email message being sent to the administrator. +.Pp +If the script does not exist or is not executable, +.Xr auditd 8 +will log directly to +.Xr syslogd 8 . .Sh FILES .Bl -tag -width "/etc/security/audit_warn" -compact .It Pa /etc/security/audit_warn @@ -54,7 +59,8 @@ could result in an email message being sent to the administrator. .Sh SEE ALSO .Xr logger 1 , .Xr audit 4 , -.Xr auditd 8 +.Xr auditd 8 , +.Xr syslogd 8 .Sh HISTORY The OpenBSM implementation was created by McAfee Research, the security division of McAfee Inc., under contract to Apple Computer Inc.\& in 2004.