Allow a '-' flag as a placeholder so that path_to_pid_file
can be specified without the flags field. Fix bogus "trail" left in parse routine where the code jumps past the end of the line and wanders into oblivion.
This commit is contained in:
parent
f258030f39
commit
ea3b35174b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=25518
@ -1,7 +1,7 @@
|
||||
.\" This file contains changes from the Open Software Foundation.
|
||||
.\"
|
||||
.\" from: @(#)newsyslog.8
|
||||
.\" $Id: newsyslog.8,v 1.5 1997/02/28 07:33:37 mpp Exp $
|
||||
.\" $Id: newsyslog.8,v 1.6 1997/05/04 01:53:53 ache Exp $
|
||||
.\"
|
||||
.\" Copyright 1988, 1989 by the Massachusetts Institute of Technology
|
||||
.\"
|
||||
@ -112,7 +112,11 @@ flag means that the file is a binary file, and so the ASCII
|
||||
message which
|
||||
.Nm
|
||||
inserts to indicate the fact that the logs have been
|
||||
turned over should not be included.
|
||||
turned over should not be included. The
|
||||
.Ar -
|
||||
flag means nothing, but can be used as a placeholder when the
|
||||
.Ar path_to_pid_file
|
||||
field is specified.
|
||||
.It Ar path_to_pid_file
|
||||
This optional field specifies
|
||||
the file name to read to find the daemon process id. If this
|
||||
|
@ -29,7 +29,7 @@ provided "as is" without express or implied warranty.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static char rcsid[] = "$Id: newsyslog.c,v 1.11 1997/05/04 01:53:53 ache Exp $";
|
||||
static char rcsid[] = "$Id: newsyslog.c,v 1.12 1997/05/05 15:00:15 ache Exp $";
|
||||
#endif /* not lint */
|
||||
|
||||
#ifndef CONF
|
||||
@ -245,6 +245,7 @@ static struct conf_entry *parse_file()
|
||||
struct conf_entry *working = NULL;
|
||||
struct passwd *pass;
|
||||
struct group *grp;
|
||||
int eol;
|
||||
|
||||
if (strcmp(conf,"-"))
|
||||
f = fopen(conf,"r");
|
||||
@ -265,11 +266,17 @@ static struct conf_entry *parse_file()
|
||||
}
|
||||
|
||||
q = parse = missing_field(sob(line),errline);
|
||||
*(parse = son(line)) = '\0';
|
||||
parse = son(line);
|
||||
if (!*parse)
|
||||
errx(1, "Malformed line (missing fields):\n%s", errline);
|
||||
*parse = '\0';
|
||||
working->log = strdup(q);
|
||||
|
||||
q = parse = missing_field(sob(++parse),errline);
|
||||
*(parse = son(parse)) = '\0';
|
||||
parse = son(parse);
|
||||
if (!*parse)
|
||||
errx(1, "Malformed line (missing fields):\n%s", errline);
|
||||
*parse = '\0';
|
||||
if ((group = strchr(q, '.')) != NULL) {
|
||||
*group++ = '\0';
|
||||
if (*q) {
|
||||
@ -298,7 +305,10 @@ static struct conf_entry *parse_file()
|
||||
working->gid = NONE;
|
||||
|
||||
q = parse = missing_field(sob(++parse),errline);
|
||||
*(parse = son(parse)) = '\0';
|
||||
parse = son(parse);
|
||||
if (!*parse)
|
||||
errx(1, "Malformed line (missing fields):\n%s", errline);
|
||||
*parse = '\0';
|
||||
}
|
||||
else
|
||||
working->uid = working->gid = NONE;
|
||||
@ -308,27 +318,42 @@ static struct conf_entry *parse_file()
|
||||
errline);
|
||||
|
||||
q = parse = missing_field(sob(++parse),errline);
|
||||
*(parse = son(parse)) = '\0';
|
||||
parse = son(parse);
|
||||
if (!*parse)
|
||||
errx(1, "Malformed line (missing fields):\n%s", errline);
|
||||
*parse = '\0';
|
||||
if (!sscanf(q,"%d",&working->numlogs))
|
||||
errx(1, "Error in config file; bad number:\n%s",
|
||||
errline);
|
||||
|
||||
q = parse = missing_field(sob(++parse),errline);
|
||||
*(parse = son(parse)) = '\0';
|
||||
parse = son(parse);
|
||||
if (!*parse)
|
||||
errx(1, "Malformed line (missing fields):\n%s", errline);
|
||||
*parse = '\0';
|
||||
if (isdigit(*q))
|
||||
working->size = atoi(q);
|
||||
else
|
||||
working->size = -1;
|
||||
|
||||
q = parse = missing_field(sob(++parse),errline);
|
||||
*(parse = son(parse)) = '\0';
|
||||
parse = son(parse);
|
||||
eol = !*parse;
|
||||
*parse = '\0';
|
||||
if (isdigit(*q))
|
||||
working->hours = atoi(q);
|
||||
else
|
||||
working->hours = -1;
|
||||
|
||||
q = parse = sob(++parse); /* Optional field */
|
||||
*(parse = son(parse)) = '\0';
|
||||
if (eol)
|
||||
q = NULL;
|
||||
else {
|
||||
q = parse = sob(++parse); /* Optional field */
|
||||
parse = son(parse);
|
||||
if (!*parse)
|
||||
eol = 1;
|
||||
*parse = '\0';
|
||||
}
|
||||
|
||||
working->flags = 0;
|
||||
while (q && *q && !isspace(*q)) {
|
||||
@ -336,13 +361,17 @@ static struct conf_entry *parse_file()
|
||||
working->flags |= CE_COMPACT;
|
||||
else if ((*q == 'B') || (*q == 'b'))
|
||||
working->flags |= CE_BINARY;
|
||||
else
|
||||
else if (*q != '-')
|
||||
errx(1, "Illegal flag in config file -- %c", *q);
|
||||
q++;
|
||||
}
|
||||
|
||||
q = parse = sob(++parse); /* Optional field */
|
||||
*(parse = son(parse)) = '\0';
|
||||
if (eol)
|
||||
q = NULL;
|
||||
else {
|
||||
q = parse = sob(++parse); /* Optional field */
|
||||
*(parse = son(parse)) = '\0';
|
||||
}
|
||||
|
||||
working->pid_file = NULL;
|
||||
if (q && *q) {
|
||||
|
Loading…
Reference in New Issue
Block a user