diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/newsyslog/newsyslog.8 | 10 | ||||
-rw-r--r-- | usr.sbin/newsyslog/newsyslog.c | 11 |
2 files changed, 19 insertions, 2 deletions
diff --git a/usr.sbin/newsyslog/newsyslog.8 b/usr.sbin/newsyslog/newsyslog.8 index 5899d7e..3f31320 100644 --- a/usr.sbin/newsyslog/newsyslog.8 +++ b/usr.sbin/newsyslog/newsyslog.8 @@ -28,6 +28,7 @@ .Op Fl CFnrsv .Op Fl R Ar tagname .Op Fl a Ar directory +.Op Fl d Ar directory .Op Fl f Ar config_file .Op Ar .Sh DESCRIPTION @@ -99,6 +100,15 @@ does not exist, it will be created when .Nm is run. +.It Fl d Ar directory +Specify a +.Ar directory +which all log files will be relative to. +To allow archiving of logs outside the root, the +.Ar directory +passed to the +.Fl a +option is unaffected. .It Fl v Place .Nm diff --git a/usr.sbin/newsyslog/newsyslog.c b/usr.sbin/newsyslog/newsyslog.c index 0a28c3f..590dbf6 100644 --- a/usr.sbin/newsyslog/newsyslog.c +++ b/usr.sbin/newsyslog/newsyslog.c @@ -187,6 +187,7 @@ int rotatereq = 0; /* -R = Always rotate the file(s) as given */ /* the run command). */ char *requestor; /* The name given on a -R request */ char *archdirname; /* Directory path to old logfiles archive */ +char *destdir = NULL; /* Directory to treat at root for logs */ const char *conf; /* Configuration file to use */ struct ptime_data *dbg_timenow; /* A "timenow" value set via -D option */ @@ -339,7 +340,10 @@ init_entry(const char *fname, struct conf_entry *src_entry) if (tempwork == NULL) err(1, "malloc of conf_entry for %s", fname); - tempwork->log = strdup(fname); + if (destdir == NULL) + tempwork->log = strdup(fname); + else + asprintf(&tempwork->log, "%s%s", destdir, fname); if (tempwork->log == NULL) err(1, "strdup for %s", fname); @@ -694,12 +698,15 @@ parse_args(int argc, char **argv) *p = '\0'; /* Parse command line options. */ - while ((ch = getopt(argc, argv, "a:f:nrsvCD:FR:")) != -1) + while ((ch = getopt(argc, argv, "a:d:f:nrsvCD:FR:")) != -1) switch (ch) { case 'a': archtodir++; archdirname = optarg; break; + case 'd': + destdir = optarg; + break; case 'f': conf = optarg; break; |