From nobody Sun Sep 28 14:55:10 2025 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 4cZS6Q37Plz68pkh; Sun, 28 Sep 2025 14:55:10 +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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cZS6Q1Tdrz3nNt; Sun, 28 Sep 2025 14:55:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1759071310; 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=/7zVM168DuDlOLzycOu5NfmC9wuLWbspLVwrlqOQHjk=; b=qVThbNl7jxcY3Dx0BSwTjD/Y7rlRtsje/6SUKJR9PZNcmK9JaprXY+gtX1D1S4uYIg61o2 cNIeIhSgCPquS22nrvj/b4FxClbDVB5qEVftp86hYy/vZ0+9uURWp3Pr8KH2flZKbaTURT XCcdyM7nJQuiVykQeIeX5YggoXlBpfb4PJQZIYFs6DpIpVQhmwVcFkgaHmUqefThqPWcqq LoJ2zqXAOULhQ8HDMTnx0eAWPHkExfGAhXvOvRDGihE6b9frvXex/VDpNOvegxUcrIpJ16 CDSJl3v6pPjOTmv8PcFGsTfWdqZ5IE7fuwBsRKBW4ja7AV8A1YWbi/nkMgoWrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1759071310; 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=/7zVM168DuDlOLzycOu5NfmC9wuLWbspLVwrlqOQHjk=; b=LOPAksLk3YriTUouH97iFvMtwZVPksHQkkKkrnNYsvrQE96UMzCeVn22g2z3qn+4ASk0IY jZp0MHaISxqtTE3qEsN8noMw7mQIS6eTGM+XdD+cbfzU+JWA2nBH8dybHxJwV2cbOCVqS2 wAswr2rdB6yC9hs+Y81O3O2vnHTQF4/XtTyMlTCL+/ZCB6Y1RdOr3aqeTSwt73NvWM9m8d EMXWoVTw6D3nOJWcheDy5F665ojBdqq/t3/JaXwEEOxBK+0nD7r2s7KvfAZ72p2SKihGMm ksdDAbNwQd2oVlUXeqF+hIC88OE1iKAvx6Bb3xxuTuVe5Tfbxx6kS1LX7m35TQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1759071310; a=rsa-sha256; cv=none; b=BN16O63MvSdN752RZbt6Omm0JlmbnBhl/VnROTOrQLHNmGpzfC/bvkG//5KOzKxHwdj4vJ yv2vwMzrRdHz1ECdEgvhLzzzAJC05WMtCn1jVhRsdwdmw34lNC47vrWoowcgWVz/WOD8xe UE3U0pm6BLVWUCRymIkgBxi/4fNIxRFe9NZ2jvhTlYtIUHW3CksjLgAq/kWFIQVUjkYXJh YSqhr4w3gX/XFhIp4eBpu4J5ROW8hf9E8we5V7CzBCB0V/z52paGnOhuOAnJdsAAYyIEYP n7mdRo6NpIgdjxqAJO/Td5mIfZ+GYK8w1yddrQULisn8qFpPk76BekADPKNAUg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4cZS6Q0tGgz8WW; Sun, 28 Sep 2025 14:55:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 58SEtA1Y045175; Sun, 28 Sep 2025 14:55:10 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 58SEtA9w045172; Sun, 28 Sep 2025 14:55:10 GMT (envelope-from git) Date: Sun, 28 Sep 2025 14:55:10 GMT Message-Id: <202509281455.58SEtA9w045172@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 81df9522c8b7 - main - newsyslog: provide -I option to specify default signal List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 81df9522c8b720016db671c9476fa449bd94e6da Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=81df9522c8b720016db671c9476fa449bd94e6da commit 81df9522c8b720016db671c9476fa449bd94e6da Author: Gleb Smirnoff AuthorDate: 2025-09-28 14:54:33 +0000 Commit: Gleb Smirnoff CommitDate: 2025-09-28 14:54:33 +0000 newsyslog: provide -I option to specify default signal Useful when used with syslog-ng, which uses SIGUSR1. Instead of adding signal number to every new entry, just set it via command line option. Reviewed by: bcr, delphij Differential Revision: https://reviews.freebsd.org/D52701 --- usr.sbin/newsyslog/newsyslog.8 | 9 +++++++-- usr.sbin/newsyslog/newsyslog.c | 13 +++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/usr.sbin/newsyslog/newsyslog.8 b/usr.sbin/newsyslog/newsyslog.8 index 7429e3b8eb01..aa89ef4b779a 100644 --- a/usr.sbin/newsyslog/newsyslog.8 +++ b/usr.sbin/newsyslog/newsyslog.8 @@ -14,7 +14,7 @@ .\" the suitability of this software for any purpose. It is .\" provided "as is" without express or implied warranty. .\" -.Dd September 1, 2025 +.Dd September 22, 2025 .Dt NEWSYSLOG 8 .Os .Sh NAME @@ -26,6 +26,7 @@ .Op Fl a Ar directory .Op Fl d Ar directory .Op Fl f Ar config_file +.Op Fl I Ar signal .Op Fl S Ar pidfile .Op Fl t Ar timefmt .Op Oo Fl R Ar tagname Oc Ar @@ -132,7 +133,7 @@ Remove the restriction that must be running as root. Of course, .Nm -will not be able to send a HUP signal to +will not be able to send a signal to .Xr syslogd 8 so this option should only be used in debugging. .It Fl s @@ -247,6 +248,10 @@ Skipping the signal step will also mean that will return faster, since .Nm normally waits a few seconds after any signal that is sent. +.It Fl I Ar signal +Specify signal to send for entries that do not have signal configured. +This option accepts either a signal number or a name as argument. +The default value is HUP. .It Fl S Ar pidfile Use .Ar pidfile diff --git a/usr.sbin/newsyslog/newsyslog.c b/usr.sbin/newsyslog/newsyslog.c index e24e2db1155d..90b9c8d716a5 100644 --- a/usr.sbin/newsyslog/newsyslog.c +++ b/usr.sbin/newsyslog/newsyslog.c @@ -241,6 +241,7 @@ static int norotate = 0; /* Don't rotate */ static int nosignal; /* Do not send any signals */ static int enforcepid = 0; /* If PID file does not exist or empty, do nothing */ static int force = 0; /* Force the trim no matter what */ +static int defsignal = SIGHUP; /* -I Signal to send by default */ static int rotatereq = 0; /* -R = Always rotate the file(s) as given */ /* on the command (this also requires */ /* that a list of files *are* given on */ @@ -455,7 +456,7 @@ init_entry(const char *fname, struct conf_entry *src_entry) tempwork->permissions = 0; tempwork->flags = 0; tempwork->compress = COMPRESS_NONE; - tempwork->sig = SIGHUP; + tempwork->sig = defsignal; tempwork->def_cfg = 0; } @@ -700,7 +701,7 @@ parse_args(int argc, char **argv) hostname_shortlen = strcspn(hostname, "."); /* Parse command line options. */ - while ((ch = getopt(argc, argv, "a:d:f:nrst:vCD:FNPR:S:")) != -1) + while ((ch = getopt(argc, argv, "a:d:f:nrst:vCD:FI:NPR:S:")) != -1) switch (ch) { case 'a': archtodir++; @@ -748,6 +749,10 @@ parse_args(int argc, char **argv) case 'F': force++; break; + case 'I': + if (str2sig(optarg, &defsignal) != 0) + usage(); + break; case 'N': norotate++; break; @@ -846,7 +851,7 @@ usage(void) fprintf(stderr, "usage: newsyslog [-CFNPnrsv] [-a directory] [-d directory] [-f config_file]\n" - " [-S pidfile] [-t timefmt] [[-R tagname] file ...]\n"); + " [-I signal] [-S pidfile] [-t timefmt] [[-R tagname] file ...]\n"); exit(1); } @@ -1481,7 +1486,7 @@ no_trimat: *parse = '\0'; } - working->sig = SIGHUP; + working->sig = defsignal; if (q && *q) { got_sig: if (str2sig(q, &working->sig) != 0) {