From nobody Thu Nov 05 15:12:20 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 4jL5QF4Yc1z709wB for ; Thu, 05 Nov 2026 15:12:21 +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 4jL5QF1q7Zz4Brt for ; Thu, 05 Nov 2026 15:12:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793891541; 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=auQfhzLklhdHYAPFdalt9Aq9bg8uE+pY0KeecGQkwBI=; b=mNT+rqPk+eHd/iS90MhK8jjGdAOq42FX34nrht4S3CMdL2jHzB/LZIfa2uI7A7Kj9JMqJz aKD8apajXT2ZI6y8h63W7wjX/lbV8gdmKE5tM6xrzlH40UhSHFYkE7UgnKX06ZKBqVxZ07 lKk16nuF9ALdLNawatHfmoD01XGXIVC+oRF3R+L4+fqmJb36QFnHi9LLv+Sl/7IzmDpurh OitF/rv2edvB3i3xlZD4HcWct4Po7z3wxsbvPBUIbxmxKKmudJIMIUDxW706xhPr4UJYi3 hpqZ2cSq+0QsKDyNeYzV9GXV1snQgQYqEKpaI5rFTD6VMzq6pvXnixp4c4yy3w== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793891541; b=UT+eclJZ1bAsmgLtHikJxnmbPX5uC249AkFlhgpwBA09V1f62iK8J3RhiQ/lvfaXKU0S+U RZIV1abxu6nXhFf/Ar4gzsRlcB8L/kMkEX2MecB0V01gRB5nd4BSh2bLXBt7Zc3Wnumbvx Kfrx1GUFb4YVdarJQ5qX+IO/pfNQiRWU3cMDNpH3YR2mjrk0Er3KgLvn5OhHOm/4kLyRrR jsQKIU0LKYPyWaC4ivbaTevbvSaRcIiJ6rGqmywTgi61NjnZl1DvUt+lc85J3oDM//fg7J 1aNFR3Vh5I+kyCLtUOj18vvJJeY4T5sxfeiDjtlIuu0HO6YmJTApLLLQmR8Qsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793891541; 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=auQfhzLklhdHYAPFdalt9Aq9bg8uE+pY0KeecGQkwBI=; b=Q0WZvU0xlflN9g3Mr2VxBZpXRmz66H7pW52mLhbbmpBQ1xANGjyWMLjt1ylMszGvMpbt7N slJBaXMYYgjeVV+3At+7X1gTF79aU4NImjOP+P8PLfdr0t83Y1GbvzUo3fOtePtG8KbU/e NE1F701ZtpX6+kNoOq7a+ugfzunyoqJ+LPudHVFpD51yuKsfv/5cE0o7NICM2e+wns80Ta O0JJX2BwGlqBbuLIE7+TgZKZvR2IUIysKgVJaS91+IWgK5HPO0aKIa6m3bGr9HE6U0btfM opzSq5iJ//f8DXOr0ERXnjzZldLM3Y+rqpfRlGE8Z2zzvxC7g5+7D/hJ0iS0Ew== 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 4jL5QD73TZzwBD for ; Thu, 05 Nov 2026 15:12:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 24c9b by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 05 Nov 2026 15:12:20 +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: a1e5a9af6390 - stable/15 - 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/15 X-Git-Reftype: branch X-Git-Commit: a1e5a9af6390f3a1d901155095264aeb1bae7382 Auto-Submitted: auto-generated Date: Thu, 05 Nov 2026 15:12:20 +0000 Message-Id: <6aec9cd4.24c9b.2518e15f@gitrepo.freebsd.org> The branch stable/15 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=a1e5a9af6390f3a1d901155095264aeb1bae7382 commit a1e5a9af6390f3a1d901155095264aeb1bae7382 Author: Dag-Erling Smørgrav AuthorDate: 2026-11-04 15:32:33 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-11-05 15:11:53 +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.