From nobody Wed Nov 04 15:33:59 2026 X-Original-To: dev-commits-src-main@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 4jKTxg3CBKz6y4J4 for ; Wed, 04 Nov 2026 15:33:59 +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 4jKTxg1nz2z4dw2 for ; Wed, 04 Nov 2026 15:33:59 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793806439; 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=YfaaSWBX6WrWMlOtpEenLtEdIcseTqbPAWg/MwIVsbc=; b=RHxNte9jTW9SiZx6vl+KDzlX6uvV1L50bt+86fOr9Nnew9SyZg4LEAazMq0nc99HH0EYDC 6z4MdH70OE+ToRbAXFqXPpy0lu7r9mfKvMc1YNe6ei4lVk+UGph1/PCLSXG8+5NH4D0+Pc yRaWe8hYILHiDmZcc4wucaALOuprRxzvGWfjYS8v6Zl9xc7wvbVOMXUZBiVf5wFcyM13/U TrX8pg7TkgXW77f3jxGhyFCGVe7NZq6ZQCUlNEWAf9t585ptqRZNAwVme3z7QO6y0JOUae zSpABllWatJGMcjTBVzcPNvGRlCIGgu/3ohiaz4Fx0MrJxmxylR5m6WSJPTNwg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1793806439; b=EkwN2IhbUhBF/fhoFuW0Jb9bvH+HDvnMiZ1l4qGJRCFEDcEUwgQc+ZlKFnLoX3ZKmJoLjq JF390oW3EkIJbjGHc54Ni7RA3x9w68SFEVhj3sUam91kSMTYZfAob3c+EJCcN1ioZs8I8b vcVjYR/tKfADe9CKQScq432tqygFbt1DHk3iZUrqGFIltSuuWpwu6thQ1MLrzmaL7Utm5N M20D5Wu6MUlX7D0V24MDw3WIJY9DFu07DTu30iPz96VsdM0GIjQBucORHcwhNqTM6vGSgX EVDqvhOTaCQw/lNkExBwokoL/qWlzcIhY9GfneB8MlfD24HbSu9YCh3OmSYPBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1793806439; 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=YfaaSWBX6WrWMlOtpEenLtEdIcseTqbPAWg/MwIVsbc=; b=rYzGr/8VNZayO6Lgf6jMPl3fHUOJcQD7Btsw6LHxaxhueHGgPoGjecBdKihXxml6fTB7TJ DEQqNzec1SPRGllVFp6h9hhmNx401Qk5jMag15w5RrNhRZw+2UESWPA+iUtJlp+mXwpdKr eRfrTUjx5nVBsqd2VVFsF7TDA6LyBBoficEvvfgea1NK7EHnKeS5sxMbwYnuzpG5lHcFzb hhtSf3lsSoegN1HCKf4y4xxsPYlFb+PHRuubxSpsil04RRua5RWr/TB0OJx7kaCPQ5irnz Dg6v2kpj7HbPKi+PTMZXpEYMyNzto4jV5Ag6iC+yfVlL/UttuDWdObxDS6wp1Q== 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 4jKTxg1QLlz17n0 for ; Wed, 04 Nov 2026 15:33:59 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 192a6 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 04 Nov 2026 15:33:59 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav Subject: git: b18489dd6098 - main - auditd: Support logging directly to syslog List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org List-Id: Commit messages for the main branch 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/main X-Git-Reftype: branch X-Git-Commit: b18489dd60980e51093f196299eb8c38b12daa20 Auto-Submitted: auto-generated Date: Wed, 04 Nov 2026 15:33:59 +0000 Message-Id: <6aeb5067.192a6.26de87e7@gitrepo.freebsd.org> The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=b18489dd60980e51093f196299eb8c38b12daa20 commit b18489dd60980e51093f196299eb8c38b12daa20 Author: Dag-Erling Smørgrav AuthorDate: 2026-11-04 15:32:33 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2026-11-04 15:32:33 +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 --- 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.