Allow user to specify which logs to rotate
This commit is contained in:
parent
d220443d1c
commit
78ae26252e
@ -28,6 +28,7 @@
|
||||
.Op Fl Fnrv
|
||||
.Op Fl f Ar config_file
|
||||
.Op Fl a Ar directory
|
||||
.Op Ar
|
||||
.Sh DESCRIPTION
|
||||
.Nm Newsyslog
|
||||
is a program that should be scheduled to run periodically by
|
||||
@ -355,6 +356,11 @@ to trim the logs, even if the trim conditions have not been met. This
|
||||
option is useful for diagnosing system problems by providing you with
|
||||
fresh logs that contain only the problems.
|
||||
.El
|
||||
.Pp
|
||||
If additional command line arguments are given,
|
||||
.Nm
|
||||
will only examine log files that match those arguments; otherwise, it
|
||||
will examine all files listed in the configuration file.
|
||||
.Sh FILES
|
||||
.Bl -tag -width /etc/newsyslog.confxxxx -compact
|
||||
.It Pa /etc/newsyslog.conf
|
||||
|
@ -95,7 +95,7 @@ time_t timenow;
|
||||
char hostname[MAXHOSTNAMELEN + 1]; /* hostname */
|
||||
char *daytime; /* timenow in human readable form */
|
||||
|
||||
static struct conf_entry *parse_file();
|
||||
static struct conf_entry *parse_file(char **files);
|
||||
static char *sob(char *p);
|
||||
static char *son(char *p);
|
||||
static char *missing_field(char *p, char *errline);
|
||||
@ -121,7 +121,7 @@ main(int argc, char **argv)
|
||||
PRS(argc, argv);
|
||||
if (needroot && getuid() && geteuid())
|
||||
errx(1, "must have root privs");
|
||||
p = q = parse_file();
|
||||
p = q = parse_file(argv + optind);
|
||||
|
||||
while (p) {
|
||||
do_entry(p);
|
||||
@ -214,7 +214,6 @@ PRS(int argc, char **argv)
|
||||
if ((p = strchr(hostname, '.'))) {
|
||||
*p = '\0';
|
||||
}
|
||||
optind = 1; /* Start options parsing */
|
||||
while ((c = getopt(argc, argv, "nrvFf:a:t:")) != -1)
|
||||
switch (c) {
|
||||
case 'n':
|
||||
@ -253,11 +252,12 @@ usage(void)
|
||||
* process
|
||||
*/
|
||||
static struct conf_entry *
|
||||
parse_file(void)
|
||||
parse_file(char **files)
|
||||
{
|
||||
FILE *f;
|
||||
char line[BUFSIZ], *parse, *q;
|
||||
char *errline, *group;
|
||||
char **p;
|
||||
struct conf_entry *first = NULL;
|
||||
struct conf_entry *working = NULL;
|
||||
struct passwd *pass;
|
||||
@ -274,6 +274,21 @@ parse_file(void)
|
||||
if ((line[0] == '\n') || (line[0] == '#'))
|
||||
continue;
|
||||
errline = strdup(line);
|
||||
|
||||
q = parse = missing_field(sob(line), errline);
|
||||
parse = son(line);
|
||||
if (!*parse)
|
||||
errx(1, "malformed line (missing fields):\n%s", errline);
|
||||
*parse = '\0';
|
||||
|
||||
if (*files) {
|
||||
for (p = files; *p; ++p)
|
||||
if (strcmp(*p, q) == 0)
|
||||
break;
|
||||
if (!*p)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!first) {
|
||||
working = (struct conf_entry *) malloc(sizeof(struct conf_entry));
|
||||
first = working;
|
||||
@ -281,12 +296,6 @@ parse_file(void)
|
||||
working->next = (struct conf_entry *) malloc(sizeof(struct conf_entry));
|
||||
working = working->next;
|
||||
}
|
||||
|
||||
q = parse = missing_field(sob(line), errline);
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user