summaryrefslogtreecommitdiffstats
path: root/usr.sbin/newsyslog
diff options
context:
space:
mode:
authorbrooks <brooks@FreeBSD.org>2004-10-04 23:35:13 +0000
committerbrooks <brooks@FreeBSD.org>2004-10-04 23:35:13 +0000
commita8b1fd9efbf31e6a704f5f931cf33e9a689d5aac (patch)
treeeacf3e11ab25063362e07b937fe3812451204703 /usr.sbin/newsyslog
parentc5171b8fc89e8a2d43edcab9bb42370226906d1e (diff)
downloadFreeBSD-src-a8b1fd9efbf31e6a704f5f931cf33e9a689d5aac.zip
FreeBSD-src-a8b1fd9efbf31e6a704f5f931cf33e9a689d5aac.tar.gz
Add a new -d argument which is used to specify an alternate root for log
files similar to DESTDIR in the BSD make process. This only affects log file paths not config file (-f) or archive directory (-a) paths.
Diffstat (limited to 'usr.sbin/newsyslog')
-rw-r--r--usr.sbin/newsyslog/newsyslog.810
-rw-r--r--usr.sbin/newsyslog/newsyslog.c11
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;
OpenPOWER on IntegriCloud