Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/newsyslog Overhaul newsyslog(8). Changes:
details: https://anonhg.NetBSD.org/src/rev/4c16c9b3fb47
branches: trunk
changeset: 494508:4c16c9b3fb47
user: ad <ad%NetBSD.org@localhost>
date: Fri Jul 07 10:52:41 2000 +0000
description:
Overhaul newsyslog(8). Changes:
- Code cleanup.
- Better flowing English in manpage (in places).
- `-n' option has been removed (was mainly a debugging convenience, I think).
- Add `C' flag: create log file if one doesn't exist.
diffstat:
usr.bin/newsyslog/Makefile | 10 +-
usr.bin/newsyslog/newsyslog.8 | 58 +-
usr.bin/newsyslog/newsyslog.c | 1096 +++++++++++++++++++---------------------
usr.bin/newsyslog/pathnames.h | 32 +
4 files changed, 594 insertions(+), 602 deletions(-)
diffs (truncated from 1379 to 300 lines):
diff -r 663d51b44ba8 -r 4c16c9b3fb47 usr.bin/newsyslog/Makefile
--- a/usr.bin/newsyslog/Makefile Fri Jul 07 10:47:06 2000 +0000
+++ b/usr.bin/newsyslog/Makefile Fri Jul 07 10:52:41 2000 +0000
@@ -1,11 +1,9 @@
-# $NetBSD: Makefile,v 1.12 1999/12/07 11:28:13 ad Exp $
+# $NetBSD: Makefile,v 1.13 2000/07/07 10:52:41 ad Exp $
PROG= newsyslog
-
-CPPFLAGS+= -DCONF=\"/etc/newsyslog.conf\"
-CPPFLAGS+= -DPIDFILE=\"/var/run/syslogd.pid\"
-CPPFLAGS+= -DCOMPRESS=\"/usr/bin/gzip\"
-CPPFLAGS+= -DCOMPRESS_POSTFIX=\".gz\"
+SRCS= newsyslog.c
+LDADD+= -lutil
+DPADD+= ${LIBUTIL}
MAN= newsyslog.8
MLINKS+=newsyslog.8 newsyslog.conf.5
diff -r 663d51b44ba8 -r 4c16c9b3fb47 usr.bin/newsyslog/newsyslog.8
--- a/usr.bin/newsyslog/newsyslog.8 Fri Jul 07 10:47:06 2000 +0000
+++ b/usr.bin/newsyslog/newsyslog.8 Fri Jul 07 10:52:41 2000 +0000
@@ -1,9 +1,29 @@
-.\" $NetBSD: newsyslog.8,v 1.12 1999/12/29 06:54:01 cgd Exp $
+.\" $NetBSD: newsyslog.8,v 1.13 2000/07/07 10:52:41 ad Exp $
+.\"
+.\" Copyright (c) 1999, 2000 Andrew Doran <ad%NetBSD.org@localhost>
+.\" All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. The name of the author may not be used to endorse or promote products
+.\" derived from this software without specific prior written permission
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" This file contains changes from the Open Software Foundation.
.\"
-.\" from FreeBSD: newsyslog.8,v 1.14.2.1 1999/02/25 18:38:33 wollman Exp
-.\"
.\" Copyright 1988, 1989 by the Massachusetts Institute of Technology
.\"
.\" Permission to use, copy, modify, and distribute this software
@@ -18,6 +38,8 @@
.\" the suitability of this software for any purpose. It is
.\" provided "as is" without express or implied warranty.
.\"
+.\" from FreeBSD: newsyslog.8,v 1.14.2.1 1999/02/25 18:38:33 wollman Exp
+.\"
.Dd November 20, 1999
.Dt NEWSYSLOG 8
.Os
@@ -26,7 +48,7 @@
.Nd maintain system log files to manageable sizes
.Sh SYNOPSIS
.Nm newsyslog
-.Op Fl Fnrv
+.Op Fl Frv
.Op Fl f Ar config_file
.Sh DESCRIPTION
.Nm Newsyslog
@@ -73,7 +95,7 @@
Each line of the file contains information about a particular log file
that should be handled by
.Nm newsyslog .
-Each line has five mandatory fields and four optional fields, with a
+Each line has six mandatory fields and three optional fields, with
whitespace separating each field. Blank lines or lines beginning with
``#'' are ignored. The fields of the configuration file are as
follows:
@@ -111,14 +133,13 @@
The
.Ar interval
field specifies the time separation (in hours) between trimming of the
-logfile. If this field
+log file. If this field
is replaced by an asterisk
.Pq Ql \&* ,
then the interval is not taken into account
when determining when to trim the log file.
.It Ar flags
-This optional field specifies if any special processing is required.
-The
+This field specifies any special processing that is required. The
.Ar Z
flag means that archived log files should be compressed with
.Xr gzip 1
@@ -129,14 +150,16 @@
.Tn ASCII
message which
.Nm
-inserts to indicate the fact that the logs have been
-trimmed should not be included. The
+inserts to indicate that the logs have been trimmed should not be included.
+The
.Ar N
flag means that no signal should be sent when the log is trimmed. The
+.Ar C
+flag instructs
+.Nm
+to create an empty log file if none currently exists. The
.Ar -
-flag means nothing, but can be used as a placeholder when the
-.Ar path_to_pid_file
-field is specified.
+flag means nothing - it is used as a spacer when no flags are set.
.It Ar path_to_pid_file
This optional field specifies
the file name to read to find the daemon process id. If this
@@ -164,11 +187,6 @@
.Nm
in verbose mode. In this mode it will print out each log and its
reasons for either trimming that log or skipping it.
-.It Fl n
-Cause
-.Nm
-not to trim the logs, but to print out what it would do if this option
-were not specified.
.It Fl r
Remove the restriction that
.Nm
@@ -194,8 +212,12 @@
.Sh AUTHORS
.An Theodore Ts'o ,
MIT Project Athena
+.An Andrew Doran ,
+The NetBSD Project
.Pp
Copyright 1987, Massachusetts Institute of Technology
+.Pp
+Copyright 1999, 2000 Andrew Doran
.Sh SEE ALSO
.Xr gzip 1 ,
.Xr syslog 3 ,
diff -r 663d51b44ba8 -r 4c16c9b3fb47 usr.bin/newsyslog/newsyslog.c
--- a/usr.bin/newsyslog/newsyslog.c Fri Jul 07 10:47:06 2000 +0000
+++ b/usr.bin/newsyslog/newsyslog.c Fri Jul 07 10:52:41 2000 +0000
@@ -1,55 +1,69 @@
-/* $NetBSD: newsyslog.c,v 1.21 1999/11/30 12:03:24 ad Exp $ */
+/* $NetBSD: newsyslog.c,v 1.22 2000/07/07 10:52:41 ad Exp $ */
+
+/*
+ * Copyright (c) 1999, 2000 Andrew Doran <ad%NetBSD.org@localhost>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
/*
* This file contains changes from the Open Software Foundation.
*/
/*
-
-Copyright 1988, 1989 by the Massachusetts Institute of Technology
-
-Permission to use, copy, modify, and distribute this software
-and its documentation for any purpose and without fee is
-hereby granted, provided that the above copyright notice
-appear in all copies and that both that copyright notice and
-this permission notice appear in supporting documentation,
-and that the names of M.I.T. and the M.I.T. S.I.P.B. not be
-used in advertising or publicity pertaining to distribution
-of the software without specific, written prior permission.
-M.I.T. and the M.I.T. S.I.P.B. make no representations about
-the suitability of this software for any purpose. It is
-provided "as is" without express or implied warranty.
-
-*/
+ * Copyright 1988, 1989 by the Massachusetts Institute of Technology
+ *
+ * Permission to use, copy, modify, and distribute this software
+ * and its documentation for any purpose and without fee is
+ * hereby granted, provided that the above copyright notice
+ * appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation,
+ * and that the names of M.I.T. and the M.I.T. S.I.P.B. not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific, written prior permission.
+ * M.I.T. and the M.I.T. S.I.P.B. make no representations about
+ * the suitability of this software for any purpose. It is
+ * provided "as is" without express or implied warranty.
+ *
+ */
/*
- * newsyslog - roll over selected logs at the appropriate time,
- * keeping the a specified number of backup files around.
+ * newsyslog(1) - a program to roll over log files provided that specified
+ * critera are met, optionally preserving a number of historical log files.
+ *
+ * XXX too much size_t fsckage.
*/
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: newsyslog.c,v 1.21 1999/11/30 12:03:24 ad Exp $");
+__RCSID("$NetBSD: newsyslog.c,v 1.22 2000/07/07 10:52:41 ad Exp $");
#endif /* not lint */
-#ifndef CONF
-#define CONF "/etc/athena/newsyslog.conf" /* Configuration file */
-#endif
-#ifndef PIDFILE
-#define PIDFILE "/etc/syslog.pid"
-#endif
-#ifndef COMPRESS
-#define COMPRESS "/usr/ucb/compress" /* File compression program */
-#endif
-#ifndef COMPRESS_POSTFIX
-#define COMPRESS_POSTFIX ".Z"
-#endif
-
#include <sys/types.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/param.h>
-#include <sys/wait.h>
#include <ctype.h>
#include <fcntl.h>
@@ -58,619 +72,545 @@
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
+#include <stdarg.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
+#include <errno.h>
+#include <err.h>
+#include <util.h>
-#define kbytes(size) (((size) + 1023) >> 10)
-#ifdef _IBMR2
-/* Calculates (db * DEV_BSIZE) */
-#define dbtob(db) ((unsigned)(db) << UBSHIFT)
-#endif
+#include "pathnames.h"
+
+#define PRINFO(x) ((void)(verbose ? printf x : 0))
-#define CE_COMPACT 1 /* Compact the achived log files */
-#define CE_BINARY 2 /* Logfile is in binary, don't add */
- /* status messages */
-#define CE_NOSIGNAL 4 /* Don't send a signal when trimmed */
-#define NONE -1
-
+#define CE_COMPACT 1 /* Compact the achived log files */
+#define CE_BINARY 2 /* Logfile is a binary file/non-syslog */
+#define CE_NOSIGNAL 4 /* Don't send a signal when trimmed */
+#define CE_CREATE 8 /* Create log file if none exists */
+
struct conf_entry {
- char *log; /* Name of the log */
- int uid; /* Owner of log */
- int gid; /* Group of log */
- int numlogs; /* Number of logs to keep */
- int size; /* Size cutoff to trigger trimming the log */
- int hours; /* Hours between log trimming */
- int permissions; /* File permissions on the log */
- int flags; /* Flags (CE_*) */
- char *pidfile; /* Name of file containing PID to signal */
- int signum; /* Signal to send */
- struct conf_entry *next; /* Linked list pointer */
+ uid_t uid; /* Owner of log */
+ gid_t gid; /* Group of log */
+ mode_t mode; /* File permissions */
Home |
Main Index |
Thread Index |
Old Index