new upstream version 3.8.0

removed unused patches
This commit is contained in:
Jan Kaluza 2011-06-21 10:38:42 +02:00
parent c9620107cb
commit ae578d8228
14 changed files with 8 additions and 2676 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
logrotate-3.7.9.tar.gz
/logrotate-3.8.0.tar.gz

View File

@ -1,19 +0,0 @@
Index: /trunk/logrotate.8
===================================================================
--- /trunk/logrotate.8 (revision 285)
+++ /trunk/logrotate.8 (revision 290)
@@ -483,8 +483,11 @@
.BR gzip (1)
+<http://fedorahosted.org/logrotate/>
+
.SH AUTHORS
.nf
-Erik Troan <ewt@redhat.com>
-.nf
-Preston Brown <pbrown@redhat.com>
+Erik Troan, Preston Brown, Jan Kaluza.
+
+<logrotate-owner@fedoraproject.org>
+
.fi

View File

@ -1,161 +0,0 @@
Index: /trunk/logrotate.c
===================================================================
--- /trunk/logrotate.c (revision 296)
+++ /trunk/logrotate.c (revision 299)
@@ -33,4 +33,9 @@
#endif
+#ifdef WITH_ACL
+#include "sys/acl.h"
+static acl_t prev_acl = NULL;
+#endif
+
#include "basenames.h"
#include "log.h"
@@ -317,4 +322,29 @@
return 1;
}
+
+#ifdef WITH_ACL
+ if ((prev_acl = acl_get_fd(inFile)) == NULL) {
+ if (errno != ENOTSUP) {
+ message(MESS_ERROR, "getting file ACL %s: %s\n",
+ name, strerror(errno));
+ close(inFile);
+ close(outFile);
+ return 1;
+ }
+ }
+ if (prev_acl) {
+ if (acl_set_fd(outFile, prev_acl) == -1) {
+ message(MESS_ERROR, "setting ACL for %s: %s\n",
+ compressedName, strerror(errno));
+ acl_free(prev_acl);
+ prev_acl = NULL;
+ close(inFile);
+ close(outFile);
+ return 1;
+ }
+ acl_free(prev_acl);
+ prev_acl = NULL;
+ }
+#endif /* WITH_ACL */
if (!fork()) {
@@ -490,4 +520,14 @@
}
#endif
+#ifdef WITH_ACL
+ if ((prev_acl = acl_get_fd(fdcurr)) == NULL) {
+ if (errno != ENOTSUP) {
+ message(MESS_ERROR, "getting file ACL %s: %s\n",
+ currLog, strerror(errno));
+ close(fdcurr);
+ return 1;
+ }
+ }
+#endif /* WITH_ACL */
fdsave =
createOutputFile(saveLog, O_WRONLY | O_CREAT | O_TRUNC, sb);
@@ -501,6 +541,26 @@
if (fdsave < 0) {
close(fdcurr);
+#ifdef WITH_ACL
+ if (prev_acl)
+ acl_free(prev_acl);
+#endif /* WITH_ACL */
return 1;
}
+#ifdef WITH_ACL
+ if (prev_acl) {
+ if (acl_set_fd(fdsave, prev_acl) == -1) {
+ message(MESS_ERROR, "setting ACL for %s: %s\n",
+ saveLog, strerror(errno));
+ acl_free(prev_acl);
+ prev_acl = NULL;
+ close(fdsave);
+ close(fdcurr);
+ return 1;
+ }
+ acl_free(prev_acl);
+ prev_acl = NULL;
+ }
+#endif /* WITH_ACL */
+
while ((cnt = read(fdcurr, buf, sizeof(buf))) > 0) {
if (write(fdsave, buf, cnt) != cnt) {
@@ -1087,4 +1147,13 @@
}
#endif
+#ifdef WITH_ACL
+ if ((prev_acl = acl_get_file(log->files[logNum], ACL_TYPE_ACCESS)) == NULL) {
+ if (errno != ENOTSUP) {
+ message(MESS_ERROR, "getting file ACL %s: %s\n",
+ log->files[logNum], strerror(errno));
+ hasErrors = 1;
+ }
+ }
+#endif /* WITH_ACL */
message(MESS_DEBUG, "renaming %s to %s\n", log->files[logNum],
rotNames->finalName);
@@ -1134,10 +1203,33 @@
if (!debug) {
+#ifdef WITH_ACL
+ if (prev_acl == NULL && (prev_acl = acl_get_file(log->files[logNum], ACL_TYPE_ACCESS)) == NULL) {
+ if (errno != ENOTSUP) {
+ message(MESS_ERROR, "getting file ACL %s: %s\n",
+ log->files[logNum], strerror(errno));
+ hasErrors = 1;
+ }
+ }
+#endif /* WITH_ACL */
+ if (!hasErrors) {
fd = createOutputFile(log->files[logNum], O_CREAT | O_RDWR,
&sb);
if (fd < 0)
hasErrors = 1;
- else
+ else {
+#ifdef WITH_ACL
+ if (prev_acl) {
+ if (acl_set_fd(fd, prev_acl) == -1) {
+ message(MESS_ERROR, "setting ACL for %s: %s\n",
+ log->files[logNum], strerror(errno));
+ hasErrors = 1;
+ }
+ acl_free(prev_acl);
+ prev_acl = NULL;
+ }
+#endif /* WITH_ACL */
close(fd);
+ }
+ }
}
}
@@ -1156,4 +1248,11 @@
&state->sb, log->flags);
+#ifdef WITH_ACL
+ if (prev_acl) {
+ acl_free(prev_acl);
+ prev_acl = NULL;
+ }
+#endif /* WITH_ACL */
+
}
return hasErrors;
Index: /trunk/Makefile
===================================================================
--- /trunk/Makefile (revision 296)
+++ /trunk/Makefile (revision 299)
@@ -14,4 +14,9 @@
CFLAGS += -DWITH_SELINUX
LOADLIBES += -lselinux
+endif
+
+ifeq ($(WITH_ACL),yes)
+CFLAGS += -DWITH_ACL
+LOADLIBES += -lacl
endif

View File

@ -1,30 +0,0 @@
Index: config.c
===================================================================
--- config.c (revision 321)
+++ config.c (working copy)
@@ -199,19 +199,22 @@
char *endtag, *chptr;
char *start = *startPtr;
char *address;
-
+
if ((endtag = isolateValue(configFile, lineNum, key, startPtr, buf, length)) != NULL) {
chptr = endtag;
- while (*chptr && isprint(*chptr) && *chptr != ' ')
+ while (*chptr && isprint(*chptr) && *chptr != ' ') {
chptr++;
+ }
+
if (*chptr) {
message(MESS_ERROR, "%s:%d bad %s address %s\n",
configFile, lineNum, key, start);
return NULL;
}
- address = strdup(chptr);
+ address = strdup(endtag);
+
free(endtag);
return address;

View File

@ -1,70 +0,0 @@
diff --git a/logrotate.c b/logrotate.c
index 3748918..fbe232a 100644
--- a/logrotate.c
+++ b/logrotate.c
@@ -194,31 +194,41 @@ static int runScript(char *logfn, char *script)
int createOutputFile(char *fileName, int flags, struct stat *sb)
{
int fd;
+ char template[PATH_MAX + 1];
+ mode_t umask_value;
+ snprintf(template, PATH_MAX, "%s/logrotate_temp.XXXXXX", ourDirName(fileName));
+
+ umask_value = umask(0000);
+ fd = mkstemp(template);
+ umask(umask_value);
+
+ if (fd < 0) {
+ message(MESS_ERROR, "error creating unique temp file: %s\n",
+ strerror(errno));
+ return -1;
+ }
+
+ if (fchown(fd, sb->st_uid, sb->st_gid)) {
+ message(MESS_ERROR, "error setting owner of %s: %s\n",
+ fileName, strerror(errno));
+ close(fd);
+ return -1;
+ }
+
+ if (fchmod(fd, sb->st_mode)) {
+ message(MESS_ERROR, "error setting mode of %s: %s\n",
+ fileName, strerror(errno));
+ close(fd);
+ return -1;
+ }
+
+ if (rename(template, fileName)) {
+ message(MESS_ERROR, "error renaming temp file to %s: %s\n",
+ fileName, strerror(errno));
+ close(fd);
+ return -1;
+ }
- fd = open(fileName, flags, sb->st_mode);
- if (fd < 0) {
- message(MESS_ERROR, "error creating output file %s: %s\n",
- fileName, strerror(errno));
- return -1;
- }
- if (fchmod(fd, (S_IRUSR | S_IWUSR) & sb->st_mode)) {
- message(MESS_ERROR, "error setting mode of %s: %s\n",
- fileName, strerror(errno));
- close(fd);
- return -1;
- }
- if (fchown(fd, sb->st_uid, sb->st_gid)) {
- message(MESS_ERROR, "error setting owner of %s: %s\n",
- fileName, strerror(errno));
- close(fd);
- return -1;
- }
- if (fchmod(fd, sb->st_mode)) {
- message(MESS_ERROR, "error setting mode of %s: %s\n",
- fileName, strerror(errno));
- close(fd);
- return -1;
- }
return fd;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,26 +0,0 @@
diff --git a/logrotate.8 b/logrotate.8
index 47749c3..3b0d4df 100644
--- a/logrotate.8
+++ b/logrotate.8
@@ -13,7 +13,7 @@ weekly, monthly, or when it grows too large.
Normally, \fBlogrotate\fR is run as a daily cron job. It will not modify
a log multiple times in one day unless the criterium for that log is
based on the log's size and \fBlogrotate\fR is being run multiple times
-each day, or unless the \fB-f\fR or \fB-force\fR option is used.
+each day, or unless the \fB-f\fR or \fB-\-force\fR option is used.
.P
Any number of config files may be given on the command line. Later config
files may override the options given in earlier files, so the order
@@ -31,7 +31,11 @@ non-zero status.
.SH OPTIONS
.TP
-\fB-d\fR
+\fB-?\fR, \fB-\-help\fR
+Prints help message.
+
+.TP
+\fB-d\fR, \fB-\-debug\fR
Turns on debug mode and implies \fB-v\fR. In debug mode, no changes will
be made to the logs or to the \fBlogrotate\fR state file.

View File

@ -1,13 +0,0 @@
Index: logrotate.8
===================================================================
--- logrotate.8 (revision 293)
+++ logrotate.8 (working copy)
@@ -411,7 +411,7 @@
.TP
\fBsize \fIsize\fR
-Log files are rotated when they grow bigger than \fIsize\fR bytes. If
+Log files are rotated only if they grow bigger then \fIsize\fR bytes. If
\fIsize\fR is followed by \fIk\fR, the size is assumed to be in kilobytes.
If the \fIM\fR is used, the size is in megabytes, and if \fIG\fR is used, the
size is in gigabytes. So \fBsize 100\fR, \fIsize 100k\fR, \fIsize 100M\fR and

View File

@ -1,151 +0,0 @@
Index: logrotate.c
===================================================================
--- logrotate.c (revision 310)
+++ logrotate.c (working copy)
@@ -71,7 +71,7 @@
char *mailCommand = DEFAULT_MAIL_COMMAND;
time_t nowSecs = 0;
-static int shred_file(char *filename, struct logInfo *log);
+static int shred_file(int fd, char *filename, struct logInfo *log);
static int globerr(const char *pathname, int theerr)
{
@@ -231,59 +231,79 @@
return fd;
}
-#define SHRED_CALL "shred -u "
-#define SHRED_COUNT_FLAG "-n "
#define DIGITS 10
+
/* unlink, but try to call shred from GNU fileutils */
-static int shred_file(char *filename, struct logInfo *log)
+static int shred_file(int fd, char *filename, struct logInfo *log)
{
- int len, ret;
- char *cmd;
char count[DIGITS]; /* that's a lot of shredding :) */
+ const char **fullCommand;
+ int id = 0;
+ int status;
if (!(log->flags & LOG_FLAG_SHRED)) {
return unlink(filename);
}
- len = strlen(filename) + strlen(SHRED_CALL);
- len += strlen(SHRED_COUNT_FLAG) + DIGITS;
- cmd = malloc(len);
+ message(MESS_DEBUG, "Using shred to remove the file %s\n", filename);
- if (!cmd) {
- message(MESS_ERROR, "malloc error while shredding");
- return unlink(filename);
+ if (log->shred_cycles != 0) {
+ fullCommand = alloca(sizeof(*fullCommand) * 6);
}
- strcpy(cmd, SHRED_CALL);
+ else {
+ fullCommand = alloca(sizeof(*fullCommand) * 4);
+ }
+ fullCommand[id++] = "shred";
+ fullCommand[id++] = "-u";
+
if (log->shred_cycles != 0) {
- strcat(cmd, SHRED_COUNT_FLAG);
+ fullCommand[id++] = "-n";
snprintf(count, DIGITS - 1, "%d", log->shred_cycles);
- strcat(count, " ");
- strcat(cmd, count);
+ fullCommand[id++] = count;
}
- strcat(cmd, filename);
- ret = system(cmd);
- free(cmd);
- if (ret != 0) {
+ fullCommand[id++] = "-";
+ fullCommand[id++] = NULL;
+
+ if (!fork()) {
+ dup2(fd, 1);
+ close(fd);
+
+ execvp(fullCommand[0], (void *) fullCommand);
+ exit(1);
+ }
+
+ wait(&status);
+
+ if (!WIFEXITED(status) || WEXITSTATUS(status)) {
message(MESS_ERROR, "Failed to shred %s\n, trying unlink", filename);
- if (ret != -1) {
- message(MESS_NORMAL, "Shred returned %d\n", ret);
- }
return unlink(filename);
- } else {
- return ret;
}
+
+ /* We have to unlink it after shred anyway,
+ * because it doesn't remove the file itself */
+ return unlink(filename);
}
static int removeLogFile(char *name, struct logInfo *log)
{
- message(MESS_DEBUG, "removing old log %s\n", name);
+ int fd;
+ message(MESS_DEBUG, "removing old log %s\n", name);
- if (!debug && shred_file(name, log)) {
- message(MESS_ERROR, "Failed to remove old log %s: %s\n",
- name, strerror(errno));
- return 1;
- }
- return 0;
+ if ((fd = open(name, O_RDWR)) < 0) {
+ message(MESS_ERROR, "error opening %s: %s\n",
+ name, strerror(errno));
+ return 1;
+ }
+
+ if (!debug && shred_file(fd, name, log)) {
+ message(MESS_ERROR, "Failed to remove old log %s: %s\n",
+ name, strerror(errno));
+ close(fd);
+ return 1;
+ }
+
+ close(fd);
+ return 0;
}
static int compressLogFile(char *name, struct logInfo *log, struct stat *sb)
@@ -310,7 +330,7 @@
compressedName = alloca(strlen(name) + strlen(log->compress_ext) + 2);
sprintf(compressedName, "%s%s", name, log->compress_ext);
- if ((inFile = open(name, O_RDONLY)) < 0) {
+ if ((inFile = open(name, O_RDWR)) < 0) {
message(MESS_ERROR, "unable to open %s for compression\n", name);
return 1;
}
@@ -357,7 +377,6 @@
exit(1);
}
- close(inFile);
close(outFile);
wait(&status);
@@ -373,7 +392,8 @@
/* If we can't change atime/mtime, it's not a disaster.
It might possibly fail under SELinux. */
- shred_file(name, log);
+ shred_file(inFile, name, log);
+ close(inFile);
return 0;
}

View File

@ -1,96 +0,0 @@
Index: logrotate.c
===================================================================
--- logrotate.c (revision 314)
+++ logrotate.c (working copy)
@@ -45,6 +45,12 @@
#define GLOB_ABORTED GLOB_ABEND
#endif
+#ifdef PATH_MAX
+#define STATEFILE_BUFFER_SIZE 2 * PATH_MAX + 16
+#else
+#define STATEFILE_BUFFER_SIZE 4096
+#endif
+
struct logState {
char *fn;
struct tm lastRotated; /* only tm.mon, tm_mday, tm_year are good! */
@@ -82,6 +88,34 @@
return 1;
}
+static void unescape(char *arg)
+{
+ char *p = arg;
+ char *next;
+ char escaped;
+ while ((next = strchr(p, '\\')) != NULL) {
+
+ p = next;
+
+ switch (p[1]) {
+ case 'n':
+ escaped = '\n';
+ break;
+ case '\\':
+ escaped = '\\';
+ break;
+ default:
+ ++p;
+ continue;
+ }
+
+ /* Overwrite the backslash with the intended character,
+ * and shift everything down one */
+ *p++ = escaped;
+ memmove(p, p+1, 1 + strlen(p+1));
+ }
+}
+
#define HASH_SIZE_MIN 64
static int allocateHash(void)
{
@@ -1546,7 +1580,13 @@
for (chptr = p->fn; *chptr; chptr++) {
switch (*chptr) {
case '"':
+ case '\\':
fputc('\\', f);
+ break;
+ case '\n':
+ fputc('\\', f);
+ fputc('n', f);
+ continue;
}
fputc(*chptr, f);
@@ -1567,7 +1607,8 @@
static int readState(char *stateFilename)
{
FILE *f;
- char buf[1024];
+ char buf[STATEFILE_BUFFER_SIZE];
+ char *filename;
const char **argv;
int argc;
int year, month, day;
@@ -1678,7 +1719,10 @@
year -= 1900, month -= 1;
- if ((st = findState(argv[0])) == NULL)
+ filename = strdup(argv[0]);
+ unescape(filename);
+
+ if ((st = findState(filename)) == NULL)
return 1;
st->lastRotated.tm_mon = month;
@@ -1690,6 +1734,7 @@
st->lastRotated = *localtime(&lr_time);
free(argv);
+ free(filename);
}
fclose(f);

View File

@ -1,33 +0,0 @@
Index: logrotate.c
===================================================================
--- logrotate.c (revision 323)
+++ logrotate.c (working copy)
@@ -1323,15 +1323,6 @@
(int) sb.st_uid, (int) sb.st_gid);
if (!debug) {
-#ifdef WITH_ACL
- if (prev_acl == NULL && (prev_acl = acl_get_file(log->files[logNum], ACL_TYPE_ACCESS)) == NULL) {
- if (errno != ENOTSUP) {
- message(MESS_ERROR, "getting file ACL %s: %s\n",
- log->files[logNum], strerror(errno));
- hasErrors = 1;
- }
- }
-#endif /* WITH_ACL */
if (!hasErrors) {
fd = createOutputFile(log->files[logNum], O_CREAT | O_RDWR,
&sb);
@@ -1363,10 +1354,11 @@
#endif
if (!hasErrors
- && log->flags & (LOG_FLAG_COPYTRUNCATE | LOG_FLAG_COPY))
+ && log->flags & (LOG_FLAG_COPYTRUNCATE | LOG_FLAG_COPY)) {
hasErrors =
copyTruncate(log->files[logNum], rotNames->finalName,
&state->sb, log->flags);
+ }
#ifdef WITH_ACL
if (prev_acl) {

View File

@ -1,28 +0,0 @@
diff --git a/config.c b/config.c
index 76c0df6..399fdf4 100644
--- a/config.c
+++ b/config.c
@@ -956,18 +956,17 @@ static int readConfigFile(const char *configFile, struct logInfo *defConfig)
free(key);
if ((key = isolateValue(configFile, lineNum, "tabooext", &start,
&buf, length)) != NULL) {
-
- if (*key == '+') {
- key++;
- while (isspace(*key) && *key)
- key++;
+ endtag = key;
+ if (*endtag == '+') {
+ endtag++;
+ while (isspace(*endtag) && *endtag)
+ endtag++;
} else {
free_2d_array(tabooExts, tabooCount);
tabooCount = 0;
tabooExts = malloc(1);
}
- endtag = key;
while (*endtag) {
chptr = endtag;
while (!isspace(*chptr) && *chptr != ',' && *chptr)

View File

@ -1,22 +1,11 @@
Summary: Rotates, compresses, removes and mails system log files
Name: logrotate
Version: 3.7.9
Release: 11%{?dist}
Version: 3.8.0
Release: 1%{?dist}
License: GPL+
Group: System Environment/Base
Url: https://fedorahosted.org/logrotate/
Source: https://fedorahosted.org/releases/l/o/logrotate/logrotate-%{version}.tar.gz
Patch1: logrotate-3.7.8-man-authors.patch
Patch2: logrotate-3.7.9-man-size.patch
Patch3: logrotate-3.7.9-man-page.patch
Patch4: logrotate-3.7.9-config.patch
Patch5: logrotate-3.7.9-acl.patch
Patch6: logrotate-3.7.9-tabooext.patch
Patch7: logrotate-3.7.9-shred.patch
Patch8: logrotate-3.7.9-statefile.patch
Patch9: logrotate-3.7.9-atomic-create.patch
Patch10: logrotate-3.7.9-address-parsing.patch
Patch11: logrotate-3.7.9-support-no-acls.patch
Requires: coreutils >= 5.92 libsepol libselinux popt libacl
BuildRequires: libselinux-devel popt-devel libacl-devel
@ -35,17 +24,6 @@ log files on your system.
%prep
%setup -q
%patch1 -p2
%patch2
%patch3 -p1
%patch4
%patch5 -p2
%patch6 -p1
%patch7
%patch8
%patch9 -p1
%patch10
%patch11
%build
make %{?_smp_mflags} RPM_OPT_FLAGS="$RPM_OPT_FLAGS" WITH_SELINUX=yes WITH_ACL=yes
@ -76,6 +54,10 @@ rm -rf $RPM_BUILD_ROOT
%attr(0644, root, root) %verify(not size md5 mtime) %config(noreplace) %{_localstatedir}/lib/logrotate.status
%changelog
* Tue Jun 21 2011 Jan Kaluza <jkaluza@redhat.com> 3.8.0-1
- new upstream version 3.8.0
- removed unused patches
* Tue May 31 2011 Jan Kaluza <jkaluza@redhat.com> 3.7.9-11
- fix #709034 - work properly when ACLs are not supported

View File

@ -1 +1 @@
eeba9dbca62a9210236f4b83195e4ea5 logrotate-3.7.9.tar.gz
590f77c13077a4c384dbec7ca9c5f242 logrotate-3.8.0.tar.gz