mirror of
https://git.FreeBSD.org/src.git
synced 2025-02-08 08:27:00 +00:00
Fix age_old_log checking so that it will notice log files which were
rotated and then compressed with bzip2 instead of gzip. Otherwise, any file which had a time-interval specified for 'when' and also specified the 'J' flag would be rotated every time newsyslog was run. (this is a quick-fix, trying to beat the code-freeze for 5.1-release) PR: bin/51519 MFC after: 1 week
This commit is contained in:
parent
8d5c19ffbc
commit
4adea93613
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=114764
@ -1468,7 +1468,9 @@ static int
|
||||
age_old_log(char *file)
|
||||
{
|
||||
struct stat sb;
|
||||
char tmp[MAXPATHLEN + sizeof(".0") + sizeof(COMPRESS_POSTFIX) + 1];
|
||||
char *endp;
|
||||
char tmp[MAXPATHLEN + sizeof(".0") + sizeof(COMPRESS_POSTFIX) +
|
||||
sizeof(BZCOMPRESS_POSTFIX) + 1];
|
||||
|
||||
if (archtodir) {
|
||||
char *p;
|
||||
@ -1497,9 +1499,22 @@ age_old_log(char *file)
|
||||
(void) strlcpy(tmp, file, sizeof(tmp));
|
||||
}
|
||||
|
||||
if (stat(strcat(tmp, ".0"), &sb) < 0)
|
||||
if (stat(strcat(tmp, COMPRESS_POSTFIX), &sb) < 0)
|
||||
return (-1);
|
||||
strlcat(tmp, ".0", sizeof(tmp));
|
||||
if (stat(tmp, &sb) < 0) {
|
||||
/*
|
||||
* A plain '.0' file does not exist. Try again, first
|
||||
* with the added suffix of '.gz', then with an added
|
||||
* suffix of '.bz2' instead of '.gz'.
|
||||
*/
|
||||
endp = strchr(tmp, '\0');
|
||||
strlcat(tmp, COMPRESS_POSTFIX, sizeof(tmp));
|
||||
if (stat(tmp, &sb) < 0) {
|
||||
*endp = '\0'; /* Remove .gz */
|
||||
strlcat(tmp, BZCOMPRESS_POSTFIX, sizeof(tmp));
|
||||
if (stat(tmp, &sb) < 0)
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
return ((int)(timenow - sb.st_mtime + 1800) / 3600);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user