diff options
author | gad <gad@FreeBSD.org> | 2004-06-03 23:41:49 +0000 |
---|---|---|
committer | gad <gad@FreeBSD.org> | 2004-06-03 23:41:49 +0000 |
commit | 848f68aacc771e36713004936dd584d0eacaf71c (patch) | |
tree | a2b420bf931c2ef65e104116bb6528eda7e7903a /usr.sbin/newsyslog | |
parent | 7cabd201cef39001c4ecb663b8f57dd1beeb30a5 (diff) | |
download | FreeBSD-src-848f68aacc771e36713004936dd584d0eacaf71c.zip FreeBSD-src-848f68aacc771e36713004936dd584d0eacaf71c.tar.gz |
Add a 'D' flag that can be specified on entries in newsyslog.conf.
If specified, the matching log files will have the NODUMP flag set
on them after they are created.
Submitted by: Sean Eric Fagan
MFC after: 16 days
Diffstat (limited to 'usr.sbin/newsyslog')
-rw-r--r-- | usr.sbin/newsyslog/newsyslog.c | 32 | ||||
-rw-r--r-- | usr.sbin/newsyslog/newsyslog.conf.5 | 10 |
2 files changed, 41 insertions, 1 deletions
diff --git a/usr.sbin/newsyslog/newsyslog.c b/usr.sbin/newsyslog/newsyslog.c index 80ad47c..5112ba5 100644 --- a/usr.sbin/newsyslog/newsyslog.c +++ b/usr.sbin/newsyslog/newsyslog.c @@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$"); #define CE_SIGNALGROUP 0x0080 /* Signal a process-group instead of a single */ /* process when trimming this file. */ #define CE_CREATE 0x0100 /* Create the log file if it does not exist. */ +#define CE_NODUMP 0x0200 /* Set 'nodump' on newly created log file. */ #define MIN_PID 5 /* Don't touch pids lower than this */ #define MAX_PID 99999 /* was lower, see /usr/include/sys/proc.h */ @@ -1137,6 +1138,9 @@ no_trimat: } working->flags |= CE_CREATE; break; + case 'd': + working->flags |= CE_NODUMP; + break; case 'g': working->flags |= CE_GLOB; break; @@ -1379,6 +1383,8 @@ dotrim(const struct conf_entry *ent) if (ent->uid != (uid_t)-1 || ent->gid != (gid_t)-1) printf("\tchown %u:%u %s\n", ent->uid, ent->gid, zfile2); + if (ent->flags & CE_NODUMP) + printf("\tchflags nodump %s\n", zfile2); } else { (void) rename(zfile1, zfile2); if (chmod(zfile2, ent->permissions)) @@ -1386,6 +1392,9 @@ dotrim(const struct conf_entry *ent) if (ent->uid != (uid_t)-1 || ent->gid != (gid_t)-1) if (chown(zfile2, ent->uid, ent->gid)) warn("can't chown %s", zfile2); + if (ent->flags & CE_NODUMP) + if (chflags(zfile2, UF_NODUMP)) + warn("can't chflags %s NODUMP", zfile2); } } @@ -1405,6 +1414,8 @@ dotrim(const struct conf_entry *ent) if (ent->uid != (uid_t)-1 || ent->gid != (gid_t)-1) printf("\tchown %u:%u %s\n", ent->uid, ent->gid, file1); + if (ent->flags & CE_NODUMP) + printf("\tchflags nodump %s\n", file1); } else { if (!(flags & CE_BINARY)) { /* Report the trimming to the old log */ @@ -1416,6 +1427,9 @@ dotrim(const struct conf_entry *ent) if (ent->uid != (uid_t)-1 || ent->gid != (gid_t)-1) if (chown(file1, ent->uid, ent->gid)) warn("can't chown %s", file1); + if (ent->flags & CE_NODUMP) + if (chflags(file1, UF_NODUMP)) + warn("can't chflags %s NODUMP", file1); } } @@ -1506,6 +1520,12 @@ log_trim(const char *logname, const struct conf_entry *log_ent) return (0); } +/* + * XXX - Note that both compress_log and bzcompress_log will lose the + * NODUMP flag if it was set on somelog.0. Fixing that in newsyslog + * (as opposed to fixing gzip/bzip2) will require some restructuring + * of the code. That restructuring is planned for a later update... + */ /* Fork of gzip to compress the old log file */ static void compress_log(char *logname, int dowait) @@ -1786,6 +1806,18 @@ createlog(const struct conf_entry *ent) } } + /* Turn on NODUMP if it was requested in the config-file. */ + if (ent->flags & CE_NODUMP) { + if (noaction) + printf("\tchflags nodump %s\n", tempfile); + else { + failed = fchflags(fd, UF_NODUMP); + if (failed) { + warn("log_trim: fchflags(NODUMP)"); + } + } + } + /* * Note that if the real logfile still exists, and if the call * to rename() fails, then "neither the old file nor the new diff --git a/usr.sbin/newsyslog/newsyslog.conf.5 b/usr.sbin/newsyslog/newsyslog.conf.5 index f86e77f..8a0d306 100644 --- a/usr.sbin/newsyslog/newsyslog.conf.5 +++ b/usr.sbin/newsyslog/newsyslog.conf.5 @@ -21,7 +21,7 @@ .\" the suitability of this software for any purpose. It is .\" provided "as is" without express or implied warranty. .\" -.Dd March 10, 2004 +.Dd June 03, 2004 .Dt NEWSYSLOG.CONF 5 .Os .Sh NAME @@ -279,6 +279,14 @@ indicates that the log file should be created if it does not already exist, and if the .Fl C option was also specified on the command line. +.It Sy D +indicates that +.Xr newsyslog 8 +should set the NODUMP flag when creating a new version of +this log file. +This option would effect how the +.Xr dump 8 +command treats the log file when making a file system backup. .It Sy G indicates that the specified .Ar logfile_name |