summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2002-09-19 21:23:00 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2002-09-19 21:23:00 +0000
commite0688feae642c37e462cd82c52eec49fab7929f6 (patch)
tree9baa142b57c926ba591aa8bb24536c2d9d879724
parent67df4e1cf238bf15030f0a16d718b580a80b8ee2 (diff)
Deal with someone specifying an empty string for the command to run
and make it mean "send no signal and run no command".
-rw-r--r--usr.bin/newsyslog/newsyslog.87
-rw-r--r--usr.bin/newsyslog/newsyslog.c22
2 files changed, 19 insertions, 10 deletions
diff --git a/usr.bin/newsyslog/newsyslog.8 b/usr.bin/newsyslog/newsyslog.8
index 46a4226af2c..4a1a5c17f09 100644
--- a/usr.bin/newsyslog/newsyslog.8
+++ b/usr.bin/newsyslog/newsyslog.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: newsyslog.8,v 1.28 2002/09/17 20:44:38 millert Exp $
+.\" $OpenBSD: newsyslog.8,v 1.29 2002/09/19 21:22:59 millert Exp $
.\"
.\" Copyright (c) 1997, Jason Downs. All rights reserved.
.\"
@@ -266,6 +266,11 @@ and be the signal name, not the number, e.g.,
Specify a command to run instead of sending a signal to the process.
The command must be enclosed in double quotes
.Pq Ql \&" ) .
+The empty string,
+.Ql \&"\&" ,
+can use used to prevent
+.Nm
+from sending a signal or running a command.
You cannot specify both a command and a PID file.
.Em NOTE:
If you specify a command to be run,
diff --git a/usr.bin/newsyslog/newsyslog.c b/usr.bin/newsyslog/newsyslog.c
index 5dca3e45b34..2caf3d604fd 100644
--- a/usr.bin/newsyslog/newsyslog.c
+++ b/usr.bin/newsyslog/newsyslog.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: newsyslog.c,v 1.55 2002/09/19 20:58:50 millert Exp $ */
+/* $OpenBSD: newsyslog.c,v 1.56 2002/09/19 21:22:59 millert Exp $ */
/*
* Copyright (c) 1999, 2002 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -86,7 +86,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: newsyslog.c,v 1.55 2002/09/19 20:58:50 millert Exp $";
+static const char rcsid[] = "$OpenBSD: newsyslog.c,v 1.56 2002/09/19 21:22:59 millert Exp $";
#endif /* not lint */
#ifndef CONF
@@ -271,10 +271,12 @@ main(int argc, char **argv)
/* Step 3, send a signal or run a command */
for (pl = pidlist; pl->file; pl++) {
- if (pl->signal == -1)
- run_command(pl->file);
- else
- send_signal(pl->file, pl->signal);
+ if (pl->file != NULL) {
+ if (pl->signal == -1)
+ run_command(pl->file);
+ else
+ send_signal(pl->file, pl->signal);
+ }
}
if (!noaction)
sleep(5);
@@ -618,9 +620,11 @@ parse_file(int *nentries)
err(1, "strdup");
} else if (*q == '"' && (tmp = strchr(q + 1, '"'))) {
*(parse = tmp) = '\0';
- working->runcmd = strdup(++q);
- if (working->runcmd == NULL)
- err(1, "strdup");
+ if (*++q != '\0') {
+ working->runcmd = strdup(q);
+ if (working->runcmd == NULL)
+ err(1, "strdup");
+ }
working->pidfile = NULL;
working->signal = -1;
} else if (strncmp(q, "SIG", 3) == 0) {