156 lines
5.9 KiB
Diff
156 lines
5.9 KiB
Diff
--- logrotate-3.7.5/logrotate.c.errorHandling 2007-03-01 12:05:30.000000000 +0100
|
|
+++ logrotate-3.7.5/logrotate.c 2007-03-31 12:50:33.000000000 +0200
|
|
@@ -1043,6 +1043,8 @@
|
|
message(MESS_ERROR, "error running first action script "
|
|
"for %s\n", log->pattern);
|
|
hasErrors = 1;
|
|
+ /* finish early, firstaction failed, affects all logs in set */
|
|
+ return hasErrors;
|
|
}
|
|
}
|
|
}
|
|
@@ -1067,16 +1069,25 @@
|
|
hasErrors |= logHasErrors[i];
|
|
}
|
|
|
|
- if (log->pre) {
|
|
+ if (log->pre
|
|
+ && (! ( (logHasErrors[j] && !(log->flags & LOG_FLAG_SHAREDSCRIPTS))
|
|
+ || (hasErrors && (log->flags & LOG_FLAG_SHAREDSCRIPTS)) ) )) {
|
|
if (!numRotated) {
|
|
message(MESS_DEBUG, "not running prerotate script, "
|
|
"since no logs will be rotated\n");
|
|
} else {
|
|
message(MESS_DEBUG, "running prerotate script\n");
|
|
if (runScript(log->pattern, log->pre)) {
|
|
- message(MESS_ERROR,
|
|
- "error running shared prerotate script "
|
|
- "for %s\n", log->pattern);
|
|
+ if (log->flags & LOG_FLAG_SHAREDSCRIPTS)
|
|
+ message(MESS_ERROR,
|
|
+ "error running shared prerotate script "
|
|
+ "for '%s'\n", log->pattern);
|
|
+ else {
|
|
+ message(MESS_ERROR,
|
|
+ "error running non-shared prerotate script "
|
|
+ "for %s of '%s'\n", log->files[j], log->pattern);
|
|
+ }
|
|
+ logHasErrors[j] = 1;
|
|
hasErrors = 1;
|
|
}
|
|
}
|
|
@@ -1085,22 +1096,33 @@
|
|
for (i = j;
|
|
((log->flags & LOG_FLAG_SHAREDSCRIPTS) && i < log->numFiles)
|
|
|| (!(log->flags & LOG_FLAG_SHAREDSCRIPTS) && i == j); i++) {
|
|
- if (!logHasErrors[i]) {
|
|
+ if (! ( (logHasErrors[i] && !(log->flags & LOG_FLAG_SHAREDSCRIPTS))
|
|
+ || (hasErrors && (log->flags & LOG_FLAG_SHAREDSCRIPTS)) ) ) {
|
|
logHasErrors[i] |=
|
|
rotateSingleLog(log, i, state[i], rotNames[i]);
|
|
hasErrors |= logHasErrors[i];
|
|
}
|
|
}
|
|
|
|
- if (log->post) {
|
|
+ if (log->post
|
|
+ && (! ( (logHasErrors[j] && !(log->flags & LOG_FLAG_SHAREDSCRIPTS))
|
|
+ || (hasErrors && (log->flags & LOG_FLAG_SHAREDSCRIPTS)) ) )) {
|
|
if (!numRotated) {
|
|
message(MESS_DEBUG, "not running postrotate script, "
|
|
"since no logs were rotated\n");
|
|
} else {
|
|
message(MESS_DEBUG, "running postrotate script\n");
|
|
if (runScript(log->pattern, log->post)) {
|
|
- message(MESS_ERROR, "error running postrotate script "
|
|
- "for %s\n", log->pattern);
|
|
+ if (log->flags & LOG_FLAG_SHAREDSCRIPTS)
|
|
+ message(MESS_ERROR,
|
|
+ "error running shared postrotate script "
|
|
+ "for '%s'\n", log->pattern);
|
|
+ else {
|
|
+ message(MESS_ERROR,
|
|
+ "error running non-shared postrotate script "
|
|
+ "for %s of '%s'\n", log->files[j], log->pattern);
|
|
+ }
|
|
+ logHasErrors[j] = 1;
|
|
hasErrors = 1;
|
|
}
|
|
}
|
|
@@ -1109,7 +1131,8 @@
|
|
for (i = j;
|
|
((log->flags & LOG_FLAG_SHAREDSCRIPTS) && i < log->numFiles)
|
|
|| (!(log->flags & LOG_FLAG_SHAREDSCRIPTS) && i == j); i++) {
|
|
- if (!logHasErrors[i]) {
|
|
+ if (! ( (logHasErrors[i] && !(log->flags & LOG_FLAG_SHAREDSCRIPTS))
|
|
+ || (hasErrors && (log->flags & LOG_FLAG_SHAREDSCRIPTS)) ) ) {
|
|
logHasErrors[i] |=
|
|
postrotateSingleLog(log, i, state[i], rotNames[i]);
|
|
hasErrors |= logHasErrors[i];
|
|
--- logrotate-3.7.5/logrotate.8.errorHandling 2006-05-17 16:46:51.000000000 +0200
|
|
+++ logrotate-3.7.5/logrotate.8 2007-03-31 12:37:06.000000000 +0200
|
|
@@ -326,7 +326,8 @@
|
|
\fBnosharedscripts\fR
|
|
Run \fBprerotate\fR and \fBpostrotate\fR scripts for every log file which
|
|
is rotated (this is the default, and overrides the \fBsharedscripts\fR
|
|
-option).
|
|
+option). If the scripts exit with error, the remaining actions will
|
|
+not be executed for the affected log only.
|
|
|
|
.TP
|
|
\fBnotifempty\fR
|
|
@@ -346,7 +347,8 @@
|
|
The lines between \fBpostrotate\fR and \fBendscript\fR (both of which
|
|
must appear on lines by themselves) are executed after the log file is
|
|
rotated. These directives may only appear inside of a log file definition.
|
|
-See \fBprerotate\fR as well.
|
|
+See \fBprerotate\fR as well. See \fBsharedscripts\fR and
|
|
+\fBnosharedscripts\fR for error handling.
|
|
|
|
.TP
|
|
\fBprerotate\fR/\fBendscript\fR
|
|
@@ -354,7 +356,8 @@
|
|
must appear on lines by themselves) are executed before the log file is
|
|
rotated and only if the log will actually be rotated. These directives
|
|
may only appear inside of a log file definition. See \fBpostrotate\fR
|
|
-as well.
|
|
+as well. See \fBsharedscripts\fR and \fBnosharedscripts\fR for error
|
|
+handling.
|
|
|
|
.TP
|
|
\fBfirstaction\fR/\fBendscript\fR
|
|
@@ -362,7 +365,8 @@
|
|
must appear on lines by themselves) are executed once before all log
|
|
files that match the wildcarded pattern are rotated, before prerotate script
|
|
is run and only if at least one log will actually be rotated. These directives
|
|
-may only appear inside of a log file definition. See \fBlastaction\fR as well.
|
|
+may only appear inside of a log file definition. If the script exits
|
|
+with error, no further processing is done. See \fBlastaction\fR as well.
|
|
|
|
.TP
|
|
\fBlastaction\fR/\fBendscript\fR
|
|
@@ -370,7 +374,9 @@
|
|
must appear on lines by themselves) are executed once after all log
|
|
files that match the wildcarded pattern are rotated, after postrotate script
|
|
is run and only if at least one log is rotated. These directives may only
|
|
-appear inside of a log file definition. See \fBfirstaction\fR as well.
|
|
+appear inside of a log file definition. If the script exits with
|
|
+error, just an error message is shown (as this is the last
|
|
+action). See \fBfirstaction\fR as well.
|
|
|
|
.TP
|
|
\fBrotate \fIcount\fR
|
|
@@ -393,8 +399,10 @@
|
|
/var/log/news/* example). If \fBsharedscript\fR is specified, the scripts
|
|
are only run once, no matter how many logs match the wildcarded pattern.
|
|
However, if none of the logs in the pattern require rotating, the scripts
|
|
-will not be run at all. This option overrides the \fBnosharedscripts\fR
|
|
-option and implies \fBcreate\fR option.
|
|
+will not be run at all. If the scripts exit with error, the remaining
|
|
+actions will not be executed for any logs. This option overrides the
|
|
+\fBnosharedscripts\fR option and implies \fBcreate\fR option.
|
|
+
|
|
|
|
.TP
|
|
\fBstart \fIcount\fR
|