From 2e4411caecd2d8307c50b7a0d90ee217ec5f84fe Mon Sep 17 00:00:00 2001 From: charnier Date: Mon, 6 Oct 1997 07:46:08 +0000 Subject: Cosmetic in err() strings. --- usr.sbin/newsyslog/newsyslog.8 | 44 ++++++++++++++++++----------------- usr.sbin/newsyslog/newsyslog.c | 53 ++++++++++++++++++------------------------ 2 files changed, 46 insertions(+), 51 deletions(-) (limited to 'usr.sbin/newsyslog') diff --git a/usr.sbin/newsyslog/newsyslog.8 b/usr.sbin/newsyslog/newsyslog.8 index e6286c9..c805197 100644 --- a/usr.sbin/newsyslog/newsyslog.8 +++ b/usr.sbin/newsyslog/newsyslog.8 @@ -1,7 +1,7 @@ .\" This file contains changes from the Open Software Foundation. .\" .\" from: @(#)newsyslog.8 -.\" $Id: newsyslog.8,v 1.7 1997/05/06 23:11:05 brian Exp $ +.\" $Id: newsyslog.8,v 1.8 1997/06/23 04:03:49 steve Exp $ .\" .\" Copyright 1988, 1989 by the Massachusetts Institute of Technology .\" @@ -33,7 +33,7 @@ is a program that should be scheduled to run periodically by .Xr cron 8 . When it is executed it archives log files if necessary. If a log file is determined to require archiving, -.Nm newsyslog +.Nm rearranges the files so that ``logfile'' is empty, ``logfile.0'' has the last period's logs in it, ``logfile.1'' has the next to last period's logs in it, and so on, up to a user-specified number of @@ -43,14 +43,14 @@ space. A log can be archived because of two reasons. The log file can have grown bigger than a preset size in kilobytes, or a preset number of hours may have elapsed since the last log archive. The granularity of -.Nm newsyslog +.Nm is dependent on how often it is scheduled to run by .Xr cron 8 . Since the program is quite fast, it may be scheduled to run every hour without any ill effects. .Pp When starting up, -.Nm newsyslog +.Nm reads in a configuration file to determine which logs should be looked at. By default, this configuration file is .Pa /etc/newsyslog.conf . @@ -62,11 +62,11 @@ whitespace separating each field. Blank lines or lines beginning with ``#'' are ignored. The fields of the configuration file are as follows: .Pp -.Bl -tag -width logfile_namexxxx +.Bl -tag -width indent .It Ar logfile_name Name of the system log file to be archived. .It Ar owner.group -Specifies the owner and group for the archive file. +Specify the owner and group for the archive file. The "." is essential, even if the .Ar owner or @@ -75,11 +75,11 @@ field is left blank. The field may be numeric, or a name which is present in .Pa /etc/passwd or -.Pa /etc/group. +.Pa /etc/group . .It Ar mode -Specifies the mode of the log file and archives. +Specify the mode of the log file and archives. .It Ar count -Specifies the number of archive files to be kept +Specify the number of archive files to be kept besides the log file itself. .It Ar size When the size of the log file reaches @@ -108,7 +108,8 @@ using .Xr gzip 1 . The .Ar B -flag means that the file is a binary file, and so the ASCII +flag means that the file is a binary file, and so the +.Tn ASCII message which .Nm inserts to indicate the fact that the logs have been @@ -128,40 +129,41 @@ properly. The following options can be used with newsyslog: .Bl -tag -width indent .It Fl f Ar config_file -instructs newsyslog to use +Instruct newsyslog to use .Ar config_file instead of .Pa /etc/newsyslog.conf for its configuration file. .It Fl v -places -.Nm newsyslog +Place +.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 -causes -.Nm newsyslog +Cause +.Nm not to trim the logs, but to print out what it would do if this option were not specified. .It Fl r -removes the restriction that -.Nm newsyslog +Remove the restriction that +.Nm must be running as root. Of course, -.Nm newsyslog +.Nm will not be able to send a HUP signal to .Xr syslogd 8 so this option should only be used in debugging. .El .Sh FILES -.Bl -tag -width /etc/newsyslog.confxxxx -comapct +.Bl -tag -width /etc/newsyslog.confxxxx -compact .It Pa /etc/newsyslog.conf -.Nm newsyslog +.Nm configuration file. .El .Sh BUGS Doesn't yet automatically read the logs to find security breaches. .Sh AUTHOR -Theodore Ts'o, MIT Project Athena +.An Theodore Ts'o , +MIT Project Athena .Pp Copyright 1987, Massachusetts Institute of Technology .Sh "SEE ALSO" diff --git a/usr.sbin/newsyslog/newsyslog.c b/usr.sbin/newsyslog/newsyslog.c index 768db39..00763a2 100644 --- a/usr.sbin/newsyslog/newsyslog.c +++ b/usr.sbin/newsyslog/newsyslog.c @@ -23,13 +23,11 @@ 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. - * - * $Source: /home/ncvs/src/usr.sbin/newsyslog/newsyslog.c,v $ - * $Author: ache $ */ #ifndef lint -static char rcsid[] = "$Id: newsyslog.c,v 1.12 1997/05/05 15:00:15 ache Exp $"; +static const char rcsid[] = + "$Id: newsyslog.c,v 1.13 1997/05/06 23:11:06 brian Exp $"; #endif /* not lint */ #ifndef CONF @@ -48,16 +46,16 @@ static char rcsid[] = "$Id: newsyslog.c,v 1.12 1997/05/05 15:00:15 ache Exp $"; #define COMPRESS_POSTFIX ".Z" #endif +#include +#include +#include +#include +#include +#include #include #include #include -#include -#include -#include -#include -#include #include -#include #include #include #include @@ -88,7 +86,6 @@ struct conf_entry { struct conf_entry *next; /* Linked list pointer */ }; -char *progname; /* contains argv[0] */ 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 */ @@ -125,10 +122,8 @@ int main(argc,argv) struct conf_entry *p, *q; PRS(argc,argv); - if (needroot && getuid() && geteuid()) { - fprintf(stderr,"%s: must have root privs\n",progname); - return(1); - } + if (needroot && getuid() && geteuid()) + errx(1, "must have root privs"); p = q = parse_file(); syslog_pid = needroot ? get_pid(PIDFILE) : 0; @@ -193,7 +188,6 @@ static void PRS(argc,argv) int c; char *p; - progname = argv[0]; timenow = time((time_t *) 0); daytime = ctime(&timenow) + 4; daytime[15] = '\0'; @@ -228,8 +222,7 @@ static void PRS(argc,argv) static void usage() { - fprintf(stderr, - "Usage: %s <-nrv> <-f config-file>\n", progname); + fprintf(stderr, "usage: newsyslog [-nrv] [-f config-file]\n"); exit(1); } @@ -268,14 +261,14 @@ static struct conf_entry *parse_file() q = parse = missing_field(sob(line),errline); parse = son(line); if (!*parse) - errx(1, "Malformed line (missing fields):\n%s", errline); + errx(1, "malformed line (missing fields):\n%s", errline); *parse = '\0'; working->log = strdup(q); q = parse = missing_field(sob(++parse),errline); parse = son(parse); if (!*parse) - errx(1, "Malformed line (missing fields):\n%s", errline); + errx(1, "malformed line (missing fields):\n%s", errline); *parse = '\0'; if ((group = strchr(q, '.')) != NULL) { *group++ = '\0'; @@ -283,7 +276,7 @@ static struct conf_entry *parse_file() if (!(isnumber(*q))) { if ((pass = getpwnam(q)) == NULL) errx(1, - "Error in config file; unknown user:\n%s", + "error in config file; unknown user:\n%s", errline); working->uid = pass->pw_uid; } else @@ -296,7 +289,7 @@ static struct conf_entry *parse_file() if (!(isnumber(*q))) { if ((grp = getgrnam(q)) == NULL) errx(1, - "Error in config file; unknown group:\n%s", + "error in config file; unknown group:\n%s", errline); working->gid = grp->gr_gid; } else @@ -307,29 +300,29 @@ static struct conf_entry *parse_file() q = parse = missing_field(sob(++parse),errline); parse = son(parse); if (!*parse) - errx(1, "Malformed line (missing fields):\n%s", errline); + errx(1, "malformed line (missing fields):\n%s", errline); *parse = '\0'; } else working->uid = working->gid = NONE; if (!sscanf(q,"%o",&working->permissions)) - errx(1, "Error in config file; bad permissions:\n%s", + errx(1, "error in config file; bad permissions:\n%s", errline); q = parse = missing_field(sob(++parse),errline); parse = son(parse); if (!*parse) - errx(1, "Malformed line (missing fields):\n%s", errline); + errx(1, "malformed line (missing fields):\n%s", errline); *parse = '\0'; if (!sscanf(q,"%d",&working->numlogs)) - errx(1, "Error in config file; bad number:\n%s", + errx(1, "error in config file; bad number:\n%s", errline); q = parse = missing_field(sob(++parse),errline); parse = son(parse); if (!*parse) - errx(1, "Malformed line (missing fields):\n%s", errline); + errx(1, "malformed line (missing fields):\n%s", errline); *parse = '\0'; if (isdigit(*q)) working->size = atoi(q); @@ -362,7 +355,7 @@ static struct conf_entry *parse_file() else if ((*q == 'B') || (*q == 'b')) working->flags |= CE_BINARY; else if (*q != '-') - errx(1, "Illegal flag in config file -- %c", *q); + errx(1, "illegal flag in config file -- %c", *q); q++; } @@ -378,7 +371,7 @@ static struct conf_entry *parse_file() if (*q == '/') working->pid_file = strdup(q); else - errx(1, "Illegal pid file in config file:\n%s", q); + errx(1, "illegal pid file in config file:\n%s", q); } free(errline); @@ -393,7 +386,7 @@ static char *missing_field(p,errline) char *p,*errline; { if (!p || !*p) - errx(1, "Missing field in config file:\n%s", errline); + errx(1, "missing field in config file:\n%s", errline); return(p); } -- cgit v1.1