Commit 38a91af3 authored by Tobias Frost's avatar Tobias Frost

Import Upstream version 3.2

parents
3.1 -> 3.2:
- create wtmp with correct perms
3.0 -> 3.1:
- fixed small alloca()
- added missingok flag
- use popt to display usage message
- handle /some/file { } in config file
2.9 -> 3.0
- updates for glibc 2.1
2.8 -> 2.9:
- fixed a bug parsing lines where { immediately follows the filename
- allow log file patterns to be placed in double quotes, which
allows spaces in names
- complain about missing log files (John Van Essen)
2.7 -> 2.8:
- changes for glibc 2.1 (Cristian Gafton)
2.6 -> 2.7:
- updated man page to include --force (Simon Mudd)
- invoke scripts via /bin/sh rather then relying on /tmp execute
semantics (Philip Guenther)
- added "extension" option for forcing a file extension after rotation
(Rob Hagopian)
2.5 -> 2.6:
- added nodelaycompress flag (from Jos Vos)
- added copytruncate, nocopytruncate flag (from Jos Vos)
- removed umask handling; explicitly use fchmod() insteadmoved umask
- added --force option (Simon Mudd)
- moved /bin/mail to MAIL_COMMAND define (Simon Mudd)
- fixed segv caused by overly long filenames
- switched from getopt_long to popt
2.4 -> 2.5:
- set the umask of the process to 0, letting open() create processes
with the proper permissions
- added delaycompress flag (from Jos Vos)
- fixed how old logs are finally removed when an olddir is specified
(Jos Vos)
- added nomail option
- added mail, nomail documentation to man page
- added the tabooext directive
- fixed problem in globbing
2.3 -> 2.4:
- glob log names in config file
- added ,v to taboo list
- fixed bug w/ create parsing
- use an int rather then a mode_t when parsing create entries as
sscanf requires it
2.2 -> 2.3:
- fill in all of last rotated structure (this probable isn't
really necessary but it's a bit cleaner and will avoid future
problems);
- fixed .spec file
2.1 -> 2.2:
- If a file is rotated and we have no state information for it,
right out the current time.
- Weekly rotation happens when the current weekday is less then
the weekday of the last rotation or more then a week has
elapsed between the last rotation and now
- Monthly rotation happens when the current month is different
from the last month or the current year is different from the
last year
- (these were contributed and suggested by Ronald Wahl)
- added olddir/noolddir options
- added ifempty/notifempty options
- ignore nonnormal files when reading config files from a directory
- (these were suggested and originally implemented by
Henning Schmiedehausen)
- updated the man page to reflect these changes
- made "make install" accept PREFIX argument
- added .spec file to tarball
2.0.2 -> 2.1:
- Don't output state information for logs that have never been
rotated (better then 1900-1-0)
- Accept 1900-1-0 as time 0
2.0.1 -> 2.0.2:
- I have no idea :-(
2.0 -> 2.0.1:
- ignore files in included directories which end with ~, .rpmorig, or
.rpmsave
This diff is collapsed.
/.cvsignore/1.1/Tue Jan 12 23:01:35 1999//
/COPYING/1.1/Wed Jul 9 18:54:49 1997//
/Makefile/1.19/Tue Dec 29 19:24:55 1998//
/basenames.c/1.1/Fri May 16 14:24:30 1997//
/basenames.h/1.1/Fri May 16 14:24:30 1997//
/log.c/1.7/Tue Jan 12 23:01:02 1999//
/log.h/1.3/Wed Nov 13 00:29:20 1996//
D/examples////
/config.c/1.17/Wed Apr 7 15:45:57 1999//
/logrotate.8/1.15/Wed Apr 7 15:45:57 1999//
/logrotate.c/1.24/Wed Apr 7 15:45:57 1999//
/logrotate.h/1.8/Wed Apr 7 15:45:57 1999//
/CHANGES/1.20/Wed Apr 7 16:00:52 1999//
/logrotate.spec/1.17/Wed Apr 7 16:00:36 1999//
:ext:notting@devserv.devel.redhat.com:/mnt/devel/CVS
VERSION = $(shell awk '/Version:/ { print $$2 }' logrotate.spec)
CVSTAG = r$(subst .,-,$(VERSION))
CFLAGS = -Wall -D_GNU_SOURCE -DVERSION=\"$(VERSION)\" $(RPM_OPT_FLAGS)
PROG = logrotate
BINDIR = /usr/sbin
MANDIR = /usr/man
MAN = logrotate.8
LOADLIBES = -lpopt
#--------------------------------------------------------------------------
OBJS = logrotate.o log.o config.o basenames.o
SOURCES = $(subst .o,.c,$(OBJS) $(LIBOBJS))
ifeq ($(RPM_OPT_FLAGS),)
CFLAGS += -g
LDFLAGS = -g
endif
ifeq (.depend,$(wildcard .depend))
TARGET=$(PROG)
else
TARGET=depend $(PROG)
endif
RCSVERSION = $(subst .,-,$(VERSION))
all: $(TARGET)
$(PROG): $(OBJS)
clean:
rm -f $(OBJS) $(PROG) core*
depend:
$(CPP) $(CFLAGS) -M $(SOURCES) > .depend
install:
[ -d $(PREFIX)/$(BINDIR) ] || mkdir -p $(PREFIX)/$(BINDIR)
[ -d $(PREFIX)/$(MANDIR) ] || mkdir -p $(PREFIX)/$(MANDIR)
[ -d $(PREFIX)/$(MANDIR)/man8 ] || mkdir -p $(PREFIX)/$(MANDIR)/man8
install -s -m 755 $(PROG) $(PREFIX)/$(BINDIR)
install -m 644 $(MAN) $(PREFIX)/$(MANDIR)/man`echo $(MAN) | sed "s/.*\.//"`/$(MAN)
co:
co RCS/*,v
(cd examples; co RCS/*,v)
cvstag:
cvs tag -F $(CVSTAG) .
archive: cvstag
@rm -rf /tmp/$(PROG)-$(VERSION)
@mkdir /tmp/$(PROG)-$(VERSION)
@rm -rf /tmp/$(PROG)-$(VERSION)
@mkdir /tmp/$(PROG)-$(VERSION)
@tar cSpf - * | (cd /tmp/$(PROG)-$(VERSION); tar xSpf -)
@cd /tmp/$(PROG)-$(VERSION); \
make clean; \
find . -name "RCS" -exec rm {} \; ; \
find . -name ".depend" -exec rm {} \; ; \
rm -rf *gz test* *.tar foo* shared \;
@cd /tmp; tar czSpf $(PROG)-$(VERSION).tar.gz $(PROG)-$(VERSION)
@rm -rf /tmp/$(PROG)-$(VERSION)
@cp /tmp/$(PROG)-$(VERSION).tar.gz .
@rm -f /tmp/$(PROG)-$(VERSION).tar.gz
@echo " "
@echo "The final archive is ./$(PROG)-$(VERSION).tar.gz."
ifeq (.depend,$(wildcard .depend))
include .depend
endif
#include <stdlib.h>
#include <string.h>
#include "basenames.h"
/* Return NAME with any leading path stripped off. */
char *ourBaseName(char *name) {
char *base;
base = strrchr(name, '/');
return base ? base + 1 : name;
}
static void stripTrailingSlashes(char *path) {
char * last;
last = path + strlen(path) - 1;
while (last > path && *last == '/')
*last-- = '\0';
}
char * ourDirName(char * origname) {
char * slash;
char * name;
int i = strlen(origname);
name = strcpy(malloc(i + 1), origname);
stripTrailingSlashes(name);
slash = strrchr(name, '/');
if (!slash)
return (char *) ".";
else {
/* Remove any trailing slashes and final element. */
while (slash > name && *slash == '/')
--slash;
slash[1] = '\0';
return name;
}
}
#ifndef H_BASENAMES
#define H_BASENAMES
/* returns a pointer inside of name */
char * ourBaseName(char *name);
/* returns a malloc'd string which must be freed by the caller */
char * ourDirName(char * origname);
#endif
This diff is collapsed.
/logrotate.cron/1.1/Thu Feb 27 17:27:26 1997//
/logrotate-default/1.2/Wed Apr 7 15:52:56 1999//
D
logrotate/examples
:ext:notting@devserv.devel.redhat.com:/mnt/devel/CVS
# see "man logrotate" for details
# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 4
# send errors to root
errors root
# create new (empty) log files after rotating old ones
create
# uncomment this if you want your log files compressed
#compress
# RPM packages drop log rotation information into this directory
include /etc/logrotate.d
# no packages own lastlog or wtmp -- we'll rotate them here
/var/log/wtmp {
monthly
create 0664 root utmp
rotate 1
}
/var/log/lastlog {
monthly
rotate 1
}
# system-specific logs may be configured here
#!/bin/sh
/usr/sbin/logrotate /etc/logrotate.conf
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <unistd.h>
#include "log.h"
int logLevel = MESS_DEBUG;
static FILE * errorFile = NULL;
static FILE * messageFile = NULL;
int flags = 0;
void logSetLevel(int level) {
logLevel = level;
}
void logSetErrorFile(FILE * f) {
errorFile = f;
}
void logSetMessageFile(FILE * f) {
messageFile = f;
}
void logSetFlags(int newFlags) {
flags |= newFlags;
}
void logClearFlags(int newFlags) {
flags &= ~newFlags;
}
void log(int fd, char * format, ...) {
int i = 0;
char * buf = NULL;
va_list args;
int size = -1;
va_start(args, format);
do {
i += 1000;
if (buf) free(buf);
buf = malloc(i);
size = vsnprintf(buf, size, format, args);
} while (i == size);
write(fd, buf, size);
free(buf);
va_end(args);
}
void message(int level, char * format, ...) {
va_list args;
FILE * where = NULL;
int showTime = 0;
if (errorFile == NULL)
errorFile = stderr;
if (messageFile == NULL)
messageFile = stderr;
where = errorFile;
if (level >= logLevel) {
va_start(args, format);
switch (level) {
case MESS_DEBUG:
where = messageFile;
showTime = 1;
break;
case MESS_NORMAL:
case MESS_VERBOSE:
where = messageFile;
break;
default:
if (flags & LOG_TIMES)
fprintf(where, "%ld: ", (long) time(NULL));
fprintf(errorFile, "error: ");
break;
}
if (showTime && (flags & LOG_TIMES)) {
fprintf(where, "%ld:", (long) time(NULL));
}
vfprintf(where, format, args);
fflush(where);
va_end(args);
if (level == MESS_FATAL) exit(1);
}
}
#ifndef H_LOG
#define H_LOG
#include <stdio.h>
#define MESS_REALDEBUG 1
#define MESS_DEBUG 2
#define MESS_VERBOSE 3
#define MESS_NORMAL 4
#define MESS_ERROR 5
#define MESS_FATAL 6
#define LOG_TIMES (1 << 0)
void message(int level, char * format, ...);
void log(int fd, char * format, ...);
void logSetErrorFile(FILE * f);
void logSetMessageFile(FILE * f);
void logSetFlags(int flags);
void logClearFlags(int flags);
void logSetLevel(int level);
#endif
This diff is collapsed.
This diff is collapsed.
#ifndef H_LOGROTATE
#define H_LOGROTATE
#include <sys/types.h>
#include <glob.h>
#define LOG_FLAG_COMPRESS (1 << 0)
#define LOG_FLAG_CREATE (1 << 1)
#define LOG_FLAG_IFEMPTY (1 << 2)
#define LOG_FLAG_DELAYCOMPRESS (1 << 3)
#define LOG_FLAG_COPYTRUNCATE (1 << 4)
#define LOG_FLAG_MISSINGOK (1 << 5)
#define MAIL_COMMAND "/bin/mail -s"
#define COMPRESS_COMMAND "gzip -9"
#define COMPRESS_EXT ".gz"
#define UNCOMPRESS_PIPE "gunzip"
#define NO_FORCE_ROTATE 0
#define FORCE_ROTATE 1
#define STATEFILE "/var/lib/logrotate.status"
typedef struct {
char * pattern;
char ** files;
int numFiles;
char * oldDir;
enum { ROT_DAYS, ROT_WEEKLY, ROT_MONTHLY, ROT_SIZE, ROT_FORCE } criterium;
unsigned int threshhold;
int rotateCount;
char * pre, * post;
char * logAddress;
char * errAddress;
char * extension;
int flags;
mode_t createMode; /* if any/all of these are -1, we use the */
uid_t createUid; /* attributes from the log file just rotated */
gid_t createGid;
glob_t globMem; /* at least we could theoretically free this */
} logInfo;
int readConfigPath(char * path, logInfo * defConfig,
logInfo ** logsPtr, int * numLogsPtr);
extern int debug;
#endif
Summary: Rotates, compresses, removes and mails system log files.
Name: logrotate
Version: 3.2
Release: 1
Copyright: GPL
Group: System Environment/Base
Source: ftp://ftp.redhat.com/pub/redhat/code/logrotate/logrotate-%{PACKAGE_VERSION}.tar.gz
BuildRoot: /var/tmp/logrotate.root
%description
The logrotate utility is designed to simplify the administration of
log files on a system which generates a lot of log files. Logrotate
allows for the automatic rotation compression, removal and mailing of
log files. Logrotate can be set to handle a log file daily, weekly,
monthly or when the log file gets to a certain size. Normally, logrotate
runs as a daily cron job.
Install the logrotate package if you need a utility to deal with the log
files on your system.
%prep
%setup
%build
make RPM_OPT_FLAGS="$RPM_OPT_FLAGS"
%install
make PREFIX=$RPM_BUILD_ROOT install
mkdir -p $RPM_BUILD_ROOT/etc/logrotate.d
mkdir -p $RPM_BUILD_ROOT/etc/cron.daily
install -m 644 examples/logrotate-default $RPM_BUILD_ROOT/etc/logrotate.conf
install -m 755 examples/logrotate.cron $RPM_BUILD_ROOT/etc/cron.daily/logrotate
%clean
rm -rf $RPM_BUILD_ROOT
%files
%attr(0755, root, root) /usr/sbin/logrotate
%attr(0644, root, root) /usr/man/man8/logrotate.8
%attr(0755, root, root) /etc/cron.daily/logrotate
%attr(0644, root, root) %config /etc/logrotate.conf
%attr(0755, root, root) %dir /etc/logrotate.d
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment