summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsobomax <sobomax@FreeBSD.org>2002-12-11 01:19:56 +0000
committersobomax <sobomax@FreeBSD.org>2002-12-11 01:19:56 +0000
commitaaf3d7c459bc6392a36f568d6996785a9870b9d8 (patch)
tree870b63ef70e61483e9bda8e2d78ce04e4efcd4a8
parentec4660a067ebe092f9def3ae9565b8a43187254b (diff)
downloadFreeBSD-src-aaf3d7c459bc6392a36f568d6996785a9870b9d8.zip
FreeBSD-src-aaf3d7c459bc6392a36f568d6996785a9870b9d8.tar.gz
- Allow comments to be placed at the end of configuration line.
Sponsored by: Porta Software Ltd Approved by: re MFC after: 2 weeks
-rw-r--r--usr.sbin/newsyslog/Makefile2
-rw-r--r--usr.sbin/newsyslog/newsyslog.88
-rw-r--r--usr.sbin/newsyslog/newsyslog.c16
3 files changed, 21 insertions, 5 deletions
diff --git a/usr.sbin/newsyslog/Makefile b/usr.sbin/newsyslog/Makefile
index ab06f3a..7312f10 100644
--- a/usr.sbin/newsyslog/Makefile
+++ b/usr.sbin/newsyslog/Makefile
@@ -3,6 +3,6 @@
PROG= newsyslog
MAN= newsyslog.8
-WARNS?= 2
+WARNS?= 4
.include <bsd.prog.mk>
diff --git a/usr.sbin/newsyslog/newsyslog.8 b/usr.sbin/newsyslog/newsyslog.8
index f55986b..03f540b 100644
--- a/usr.sbin/newsyslog/newsyslog.8
+++ b/usr.sbin/newsyslog/newsyslog.8
@@ -79,7 +79,11 @@ that should be handled by
.Nm .
Each line has five mandatory fields and four optional fields, with
whitespace separating each field. Blank lines or lines beginning with
-``#'' are ignored. The fields of the configuration file are as
+``#'' are ignored. If ``#'' is placed in the middle of the line,
+``#'' character and the rest of the line after it is ignored.
+To prevent special meaning, the ``#'' may be escaped with ``\\'',
+in this case preceding ``\\'' is removed and ``#'' treated as ordinary
+character. The fields of the configuration file are as
follows:
.Pp
.Bl -tag -width indent
@@ -297,7 +301,7 @@ to archive all filenames matching this pattern using the same
options.
See
.Xr glob 3
-for details on matching rules.
+for details on syntax and matching rules.
.It Ar path_to_pid_file
This optional field specifies
the file name to read to find the daemon process id. If this
diff --git a/usr.sbin/newsyslog/newsyslog.c b/usr.sbin/newsyslog/newsyslog.c
index e6e89b0..cfc983b 100644
--- a/usr.sbin/newsyslog/newsyslog.c
+++ b/usr.sbin/newsyslog/newsyslog.c
@@ -290,7 +290,7 @@ parse_file(char **files)
{
FILE *f;
char line[BUFSIZ], *parse, *q;
- char *errline, *group;
+ char *cp, *errline, *group;
char **p;
struct conf_entry *first, *working;
struct passwd *pass;
@@ -306,9 +306,21 @@ parse_file(char **files)
if (!f)
err(1, "%s", conf);
while (fgets(line, BUFSIZ, f)) {
- if ((line[0] == '\n') || (line[0] == '#'))
+ if ((line[0] == '\n') || (line[0] == '#') ||
+ (strlen(line) == 0))
continue;
errline = strdup(line);
+ for (cp = line + 1; *cp != '\0'; cp++) {
+ if (*cp != '#')
+ continue;
+ if (*(cp - 1) == '\\') {
+ strcpy(cp - 1, cp);
+ cp--;
+ continue;
+ }
+ *cp = '\0';
+ break;
+ }
q = parse = missing_field(sob(line), errline);
parse = son(line);
OpenPOWER on IntegriCloud