summaryrefslogtreecommitdiffstats
path: root/usr.sbin/newsyslog
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2000-05-11 10:17:54 +0000
committerdes <des@FreeBSD.org>2000-05-11 10:17:54 +0000
commit7d6740ec11e74d97fb52354e28552590cf2dc4ad (patch)
treee18c7df6b4f7d5327d47f4a6fe17233c38e1eebf /usr.sbin/newsyslog
parent67f6623fc7342a23cc66a332c5ae42b6f52ee3df (diff)
downloadFreeBSD-src-7d6740ec11e74d97fb52354e28552590cf2dc4ad.zip
FreeBSD-src-7d6740ec11e74d97fb52354e28552590cf2dc4ad.tar.gz
Allow user to specify which logs to rotate
Diffstat (limited to 'usr.sbin/newsyslog')
-rw-r--r--usr.sbin/newsyslog/newsyslog.86
-rw-r--r--usr.sbin/newsyslog/newsyslog.c29
2 files changed, 25 insertions, 10 deletions
diff --git a/usr.sbin/newsyslog/newsyslog.8 b/usr.sbin/newsyslog/newsyslog.8
index de25407..7601b5e 100644
--- a/usr.sbin/newsyslog/newsyslog.8
+++ b/usr.sbin/newsyslog/newsyslog.8
@@ -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
diff --git a/usr.sbin/newsyslog/newsyslog.c b/usr.sbin/newsyslog/newsyslog.c
index 7334728..34dbc87 100644
--- a/usr.sbin/newsyslog/newsyslog.c
+++ b/usr.sbin/newsyslog/newsyslog.c
@@ -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);
OpenPOWER on IntegriCloud