aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorBrooks Davis <brooks@FreeBSD.org>2005-03-03 15:47:32 +0000
committerBrooks Davis <brooks@FreeBSD.org>2005-03-03 15:47:32 +0000
commitdeea909a70e040b745672af101705a8a5d707074 (patch)
tree71480dc3dd0e32e6a639b7886e158dd2648b4e88 /usr.sbin
parent573d78add60b77cf8a8ad82c30923b2f1a171fa3 (diff)
downloadsrc-deea909a70e040b745672af101705a8a5d707074.tar.gz
src-deea909a70e040b745672af101705a8a5d707074.zip
Add the -N option to not rotate any files. This is to be used in
cojunction with -C and is used by /etc/rc.d/newsyslog. I forgot that this was in my perforce tree and not my running system and thus committed a non-working newsyslog script. Reported by: des Pointy hat: brooks
Notes
Notes: svn path=/head/; revision=143106
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/newsyslog/newsyslog.89
-rw-r--r--usr.sbin/newsyslog/newsyslog.c16
2 files changed, 21 insertions, 4 deletions
diff --git a/usr.sbin/newsyslog/newsyslog.8 b/usr.sbin/newsyslog/newsyslog.8
index e5ebb8a4e441..09fbe44fe7c1 100644
--- a/usr.sbin/newsyslog/newsyslog.8
+++ b/usr.sbin/newsyslog/newsyslog.8
@@ -25,7 +25,7 @@
.Nd maintain system log files to manageable sizes
.Sh SYNOPSIS
.Nm
-.Op Fl CFnrsv
+.Op Fl CFNnrsv
.Op Fl R Ar tagname
.Op Fl a Ar directory
.Op Fl d Ar directory
@@ -162,6 +162,13 @@ 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.
+.It Fl N
+Do not perform any rotations.
+This option is intended to be used with the
+.Fl C
+or
+.Fl CC
+options when creating log files is the only objective.
.It Fl R Ar tagname
Specify that
.Nm
diff --git a/usr.sbin/newsyslog/newsyslog.c b/usr.sbin/newsyslog/newsyslog.c
index 9967e888d203..7b3a3aac8deb 100644
--- a/usr.sbin/newsyslog/newsyslog.c
+++ b/usr.sbin/newsyslog/newsyslog.c
@@ -179,6 +179,7 @@ int createlogs; /* Create (non-GLOB) logfiles which do not */
int verbose = 0; /* Print out what's going on */
int needroot = 1; /* Root privs are necessary */
int noaction = 0; /* Don't do anything, just show it */
+int norotate = 0; /* Don't rotate */
int nosignal; /* Do not send any signals */
int force = 0; /* Force the trim no matter what */
int rotatereq = 0; /* -R = Always rotate the file(s) as given */
@@ -557,7 +558,7 @@ do_entry(struct conf_entry * ent)
/*
* If the file needs to be rotated, then rotate it.
*/
- if (ent->rotate) {
+ if (ent->rotate && !norotate) {
if (temp_reason[0] != '\0')
ent->r_reason = strdup(temp_reason);
if (verbose)
@@ -698,7 +699,7 @@ parse_args(int argc, char **argv)
*p = '\0';
/* Parse command line options. */
- while ((ch = getopt(argc, argv, "a:d:f:nrsvCD:FR:")) != -1)
+ while ((ch = getopt(argc, argv, "a:d:f:nrsvCD:FNR:")) != -1)
switch (ch) {
case 'a':
archtodir++;
@@ -739,6 +740,9 @@ parse_args(int argc, char **argv)
case 'F':
force++;
break;
+ case 'N':
+ norotate++;
+ break;
case 'R':
rotatereq++;
requestor = strdup(optarg);
@@ -749,6 +753,12 @@ parse_args(int argc, char **argv)
/* NOTREACHED */
}
+ if (force && norotate) {
+ warnx("Only one of -F and -N may be specified.");
+ usage();
+ /* NOTREACHED */
+ }
+
if (rotatereq) {
if (optind == argc) {
warnx("At least one filename must be given when -R is specified.");
@@ -838,7 +848,7 @@ usage(void)
{
fprintf(stderr,
- "usage: newsyslog [-CFnrsv] [-a directory] [-d directory] [-f config-file]\n"
+ "usage: newsyslog [-CFNnrsv] [-a directory] [-d directory] [-f config-file]\n"
" [ [-R requestor] filename ... ]\n");
exit(1);
}