OBS User unknown 2009-03-08 23:25:57 +00:00 committed by Git OBS Bridge
parent 2507ecb4d6
commit 1303a84ead
12 changed files with 191 additions and 322 deletions

View File

@ -1,169 +0,0 @@
--- logrotate.c (revision 259)
+++ logrotate.c (revision 260)
@@ -46,8 +46,11 @@
char *baseName;
};
-LIST_HEAD(stateSet, logState) states;
+struct logStates {
+ LIST_HEAD(stateSet, logState) head;
+} **states;
+unsigned int hashSize;
int numLogs = 0;
int debug = 0;
char *mailCommand = DEFAULT_MAIL_COMMAND;
@@ -64,6 +67,59 @@
return 1;
}
+#define HASH_SIZE_MIN 64
+static int allocateHash(void)
+{
+ struct logInfo *log;
+ unsigned int hs;
+ int i;
+
+ hs = 0;
+
+ for (log = logs.tqh_first; log != NULL; log = log->list.tqe_next)
+ hs += log->numFiles;
+
+ hs *= 2;
+
+ /* Enforce some reasonable minimum hash size */
+ if (hs < HASH_SIZE_MIN)
+ hs = HASH_SIZE_MIN;
+
+ states = calloc(hs, sizeof(struct logStates *));
+ if (states == NULL) {
+ message(MESS_ERROR, "could not allocate memory for "
+ "hash table\n");
+ return 1;
+ }
+
+ for (i = 0; i < hs; i++) {
+ states[i] = malloc(sizeof(struct logState));
+ if (states[i] == NULL) {
+ message(MESS_ERROR, "could not allocate memory for "
+ "hash element\n");
+ return 1;
+ }
+ LIST_INIT(&(states[i]->head));
+ }
+
+ hashSize = hs;
+
+ return 0;
+}
+
+#define HASH_CONST 13
+static unsigned hashIndex(const char *fn)
+{
+ unsigned hash = 0;
+
+ while (*fn) {
+ hash *= HASH_CONST;
+ hash += *fn++;
+ }
+
+ return hash % hashSize;
+}
+
static struct logState *newState(const char *fn)
{
struct tm now = *localtime(&nowSecs);
@@ -92,9 +148,10 @@
static struct logState *findState(const char *fn)
{
+ unsigned int i = hashIndex(fn);
struct logState *p;
- for (p = states.lh_first; p != NULL; p = p->list.le_next)
+ for (p = states[i]->head.lh_first; p != NULL; p = p->list.le_next)
if (!strcmp(fn, p->fn))
break;
@@ -103,7 +160,7 @@
if ((p = newState(fn)) == NULL)
return NULL;
- LIST_INSERT_HEAD(&states, p, list);
+ LIST_INSERT_HEAD(&(states[i]->head), p, list);
}
return p;
@@ -1313,6 +1370,7 @@
struct logState *p;
FILE *f;
char *chptr;
+ int i;
f = fopen(stateFilename, "w");
if (!f) {
@@ -1323,27 +1381,29 @@
fprintf(f, "logrotate state -- version 2\n");
- for (p = states.lh_first; p != NULL; p = p->list.le_next) {
- fputc('"', f);
- for (chptr = p->fn; *chptr; chptr++) {
- switch (*chptr) {
- case '"':
- fputc('\\', f);
- }
+ for (i = 0; i < hashSize; i++) {
+ for (p = states[i]->head.lh_first; p != NULL;
+ p = p->list.le_next) {
+ fputc('"', f);
+ for (chptr = p->fn; *chptr; chptr++) {
+ switch (*chptr) {
+ case '"':
+ fputc('\\', f);
+ }
- fputc(*chptr, f);
+ fputc(*chptr, f);
+ }
+
+ fputc('"', f);
+ fprintf(f, " %d-%d-%d\n",
+ p->lastRotated.tm_year + 1900,
+ p->lastRotated.tm_mon + 1,
+ p->lastRotated.tm_mday);
+ }
}
- fputc('"', f);
- fprintf(f, " %d-%d-%d\n",
- p->lastRotated.tm_year + 1900,
- p->lastRotated.tm_mon + 1,
- p->lastRotated.tm_mday);
- }
-
- fclose(f);
-
- return 0;
+ fclose(f);
+ return 0;
}
static int readState(char *stateFilename)
@@ -1555,7 +1615,8 @@
poptFreeContext(optCon);
nowSecs = time(NULL);
- LIST_INIT(&states);
+ if (allocateHash() != 0)
+ return 1;
if (readState(stateFile))
{
@@ -1577,5 +1639,5 @@
rc = 1;
}
- return (rc != 0);
+ return (rc != 0);
}

View File

@ -1,11 +0,0 @@
--- ./logrotate.c.orig 2008-09-03 10:32:34.000000000 +0200
+++ ./logrotate.c 2008-09-03 10:32:55.000000000 +0200
@@ -930,7 +930,7 @@ int prerotateSingleLog(struct logInfo *l
rotNames->dirName, rotNames->baseName, dext_str, fileext);
sprintf(destFile, "%s%s", rotNames->finalName, compext);
if (!stat(destFile, &fst_buf)) {
- message(MESS_DEBUG,
+ message(MESS_ERROR,
"destination %s already exists, skipping rotation\n",
rotNames->firstRotated);
hasErrors = 1;

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:d3d9ef3b41e2ba0d0b7f5a3aa2598b89fdaabad177f172452756411729fbb5cb
size 37080

View File

@ -1,95 +1,7 @@
--- ./config.c.orig 2008-09-02 17:28:52.000000000 +0200 Index: test/test
+++ ./config.c 2008-09-02 17:29:59.000000000 +0200 ===================================================================
@@ -434,6 +434,7 @@ int readAllConfigPaths(const char **path --- test/test.orig 2008-05-14 12:31:35.000000000 +0200
/* first, last */ NULL, NULL, +++ test/test 2009-03-06 15:15:00.000000000 +0100
/* logAddress */ NULL,
/* extension */ NULL,
+ /* addextension */ NULL,
/* compress_prog */ NULL,
/* uncompress_prog */ NULL,
/* compress_ext */ NULL,
@@ -1151,6 +1152,24 @@ static int readConfigFile(const char *co
message(MESS_DEBUG, "extension is now %s\n",
newlog->extension);
+ } else if (!strcmp(start, "addextension")) {
+ *endtag = oldchar, start = endtag;
+
+ freeLogItem (addextension);
+
+ if (!isolateValue
+ (configFile, lineNum, "addextension name", &start,
+ &endtag)) {
+ oldchar = *endtag, *endtag = '\0';
+
+ newlog->addextension = strdup(start);
+
+ *endtag = oldchar, start = endtag;
+ }
+
+ message(MESS_DEBUG, "addextension is now %s\n",
+ newlog->addextension);
+
} else if (!strcmp(start, "compresscmd")) {
*endtag = oldchar, start = endtag;
--- ./logrotate.h.orig 2008-09-02 17:28:52.000000000 +0200
+++ ./logrotate.h 2008-09-02 17:29:59.000000000 +0200
@@ -41,6 +41,7 @@ struct logInfo {
char *pre, *post, *first, *last;
char *logAddress;
char *extension;
+ char *addextension;
char *compress_prog;
char *uncompress_prog;
char *compress_ext;
--- ./logrotate.8.orig 2008-09-02 17:28:52.000000000 +0200
+++ ./logrotate.8 2008-09-02 17:29:59.000000000 +0200
@@ -142,6 +142,15 @@ Here is more information on the directiv
a \fBlogrotate\fR configuration file:
.TP
+\fBaddextension \fIext\fR
+Log files are given the final extension \fIext\fR after rotation. If
+the original file already ends with \fIext\fR, the extension is not
+duplicated, but merely moved to the end, i.e. both \fBfilename\fR and
+\fBfilename\fIext\fR would get rotated to filename.1\fIext\fR. If
+compression is used, the compression extension (normally \fB.gz\fR)
+appears after \fIext\fR.
+
+.TP
\fBcompress\fR
Old versions of log files are compressed with \fBgzip\fR by default. See also
\fBnocompress\fR.
--- ./logrotate.c.orig 2008-09-02 17:28:52.000000000 +0200
+++ ./logrotate.c 2008-09-02 17:29:59.000000000 +0200
@@ -618,6 +618,24 @@ int prerotateSingleLog(struct logInfo *l
rotNames->baseName = strdup(ourBaseName(log->files[logNum]));
+ if (log->addextension) {
+ size_t baseLen = strlen(rotNames->baseName);
+ size_t extLen = strlen(log->addextension);
+ if (baseLen >= extLen &&
+ strncmp(&(rotNames->baseName[baseLen - extLen]),
+ log->addextension, extLen) == 0) {
+ char *tempstr;
+
+ fileext = log->addextension;
+ tempstr = calloc(baseLen - extLen + 1, sizeof(char));
+ strncat(tempstr, rotNames->baseName, baseLen - extLen);
+ free(rotNames->baseName);
+ rotNames->baseName = tempstr;
+ } else {
+ fileext = log->addextension;
+ }
+ }
+
oldName = alloca(PATH_MAX);
newName = alloca(PATH_MAX);
rotNames->disposeName = malloc(PATH_MAX);
--- test/test.orig 2008-09-03 10:25:58.000000000 +0200
+++ test/test 2008-09-03 10:27:06.000000000 +0200
@@ -369,4 +369,27 @@ @@ -369,4 +369,27 @@
EOF EOF
@ -118,8 +30,10 @@
+EOF +EOF
+ +
cleanup cleanup
--- test/test-config.16.in.orig 2008-09-03 10:27:59.000000000 +0200 Index: test/test-config.16.in
+++ test/test-config.16.in 2008-09-03 10:28:23.000000000 +0200 ===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ test/test-config.16.in 2009-03-06 15:15:00.000000000 +0100
@@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
+create +create
+ +
@ -129,8 +43,10 @@
+ addextension .log + addextension .log
+} +}
+ +
--- test/test-config.15.in.orig 2008-09-03 10:27:59.000000000 +0200 Index: test/test-config.15.in
+++ test/test-config.15.in 2008-09-03 10:28:23.000000000 +0200 ===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ test/test-config.15.in 2009-03-06 15:15:00.000000000 +0100
@@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
+create +create
+ +
@ -140,3 +56,101 @@
+ addextension .newext + addextension .newext
+} +}
+ +
Index: config.c
===================================================================
--- config.c.orig 2009-03-06 15:07:06.000000000 +0100
+++ config.c 2009-03-06 15:17:38.000000000 +0100
@@ -428,6 +428,7 @@
.last = NULL,
.logAddress = NULL,
.extension = NULL,
+ .addextension = NULL,
.compress_prog = NULL,
.uncompress_prog = NULL,
.compress_ext = NULL,
@@ -1158,6 +1159,24 @@
message(MESS_DEBUG, "extension is now %s\n",
newlog->extension);
+ } else if (!strcmp(start, "addextension")) {
+ *endtag = oldchar, start = endtag;
+
+ freeLogItem (addextension);
+
+ if (!isolateValue
+ (configFile, lineNum, "addextension name", &start,
+ &endtag)) {
+ oldchar = *endtag, *endtag = '\0';
+
+ newlog->addextension = strdup(start);
+
+ *endtag = oldchar, start = endtag;
+ }
+
+ message(MESS_DEBUG, "addextension is now %s\n",
+ newlog->addextension);
+
} else if (!strcmp(start, "compresscmd")) {
*endtag = oldchar, start = endtag;
Index: logrotate.8
===================================================================
--- logrotate.8.orig 2008-12-06 15:05:40.000000000 +0100
+++ logrotate.8 2009-03-06 15:15:00.000000000 +0100
@@ -144,6 +144,15 @@
a \fBlogrotate\fR configuration file:
.TP
+\fBaddextension \fIext\fR
+Log files are given the final extension \fIext\fR after rotation. If
+the original file already ends with \fIext\fR, the extension is not
+duplicated, but merely moved to the end, i.e. both \fBfilename\fR and
+\fBfilename\fIext\fR would get rotated to filename.1\fIext\fR. If
+compression is used, the compression extension (normally \fB.gz\fR)
+appears after \fIext\fR.
+
+.TP
\fBcompress\fR
Old versions of log files are compressed with \fBgzip\fR(1) by default. See also
\fBnocompress\fR.
Index: logrotate.c
===================================================================
--- logrotate.c.orig 2009-03-06 15:07:06.000000000 +0100
+++ logrotate.c 2009-03-06 15:15:00.000000000 +0100
@@ -671,6 +671,24 @@
rotNames->baseName = strdup(ourBaseName(log->files[logNum]));
+ if (log->addextension) {
+ size_t baseLen = strlen(rotNames->baseName);
+ size_t extLen = strlen(log->addextension);
+ if (baseLen >= extLen &&
+ strncmp(&(rotNames->baseName[baseLen - extLen]),
+ log->addextension, extLen) == 0) {
+ char *tempstr;
+
+ fileext = log->addextension;
+ tempstr = calloc(baseLen - extLen + 1, sizeof(char));
+ strncat(tempstr, rotNames->baseName, baseLen - extLen);
+ free(rotNames->baseName);
+ rotNames->baseName = tempstr;
+ } else {
+ fileext = log->addextension;
+ }
+ }
+
oldName = alloca(PATH_MAX);
newName = alloca(PATH_MAX);
rotNames->disposeName = malloc(PATH_MAX);
Index: logrotate.h
===================================================================
--- logrotate.h.orig 2009-03-06 15:07:06.000000000 +0100
+++ logrotate.h 2009-03-06 15:15:00.000000000 +0100
@@ -41,6 +41,7 @@
char *pre, *post, *first, *last;
char *logAddress;
char *extension;
+ char *addextension;
char *compress_prog;
char *uncompress_prog;
char *compress_ext;

View File

@ -1,6 +1,8 @@
--- ./config.c.orig 2008-05-09 09:28:59.000000000 +0200 Index: config.c
+++ ./config.c 2008-08-22 16:21:35.000000000 +0200 ===================================================================
@@ -485,7 +485,7 @@ --- config.c.orig 2008-06-02 12:26:14.000000000 +0200
+++ config.c 2009-03-06 14:21:45.000000000 +0100
@@ -483,7 +483,7 @@
static int readConfigFile(const char *configFile, struct logInfo *defConfig) static int readConfigFile(const char *configFile, struct logInfo *defConfig)
{ {
int fd; int fd;
@ -9,7 +11,7 @@
char oldchar, foo; char oldchar, foo;
off_t length; off_t length;
int lineNum = 1; int lineNum = 1;
@@ -1182,6 +1182,18 @@ @@ -1189,6 +1189,18 @@
message(MESS_DEBUG, "compress_prog is now %s\n", message(MESS_DEBUG, "compress_prog is now %s\n",
newlog->compress_prog); newlog->compress_prog);
@ -28,21 +30,11 @@
} else if (!strcmp(start, "uncompresscmd")) { } else if (!strcmp(start, "uncompresscmd")) {
*endtag = oldchar, start = endtag; *endtag = oldchar, start = endtag;
--- ./logrotate.h.orig 2008-05-09 09:28:59.000000000 +0200 Index: logrotate.c
+++ ./logrotate.h 2008-08-22 16:38:13.000000000 +0200 ===================================================================
@@ -61,6 +61,9 @@ --- logrotate.c.orig 2008-10-15 15:07:43.000000000 +0200
extern int numLogs; +++ logrotate.c 2009-03-06 14:21:45.000000000 +0100
extern int debug; @@ -54,6 +54,15 @@
+/* This is the definition. Note we have to carry the "2" within the declaration (logrotate.c), too! */
+extern const char * compress_cmd_list[][2];
+
int readAllConfigPaths(const char **paths);
#endif
--- ./logrotate.c.orig 2008-05-14 12:31:35.000000000 +0200
+++ ./logrotate.c 2008-08-22 16:21:35.000000000 +0200
@@ -51,6 +51,15 @@
int numLogs = 0; int numLogs = 0;
int debug = 0; int debug = 0;
char *mailCommand = DEFAULT_MAIL_COMMAND; char *mailCommand = DEFAULT_MAIL_COMMAND;
@ -58,12 +50,17 @@
time_t nowSecs = 0; time_t nowSecs = 0;
static int shred_file(char *filename, struct logInfo *log); static int shred_file(char *filename, struct logInfo *log);
@@ -278,7 +287,7 @@ Index: logrotate.h
char *uncompressCommand, char *address, char *subject) ===================================================================
{ --- logrotate.h.orig 2008-05-09 09:28:59.000000000 +0200
int mailInput; +++ logrotate.h 2009-03-06 14:21:45.000000000 +0100
- pid_t mailChild, uncompressChild; @@ -61,6 +61,9 @@
+ pid_t mailChild, uncompressChild=(pid_t) 0; extern int numLogs;
int mailStatus, uncompressStatus; extern int debug;
int uncompressPipe[2];
char *mailArgv[] = { mailCommand, "-s", subject, address, NULL }; +/* This is the definition. Note we have to carry the "2" within the declaration (logrotate.c), too! */
+extern const char * compress_cmd_list[][2];
+
int readAllConfigPaths(const char **paths);
#endif

View File

@ -1,6 +1,8 @@
--- examples/logrotate-default Index: examples/logrotate-default
+++ examples/logrotate-default ===================================================================
@@ -14,22 +14,30 @@ dateext --- examples/logrotate-default.orig 2007-08-29 09:19:36.000000000 +0200
+++ examples/logrotate-default 2009-03-06 14:11:05.000000000 +0100
@@ -14,22 +14,30 @@
# uncomment this if you want your log files compressed # uncomment this if you want your log files compressed
#compress #compress
@ -44,8 +46,10 @@
+#} +#}
# system-specific logs may be also be configured here. # system-specific logs may be also be configured here.
--- examples/logrotate.wtmp Index: examples/logrotate.wtmp
+++ examples/logrotate.wtmp ===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ examples/logrotate.wtmp 2009-03-06 14:11:05.000000000 +0100
@@ -0,0 +1,11 @@ @@ -0,0 +1,11 @@
+/var/log/wtmp { +/var/log/wtmp {
+ compress + compress

View File

@ -0,0 +1,13 @@
Index: logrotate.c
===================================================================
--- logrotate.c.orig 2009-03-06 15:20:25.000000000 +0100
+++ logrotate.c 2009-03-06 15:24:07.000000000 +0100
@@ -997,7 +997,7 @@
}
snprintf(destFile, PATH_MAX, "%s%s", rotNames->finalName, compext);
if (!stat(destFile, &fst_buf)) {
- message(MESS_DEBUG,
+ message(MESS_ERROR,
"destination %s already exists, skipping rotation\n",
rotNames->firstRotated);
hasErrors = 1;

View File

@ -1,5 +1,7 @@
--- ./Makefile.orig 2008-05-19 12:25:54.000000000 +0200 Index: Makefile
+++ ./Makefile 2008-08-22 15:28:29.000000000 +0200 ===================================================================
--- Makefile.orig 2008-05-19 12:25:54.000000000 +0200
+++ Makefile 2009-03-06 13:57:22.000000000 +0100
@@ -61,7 +61,7 @@ @@ -61,7 +61,7 @@
endif endif
@ -9,8 +11,10 @@
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
--- ./examples/logrotate.cron.orig 2008-08-22 15:51:39.000000000 +0200 Index: examples/logrotate.cron
+++ ./examples/logrotate.cron 2008-08-22 15:28:29.000000000 +0200 ===================================================================
--- examples/logrotate.cron.orig 2003-07-09 21:36:35.000000000 +0200
+++ examples/logrotate.cron 2009-03-06 13:57:22.000000000 +0100
@@ -1,8 +1,17 @@ @@ -1,8 +1,17 @@
#!/bin/sh #!/bin/sh

3
logrotate-3.7.8.tar.bz2 Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:65fe448828145f3d83eb9e5f92654dfe1bc4dcd865586ec041c71fac009b4479
size 37763

View File

@ -1,3 +1,14 @@
-------------------------------------------------------------------
Fri Mar 6 15:31:04 CET 2009 - puzel@suse.cz
- update to 3.7.8
- do not exit on status file errors
- limit config file inclusion nesting
- use hashes for status file handling
- dateformat to allow unixtime
- manual page corrections
- drop hashes patch (upstream)
------------------------------------------------------------------- -------------------------------------------------------------------
Wed Dec 10 19:48:49 CET 2008 - schwab@suse.de Wed Dec 10 19:48:49 CET 2008 - schwab@suse.de

View File

@ -1,7 +1,7 @@
# #
# spec file for package logrotate (Version 3.7.7) # spec file for package logrotate (Version 3.7.8)
# #
# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany. # Copyright (c) 2009 SUSE LINUX Products GmbH, Nuernberg, Germany.
# #
# All modifications and additions to the file contributed by third parties # All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed # remain the property of their copyright owners, unless otherwise agreed
@ -23,8 +23,8 @@ Name: logrotate
BuildRequires: popt-devel BuildRequires: popt-devel
BuildRequires: libselinux-devel BuildRequires: libselinux-devel
Summary: Rotate, Compress, Remove, and Mail System Log Files Summary: Rotate, Compress, Remove, and Mail System Log Files
Version: 3.7.7 Version: 3.7.8
Release: 10 Release: 1
License: GPL v2 or later License: GPL v2 or later
Group: System/Base Group: System/Base
Source: %{name}-%{version}.tar.bz2 Source: %{name}-%{version}.tar.bz2
@ -34,7 +34,6 @@ Patch2: %{name}-%{version}-autoext.patch
Patch3: %{name}-%{version}-addextension.patch Patch3: %{name}-%{version}-addextension.patch
Patch4: %{name}-%{version}-mess_err.patch Patch4: %{name}-%{version}-mess_err.patch
Patch5: %{name}-%{version}-cron-check-for-another-instance.patch Patch5: %{name}-%{version}-cron-check-for-another-instance.patch
Patch6: %{name}-%{version}-hashes.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRoot: %{_tmppath}/%{name}-%{version}-build
PreReq: %fillup_prereq /bin/rm /bin/mv PreReq: %fillup_prereq /bin/rm /bin/mv
Requires: bzip2 cron Requires: bzip2 cron
@ -63,7 +62,6 @@ Authors:
%patch3 %patch3
%patch4 %patch4
%patch5 %patch5
%patch6
%build %build
make RPM_OPT_FLAGS="$RPM_OPT_FLAGS" WITH_SELINUX=yes make RPM_OPT_FLAGS="$RPM_OPT_FLAGS" WITH_SELINUX=yes
@ -99,6 +97,14 @@ rm -rf $RPM_BUILD_ROOT
%config(noreplace)/etc/logrotate.d/wtmp %config(noreplace)/etc/logrotate.d/wtmp
%changelog %changelog
* Fri Mar 06 2009 puzel@suse.cz
- update to 3.7.8
- do not exit on status file errors
- limit config file inclusion nesting
- use hashes for status file handling
- dateformat to allow unixtime
- manual page corrections
- drop hashes patch (upstream)
* Wed Dec 10 2008 schwab@suse.de * Wed Dec 10 2008 schwab@suse.de
- Fix compresscmd default. - Fix compresscmd default.
* Tue Oct 21 2008 puzel@suse.cz * Tue Oct 21 2008 puzel@suse.cz