Add a new newsyslog.conf flag - 'G', which if set tells newsyslog(8) that

the specified filename of the log to be rotated is in fact shell glob
pattern. In this case, all files matching this pattern will be rotated
using the same options. Useful in the case when there is no pre-defined
name for the logfiles (e.g. xtradius, samba etc).

Sponsored by:	PortaOne Software Ltd
MFC after:	2 weeks
This commit is contained in:
Maxim Sobolev 2002-11-14 08:43:07 +00:00
parent 122dd01309
commit 2e01a2be1e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=106905
2 changed files with 29 additions and 1 deletions

View File

@ -288,6 +288,16 @@ turned over should not be included. The
flag means nothing, but can be used as a placeholder when the
.Ar path_to_pid_file
field is specified.
.Ar G
flag means that the specified
.Ar logfile_name
is a shell pattern, which instructs the
.Nm
to archive all filenames matchins this pattern using the same
options.
See
.Xr glob 3
for details on matching rules.
.It Ar path_to_pid_file
This optional field specifies
the file name to read to find the daemon process id. If this

View File

@ -44,6 +44,7 @@ static const char rcsid[] =
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <glob.h>
#include <grp.h>
#include <paths.h>
#include <pwd.h>
@ -68,6 +69,7 @@ static const char rcsid[] =
#define CE_BZCOMPACT 8 /* Compact the achived log files with bzip2 */
/* status messages */
#define CE_TRIMAT 4 /* trim at a specific time */
#define CE_GLOB 16 /* name of the log is file name pattern */
#define NONE -1
@ -125,6 +127,8 @@ int
main(int argc, char **argv)
{
struct conf_entry *p, *q;
glob_t pglob;
int i;
PRS(argc, argv);
if (needroot && getuid() && geteuid())
@ -132,7 +136,19 @@ main(int argc, char **argv)
p = q = parse_file(argv + optind);
while (p) {
do_entry(p);
if ((p->flags & CE_GLOB) == 0) {
do_entry(p);
} else {
if (glob(p->log, GLOB_NOCHECK, NULL, &pglob) != 0) {
warn("can't expand pattern: %s", p->log);
} else {
for (i = 0; i < pglob.gl_matchc; i++) {
p->log = pglob.gl_pathv[i];
do_entry(p);
}
globfree(&pglob);
}
}
p = p->next;
free((char *) q);
q = p;
@ -443,6 +459,8 @@ parse_file(char **files)
working->flags |= CE_BZCOMPACT;
else if ((*q == 'B') || (*q == 'b'))
working->flags |= CE_BINARY;
else if ((*q == 'G') || (*q == 'c'))
working->flags |= CE_GLOB;
else if (*q != '-')
errx(1, "illegal flag in config file -- %c",
*q);