The branch main has been updated by glebius:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=81df9522c8b720016db671c9476fa449bd94e6da

commit 81df9522c8b720016db671c9476fa449bd94e6da
Author:     Gleb Smirnoff <[email protected]>
AuthorDate: 2025-09-28 14:54:33 +0000
Commit:     Gleb Smirnoff <[email protected]>
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) {

Reply via email to