Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package logrotate for openSUSE:Factory checked in at 2021-06-01 10:33:35 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/logrotate (Old) and /work/SRC/openSUSE:Factory/.logrotate.new.1898 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "logrotate" Tue Jun 1 10:33:35 2021 rev:68 rq:895944 version:3.18.1 Changes: -------- --- /work/SRC/openSUSE:Factory/logrotate/logrotate.changes 2021-02-11 12:48:16.865566948 +0100 +++ /work/SRC/openSUSE:Factory/.logrotate.new.1898/logrotate.changes 2021-06-01 10:33:48.140439232 +0200 @@ -1,0 +2,9 @@ +Thu May 27 16:31:55 UTC 2021 - Dirk M??ller <dmuel...@suse.com> + +- update to 3.18.1: + * fix memory leaks on error-handling paths + * make `renamecopy` and `copytruncate` override each other + * improve error handling in the parser of configuration files + * improve user experience for non-privileged users of logrotate + +------------------------------------------------------------------- Old: ---- logrotate-3.18.0.tar.xz logrotate-3.18.0.tar.xz.asc New: ---- logrotate-3.18.1.tar.xz logrotate-3.18.1.tar.xz.asc ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ logrotate.spec ++++++ --- /var/tmp/diff_new_pack.wRZETJ/_old 2021-06-01 10:33:48.560439947 +0200 +++ /var/tmp/diff_new_pack.wRZETJ/_new 2021-06-01 10:33:48.560439947 +0200 @@ -17,17 +17,17 @@ Name: logrotate -Version: 3.18.0 +Version: 3.18.1 Release: 0 Summary: Cron service for rotating, compressing, mailing and removing system log files License: GPL-2.0-or-later Group: System/Base URL: https://github.com/logrotate/logrotate Source0: https://github.com/%{name}/%{name}/releases/download/%{version}/%{name}-%{version}.tar.xz -Source10: https://github.com/%{name}/%{name}/releases/download/%{version}/%{name}-%{version}.tar.xz.asc # SUSE specific logrotate configurations Source1: logrotate.wtmp Source2: logrotate.default +Source10: https://github.com/%{name}/%{name}/releases/download/%{version}/%{name}-%{version}.tar.xz.asc Source100: %{name}-rpmlintrc Patch0: logrotate-3.13.0-systemd_add_home_env.patch BuildRequires: acl @@ -36,7 +36,7 @@ BuildRequires: pkgconfig(libselinux) BuildRequires: pkgconfig(popt) BuildRequires: pkgconfig(systemd) >= 197 -Requires: /usr/bin/xz +Requires: %{_bindir}/xz %{?systemd_ordering} %description @@ -56,10 +56,10 @@ --disable-silent-rules \ --with-state-file-path=%{_localstatedir}/lib/misc/logrotate.status \ --disable-werror -make %{?_smp_mflags} +%make_build %check -make %{?_smp_mflags} check +%make_build check %install %make_install @@ -94,8 +94,8 @@ %doc ChangeLog.md README.md %{_sbindir}/logrotate %{_sbindir}/rc%{name} -%{_mandir}/man8/logrotate.8* -%{_mandir}/man5/logrotate.conf.5* +%{_mandir}/man8/logrotate.8%{?ext_man} +%{_mandir}/man5/logrotate.conf.5%{?ext_man} %config %{_sysconfdir}/logrotate.conf %config(noreplace) %{_sysconfdir}/logrotate.d/wtmp %{_unitdir}/%{name}.service ++++++ logrotate-3.18.0.tar.xz -> logrotate-3.18.1.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logrotate-3.18.0/.tarball-version new/logrotate-3.18.1/.tarball-version --- old/logrotate-3.18.0/.tarball-version 2021-01-08 08:34:25.000000000 +0100 +++ new/logrotate-3.18.1/.tarball-version 2021-05-21 15:39:05.000000000 +0200 @@ -1 +1 @@ -3.18.0 +3.18.1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logrotate-3.18.0/.version new/logrotate-3.18.1/.version --- old/logrotate-3.18.0/.version 2021-01-08 08:34:25.000000000 +0100 +++ new/logrotate-3.18.1/.version 2021-05-21 15:39:05.000000000 +0200 @@ -1 +1 @@ -3.18.0 +3.18.1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logrotate-3.18.0/ChangeLog.md new/logrotate-3.18.1/ChangeLog.md --- old/logrotate-3.18.0/ChangeLog.md 2021-01-08 08:19:35.000000000 +0100 +++ new/logrotate-3.18.1/ChangeLog.md 2021-05-21 12:39:41.000000000 +0200 @@ -4,7 +4,15 @@ ## [UNRELEASED] -[UNRELEASED]: https://github.com/logrotate/logrotate/compare/3.18.0...master +[UNRELEASED]: https://github.com/logrotate/logrotate/compare/3.18.1...master + +## [3.18.1] - 2021-05-21 + - fix memory leaks on error-handling paths (#383, #387) + - make `renamecopy` and `copytruncate` override each other (#386) + - improve error handling in the parser of configuration files (#383) + - improve user experience for non-privileged users of logrotate (#372) + +[3.18.1]: https://github.com/logrotate/logrotate/compare/3.18.0...3.18.1 ## [3.18.0] - 2021-01-08 - allow UIDs and GIDs to be specified numerically (#217) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logrotate-3.18.0/README.md new/logrotate-3.18.1/README.md --- old/logrotate-3.18.0/README.md 2021-01-08 08:14:37.000000000 +0100 +++ new/logrotate-3.18.1/README.md 2021-05-21 12:29:35.000000000 +0200 @@ -6,10 +6,11 @@ The latest release is: -* [logrotate-3.18.0](https://github.com/logrotate/logrotate/releases/download/3.18.0/logrotate-3.18.0.tar.xz) ([sig](https://github.com/logrotate/logrotate/releases/download/3.18.0/logrotate-3.18.0.tar.xz.asc)) ([Changelog](https://github.com/logrotate/logrotate/releases/tag/3.18.0)) +* [logrotate-3.18.1](https://github.com/logrotate/logrotate/releases/download/3.18.1/logrotate-3.18.1.tar.xz) ([sig](https://github.com/logrotate/logrotate/releases/download/3.18.1/logrotate-3.18.1.tar.xz.asc)) ([Changelog](https://github.com/logrotate/logrotate/releases/tag/3.18.1)) Previous releases: +* [logrotate-3.18.0](https://github.com/logrotate/logrotate/releases/download/3.18.0/logrotate-3.18.0.tar.xz) ([sig](https://github.com/logrotate/logrotate/releases/download/3.18.0/logrotate-3.18.0.tar.xz.asc)) ([Changelog](https://github.com/logrotate/logrotate/releases/tag/3.18.0)) * [logrotate-3.17.0](https://github.com/logrotate/logrotate/releases/download/3.17.0/logrotate-3.17.0.tar.xz) ([sig](https://github.com/logrotate/logrotate/releases/download/3.17.0/logrotate-3.17.0.tar.xz.asc)) ([Changelog](https://github.com/logrotate/logrotate/releases/tag/3.17.0)) * [logrotate-3.16.0](https://github.com/logrotate/logrotate/releases/download/3.16.0/logrotate-3.16.0.tar.xz) ([sig](https://github.com/logrotate/logrotate/releases/download/3.16.0/logrotate-3.16.0.tar.xz.asc)) ([Changelog](https://github.com/logrotate/logrotate/releases/tag/3.16.0)) * [logrotate-3.15.1](https://github.com/logrotate/logrotate/releases/download/3.15.1/logrotate-3.15.1.tar.xz) ([sig](https://github.com/logrotate/logrotate/releases/download/3.15.1/logrotate-3.15.1.tar.xz.asc)) ([Changelog](https://github.com/logrotate/logrotate/releases/tag/3.15.1)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logrotate-3.18.0/config.c new/logrotate-3.18.1/config.c --- old/logrotate-3.18.0/config.c 2021-01-05 14:01:16.000000000 +0100 +++ new/logrotate-3.18.1/config.c 2021-05-21 12:28:13.000000000 +0200 @@ -12,7 +12,6 @@ #include <stdlib.h> #include <string.h> #include <sys/stat.h> -#include <time.h> #include <unistd.h> #include <assert.h> #include <wchar.h> @@ -61,24 +60,20 @@ va_start(arg, format); size = vsnprintf(NULL, 0, format, arg); - size++; va_end(arg); - va_start(arg, format); - str = malloc(size); + if (size < 0) { + return -1; + } + str = malloc((size_t)size + 1); if (str == NULL) { - va_end(arg); - /* - * Strictly speaking, GNU asprintf doesn't do this, - * but the caller isn't checking the return value. - */ - message_OOM(); - exit(1); + return -1; } - rv = vsnprintf(str, size, format, arg); + va_start(arg, format); + rv = vsnprintf(str, (size_t)size + 1, format, arg); va_end(arg); *string_ptr = str; - return (rv); + return rv; } #endif @@ -315,7 +310,7 @@ return -1; } -static int readModeUidGid(const char *configFile, int lineNum, char *key, +static int readModeUidGid(const char *configFile, int lineNum, const char *key, const char *directive, mode_t *mode, uid_t *pUid, gid_t *pGid) { @@ -815,21 +810,19 @@ for (i = 0; i < defTabooCount; i++) { - int bytes; char *pattern = NULL; /* generate a pattern by concatenating star (wildcard) to the * suffix literal */ - bytes = asprintf(&pattern, "*%s", defTabooExts[i]); - if (bytes != -1) { - tabooPatterns[i] = pattern; - tabooCount++; - } else { + if (asprintf(&pattern, "*%s", defTabooExts[i]) < 0) { free_2d_array(tabooPatterns, tabooCount); message_OOM(); return 1; } + + tabooPatterns[i] = pattern; + tabooCount++; } for (file = paths; *file; file++) { @@ -943,12 +936,14 @@ newlog->what = NULL; \ } while (0) #define RAISE_ERROR() \ - if (newlog != defConfig) { \ - state = STATE_ERROR; \ - goto next_state; \ - } else { \ - goto error; \ - } + do { \ + if (newlog != defConfig) { \ + state = STATE_ERROR; \ + goto next_state; \ + } else { \ + goto error; \ + } \ + } while(0) #define MAX_NESTING 16U static int readConfigFile(const char *configFile, struct logInfo *defConfig) @@ -969,6 +964,9 @@ static unsigned recursion_depth = 0U; char *globerr_msg = NULL; int in_config = 0; +#ifdef HAVE_MADVISE + int r; +#endif struct flock fd_lock = { .l_start = 0, .l_len = 0, @@ -1011,7 +1009,7 @@ if (getuid() == ROOT_UID) { if ((sb.st_mode & 07533) != 0400) { - message(MESS_DEBUG, + message(MESS_NORMAL, "Potentially dangerous mode on %s: 0%o\n", configFile, (unsigned) (sb.st_mode & 07777)); } @@ -1068,12 +1066,14 @@ #ifdef HAVE_MADVISE #ifdef MADV_DONTFORK - madvise(buf, length + 2, - MADV_SEQUENTIAL | MADV_WILLNEED | MADV_DONTFORK); + r = madvise(buf, length, MADV_SEQUENTIAL | MADV_WILLNEED | MADV_DONTFORK); #else /* MADV_DONTFORK */ - madvise(buf, length + 2, - MADV_SEQUENTIAL | MADV_WILLNEED); + r = madvise(buf, length, MADV_SEQUENTIAL | MADV_WILLNEED); #endif /* MADV_DONTFORK */ + if (r < 0) { + message(MESS_DEBUG, "Failed to advise use of memory: %s\n", + strerror(errno)); + } #endif /* HAVE_MADVISE */ message(MESS_DEBUG, "reading config file %s\n", configFile); @@ -1092,8 +1092,16 @@ if (isalpha((unsigned char)*start)) { free(key); key = isolateWord(&start, &buf, length); - if (key == NULL) + if (key == NULL) { + message(MESS_ERROR, "%s:%d failed to parse keyword\n", + configFile, lineNum); continue; + } + if (!isspace((unsigned char)*start)) { + message(MESS_NORMAL, "%s:%d keyword '%s' not properly" + " separated, found %#x\n", + configFile, lineNum, key, *start); + } if (!strcmp(key, "compress")) { newlog->flags |= LOG_FLAG_COMPRESS; } else if (!strcmp(key, "nocompress")) { @@ -1112,10 +1120,12 @@ newlog->flags &= ~LOG_FLAG_SHAREDSCRIPTS; } else if (!strcmp(key, "copytruncate")) { newlog->flags |= LOG_FLAG_COPYTRUNCATE; + newlog->flags &= ~LOG_FLAG_TMPFILENAME; } else if (!strcmp(key, "nocopytruncate")) { newlog->flags &= ~LOG_FLAG_COPYTRUNCATE; } else if (!strcmp(key, "renamecopy")) { newlog->flags |= LOG_FLAG_TMPFILENAME; + newlog->flags &= ~LOG_FLAG_COPYTRUNCATE; } else if (!strcmp(key, "norenamecopy")) { newlog->flags &= ~LOG_FLAG_TMPFILENAME; } else if (!strcmp(key, "copy")) { @@ -1136,11 +1146,11 @@ newlog->flags |= LOG_FLAG_DATEHOURAGO; } else if (!strcmp(key, "dateformat")) { freeLogItem(dateformat); - newlog->dateformat = isolateLine(&start, &buf, length); - if (newlog->dateformat == NULL) - continue; + newlog->dateformat = isolateValue(configFile, lineNum, + key, &start, &buf, + length); } else if (!strcmp(key, "noolddir")) { - newlog->oldDir = NULL; + freeLogItem(oldDir); } else if (!strcmp(key, "mailfirst")) { newlog->flags |= LOG_FLAG_MAILFIRST; } else if (!strcmp(key, "maillast")) { @@ -1150,8 +1160,11 @@ mode_t tmp_mode = NO_MODE; free(key); key = isolateLine(&start, &buf, length); - if (key == NULL) - continue; + if (key == NULL) { + message(MESS_ERROR, "%s:%d failed to parse su option value\n", + configFile, lineNum); + RAISE_ERROR(); + } rv = readModeUidGid(configFile, lineNum, key, "su", &tmp_mode, &newlog->suUid, @@ -1264,13 +1277,14 @@ free(key); key = isolateValue(configFile, lineNum, "shred cycles", &start, &buf, length); - if (key == NULL) - continue; + if (key == NULL) { + RAISE_ERROR(); + } newlog->shred_cycles = (int)strtoul(key, &chptr, 0); if (*chptr || newlog->shred_cycles < 0) { message(MESS_ERROR, "%s:%d bad shred cycles '%s'\n", configFile, lineNum, key); - goto error; + RAISE_ERROR(); } } else if (!strcmp(key, "hourly")) { set_criterium(&newlog->criterium, ROT_HOURLY, &criterium_set); @@ -1305,8 +1319,9 @@ free(key); key = isolateValue(configFile, lineNum, "rotate count", &start, &buf, length); - if (key == NULL) - continue; + if (key == NULL) { + RAISE_ERROR(); + } newlog->rotateCount = (int)strtol(key, &chptr, 0); if (*chptr || newlog->rotateCount < -1) { message(MESS_ERROR, @@ -1318,8 +1333,9 @@ free(key); key = isolateValue(configFile, lineNum, "start count", &start, &buf, length); - if (key == NULL) - continue; + if (key == NULL) { + RAISE_ERROR(); + } newlog->logStart = (int)strtoul(key, &chptr, 0); if (*chptr || newlog->logStart < 0) { message(MESS_ERROR, "%s:%d bad start count '%s'\n", @@ -1330,8 +1346,9 @@ free(key); key = isolateValue(configFile, lineNum, "minage count", &start, &buf, length); - if (key == NULL) - continue; + if (key == NULL) { + RAISE_ERROR(); + } newlog->rotateMinAge = (int)strtoul(key, &chptr, 0); if (*chptr || newlog->rotateMinAge < 0) { message(MESS_ERROR, "%s:%d bad minimum age '%s'\n", @@ -1342,8 +1359,9 @@ free(key); key = isolateValue(configFile, lineNum, "maxage count", &start, &buf, length); - if (key == NULL) - continue; + if (key == NULL) { + RAISE_ERROR(); + } newlog->rotateAge = (int)strtoul(key, &chptr, 0); if (*chptr || newlog->rotateAge < 0) { message(MESS_ERROR, "%s:%d bad maximum age '%s'\n", @@ -1351,7 +1369,7 @@ RAISE_ERROR(); } } else if (!strcmp(key, "errors")) { - message(MESS_DEBUG, + message(MESS_NORMAL, "%s: %d: the errors directive is deprecated and no longer used.\n", configFile, lineNum); } else if (!strcmp(key, "mail")) { @@ -1360,7 +1378,6 @@ "mail", &start, &buf, length))) { RAISE_ERROR(); } - else continue; } else if (!strcmp(key, "nomail")) { freeLogItem(logAddress); } else if (!strcmp(key, "missingok")) { @@ -1421,7 +1438,6 @@ } while (*endtag) { - int bytes; char *pattern = NULL; chptr = endtag; @@ -1437,10 +1453,11 @@ RAISE_ERROR(); } tabooPatterns = tmp; - bytes = asprintf(&pattern, "*%.*s", (int)(chptr - endtag), endtag); + if (asprintf(&pattern, "*%.*s", (int)(chptr - endtag), endtag) < 0) { + message_OOM(); + RAISE_ERROR(); + } - /* should test for malloc() failure */ - assert(bytes != -1); tabooPatterns[tabooCount] = pattern; tabooCount++; } @@ -1481,7 +1498,6 @@ } while (*endtag) { - int bytes; char *pattern = NULL; char **tmp; @@ -1496,10 +1512,11 @@ RAISE_ERROR(); } tabooPatterns = tmp; - bytes = asprintf(&pattern, "%.*s", (int)(chptr - endtag), endtag); + if (asprintf(&pattern, "%.*s", (int)(chptr - endtag), endtag) < 0) { + message_OOM(); + RAISE_ERROR(); + } - /* should test for malloc() failure */ - assert(bytes != -1); tabooPatterns[tabooCount] = pattern; tabooCount++; @@ -1515,8 +1532,9 @@ free(key); key = isolateValue(configFile, lineNum, "include", &start, &buf, length); - if (key == NULL) - continue; + if (key == NULL) { + RAISE_ERROR(); + } if (key[0] == '~' && key[1] == '/') { /* replace '~' with content of $HOME cause low-level functions @@ -1540,7 +1558,7 @@ env_home = pwd->pw_dir; } - if (asprintf(&new_key, "%s/%s", env_home, key + 2) == -1) { + if (asprintf(&new_key, "%s/%s", env_home, key + 2) < 0) { message_OOM(); RAISE_ERROR(); } @@ -1578,8 +1596,9 @@ free(key); key = isolateValue(configFile, lineNum, "extension name", &start, &buf, length); - if (key == NULL) - continue; + if (key == NULL) { + RAISE_ERROR(); + } freeLogItem (extension); newlog->extension = key; key = NULL; @@ -1589,8 +1608,9 @@ free(key); key = isolateValue(configFile, lineNum, "addextension name", &start, &buf, length); - if (key == NULL) - continue; + if (key == NULL) { + RAISE_ERROR(); + } freeLogItem (addextension); newlog->addextension = key; key = NULL; @@ -1892,13 +1912,12 @@ continue; } } - ld = malloc(strlen(dirName) + strlen(newlog->oldDir) + 2); - if (ld == NULL) { + if (asprintf(&ld, "%s/%s", dirName, newlog->oldDir) < 0) { message_OOM(); free(dirpath); goto error; } - sprintf(ld, "%s/%s", dirName, newlog->oldDir); + free(dirpath); if (newlog->oldDir[0] != '/') { @@ -2072,8 +2091,8 @@ break; default: message(MESS_FATAL, - "%s: %d: readConfigFile() unknown state\n", - configFile, lineNum); + "%s: %d: readConfigFile() unknown state: %#x\n", + configFile, lineNum, state); } if (*start == '\n') { lineNum++; @@ -2093,12 +2112,14 @@ munmap(buf, length); close(fd); + free(globerr_msg); return logerror; error: /* free is a NULL-safe operation */ free(key); munmap(buf, length); close(fd); + free(globerr_msg); return 1; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logrotate-3.18.0/configure new/logrotate-3.18.1/configure --- old/logrotate-3.18.0/configure 2021-01-08 08:34:18.000000000 +0100 +++ new/logrotate-3.18.1/configure 2021-05-21 15:39:03.000000000 +0200 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for logrotate 3.18.0. +# Generated by GNU Autoconf 2.69 for logrotate 3.18.1. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -577,8 +577,8 @@ # Identity of this package. PACKAGE_NAME='logrotate' PACKAGE_TARNAME='logrotate' -PACKAGE_VERSION='3.18.0' -PACKAGE_STRING='logrotate 3.18.0' +PACKAGE_VERSION='3.18.1' +PACKAGE_STRING='logrotate 3.18.1' PACKAGE_BUGREPORT='' PACKAGE_URL='https://github.com/logrotate/logrotate' @@ -1297,7 +1297,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures logrotate 3.18.0 to adapt to many kinds of systems. +\`configure' configures logrotate 3.18.1 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1368,7 +1368,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of logrotate 3.18.0:";; + short | recursive ) echo "Configuration of logrotate 3.18.1:";; esac cat <<\_ACEOF @@ -1481,7 +1481,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -logrotate configure 3.18.0 +logrotate configure 3.18.1 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1903,7 +1903,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by logrotate $as_me 3.18.0, which was +It was created by logrotate $as_me 3.18.1, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2767,7 +2767,7 @@ # Define the identity of the package. PACKAGE='logrotate' - VERSION='3.18.0' + VERSION='3.18.1' cat >>confdefs.h <<_ACEOF @@ -6437,7 +6437,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by logrotate $as_me 3.18.0, which was +This file was extended by logrotate $as_me 3.18.1, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -6504,7 +6504,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -logrotate config.status 3.18.0 +logrotate config.status 3.18.1 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logrotate-3.18.0/examples/logrotate.conf new/logrotate-3.18.1/examples/logrotate.conf --- old/logrotate-3.18.0/examples/logrotate.conf 2020-06-07 16:39:56.000000000 +0200 +++ new/logrotate-3.18.1/examples/logrotate.conf 2021-04-16 18:32:39.000000000 +0200 @@ -20,4 +20,4 @@ # packages drop log rotation information into this directory include /etc/logrotate.d -# system-specific logs may be also be configured here. +# system-specific logs may also be configured here. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logrotate-3.18.0/log.c new/logrotate-3.18.1/log.c --- old/logrotate-3.18.0/log.c 2019-12-04 10:17:23.000000000 +0100 +++ new/logrotate-3.18.1/log.c 2021-05-21 12:28:13.000000000 +0200 @@ -1,8 +1,6 @@ #include <stdarg.h> #include <stdio.h> #include <stdlib.h> -#include <time.h> -#include <sys/time.h> #include <unistd.h> #ifdef HAVE_VSYSLOG #include <syslog.h> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logrotate-3.18.0/log.h new/logrotate-3.18.1/log.h --- old/logrotate-3.18.0/log.h 2020-04-08 18:55:16.000000000 +0200 +++ new/logrotate-3.18.1/log.h 2021-05-21 12:28:13.000000000 +0200 @@ -10,8 +10,6 @@ #define MESS_ERROR 5 #define MESS_FATAL 6 -#define LOG_TIMES (1 << 0) - void message(int level, const char *format, ...) #ifdef __GNUC__ __attribute__ ((format(printf, 2, 3))); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logrotate-3.18.0/logrotate.8 new/logrotate-3.18.1/logrotate.8 --- old/logrotate-3.18.0/logrotate.8 2021-01-08 08:34:23.000000000 +0100 +++ new/logrotate-3.18.1/logrotate.8 2021-05-21 15:39:05.000000000 +0200 @@ -1,4 +1,4 @@ -.TH LOGROTATE 8 "3.18.0" "Linux" "System Administrator's Manual" +.TH LOGROTATE 8 "3.18.1" "Linux" "System Administrator's Manual" .\" Per groff_man(7), the TQ macro should be copied from an-ext.tmac when .\" not running under groff. That's not quite right; not all groff .\" installations include this macro. So bring it in with another name @@ -154,6 +154,7 @@ rotate 2 olddir /var/log/news/old missingok + sharedscripts postrotate kill \-HUP $(cat /var/run/inn.pid) endscript @@ -192,9 +193,7 @@ characters supported. The next section defines the parameters for all of the files in -\fI/var/log/news\fR. Each file is rotated on a monthly basis. This is -considered a single rotation directive and if errors occur for more than -one file, the log files are not compressed. +\fI/var/log/news\fR. Each file is rotated on a monthly basis. The last section uses tilde expansion to rotate log files in the home directory of the current user. This is only available, if your glob @@ -411,7 +410,8 @@ This option can be used, for instance, to make a snapshot of the current log file, or when some other utility needs to truncate or parse the file. When this option is used, the \fBcreate\fR option will have no effect, -as the old log file stays in place. +as the old log file stays in place. The \fBcopy\fR option allows storing +rotated log files on the different devices using \fBolddir\fR directive. .TP \fBnocopy\fR @@ -427,7 +427,9 @@ Note that there is a very small time slice between copying the file and truncating it, so some logging data might be lost. When this option is used, the \fBcreate\fR option will have no effect, -as the old log file stays in place. +as the old log file stays in place. The \fBcopytruncate\fR option allows +storing rotated log files on the different devices using \fBolddir\fR +directive. The \fBcopytruncate\fR option implies \fBnorenamecopy\fR. .TP \fBnocopytruncate\fR @@ -438,9 +440,15 @@ \fBrenamecopy\fR Log file is renamed to temporary filename in the same directory by adding ".tmp" extension to it. After that, \fBpostrotate\fR script is run -and log file is copied from temporary filename to final filename. This allows -storing rotated log files on the different devices using \fBolddir\fR -directive. In the end, temporary filename is removed. +and log file is copied from temporary filename to final filename. In the end, +temporary filename is removed. The \fBrenamecopy\fR option allows storing +rotated log files on the different devices using \fBolddir\fR directive. +The \fBrenamecopy\fR option implies \fBnocopytruncate\fR. + +.TP +\fBnorenamecopy\fR +Do not rename and copy the original log file +(this overrides the \fBrenamecopy\fR option). .TP \fBshred\fR diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logrotate-3.18.0/logrotate.8.in new/logrotate-3.18.1/logrotate.8.in --- old/logrotate-3.18.0/logrotate.8.in 2021-01-05 14:01:16.000000000 +0100 +++ new/logrotate-3.18.1/logrotate.8.in 2021-05-03 14:43:18.000000000 +0200 @@ -154,6 +154,7 @@ rotate 2 olddir /var/log/news/old missingok + sharedscripts postrotate kill \-HUP $(cat /var/run/inn.pid) endscript @@ -192,9 +193,7 @@ characters supported. The next section defines the parameters for all of the files in -\fI/var/log/news\fR. Each file is rotated on a monthly basis. This is -considered a single rotation directive and if errors occur for more than -one file, the log files are not compressed. +\fI/var/log/news\fR. Each file is rotated on a monthly basis. The last section uses tilde expansion to rotate log files in the home directory of the current user. This is only available, if your glob @@ -411,7 +410,8 @@ This option can be used, for instance, to make a snapshot of the current log file, or when some other utility needs to truncate or parse the file. When this option is used, the \fBcreate\fR option will have no effect, -as the old log file stays in place. +as the old log file stays in place. The \fBcopy\fR option allows storing +rotated log files on the different devices using \fBolddir\fR directive. .TP \fBnocopy\fR @@ -427,7 +427,9 @@ Note that there is a very small time slice between copying the file and truncating it, so some logging data might be lost. When this option is used, the \fBcreate\fR option will have no effect, -as the old log file stays in place. +as the old log file stays in place. The \fBcopytruncate\fR option allows +storing rotated log files on the different devices using \fBolddir\fR +directive. The \fBcopytruncate\fR option implies \fBnorenamecopy\fR. .TP \fBnocopytruncate\fR @@ -438,9 +440,15 @@ \fBrenamecopy\fR Log file is renamed to temporary filename in the same directory by adding ".tmp" extension to it. After that, \fBpostrotate\fR script is run -and log file is copied from temporary filename to final filename. This allows -storing rotated log files on the different devices using \fBolddir\fR -directive. In the end, temporary filename is removed. +and log file is copied from temporary filename to final filename. In the end, +temporary filename is removed. The \fBrenamecopy\fR option allows storing +rotated log files on the different devices using \fBolddir\fR directive. +The \fBrenamecopy\fR option implies \fBnocopytruncate\fR. + +.TP +\fBnorenamecopy\fR +Do not rename and copy the original log file +(this overrides the \fBrenamecopy\fR option). .TP \fBshred\fR diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logrotate-3.18.0/logrotate.c new/logrotate-3.18.1/logrotate.c --- old/logrotate-3.18.0/logrotate.c 2020-07-13 14:03:46.000000000 +0200 +++ new/logrotate-3.18.1/logrotate.c 2021-05-03 21:37:19.000000000 +0200 @@ -582,8 +582,12 @@ return -1; } - if ((sb_create.st_uid != sb->st_uid || sb_create.st_gid != sb->st_gid) && - fchown(fd, sb->st_uid, sb->st_gid)) { + /* Only attempt to set user/group if running as root */ + if ( + ROOT_UID == geteuid() && + (sb_create.st_uid != sb->st_uid || sb_create.st_gid != sb->st_gid) && + fchown(fd, sb->st_uid, sb->st_gid) + ) { message(MESS_ERROR, "error setting owner of %s to uid %u and gid %u: %s\n", fileName, (unsigned) sb->st_uid, (unsigned) sb->st_gid, strerror(errno)); close(fd); @@ -770,6 +774,8 @@ int error_printed = 0; char *prevCtx; pid_t pid; + int in_flags; + const char *in_how; message(MESS_DEBUG, "compressing log with: %s\n", log->compress_prog); if (debug) @@ -785,8 +791,18 @@ compressedName = alloca(strlen(name) + strlen(log->compress_ext) + 2); sprintf(compressedName, "%s%s", name, log->compress_ext); - if ((inFile = open(name, O_RDWR | O_NOFOLLOW)) < 0) { - message(MESS_ERROR, "unable to open %s for compression: %s\n", name, strerror(errno)); + in_flags = O_NOFOLLOW; + if (log->flags & LOG_FLAG_SHRED) { + /* need write access for shredding */ + in_flags |= O_RDWR; + in_how = "read-write"; + } else { + in_flags |= O_RDONLY; + in_how = "read-only"; + } + if ((inFile = open(name, in_flags)) < 0) { + message(MESS_ERROR, "unable to open %s (%s) for compression: %s\n", + name, in_how, strerror(errno)); return 1; } @@ -1529,7 +1545,6 @@ struct logState *state, struct logNames *rotNames) { struct tm now; - char *oldName = NULL; const char *compext = ""; const char *fileext = ""; int hasErrors = 0; @@ -1567,7 +1582,7 @@ state->lastRotated = now; { - char *ld; + const char *ld; char *logpath = strdup(log->files[logNum]); if (logpath == NULL) { message_OOM(); @@ -1576,9 +1591,9 @@ ld = dirname(logpath); if (log->oldDir) { if (log->oldDir[0] != '/') { - rotNames->dirName = - malloc(strlen(ld) + strlen(log->oldDir) + 2); - sprintf(rotNames->dirName, "%s/%s", ld, log->oldDir); + if (asprintf(&rotNames->dirName, "%s/%s", ld, log->oldDir) < 0) { + rotNames->dirName = NULL; + } } else rotNames->dirName = strdup(log->oldDir); } else @@ -1770,11 +1785,8 @@ sortGlobResult(&globResult, strlen(rotNames->dirName) + 1 + strlen(rotNames->baseName), dformat); for (glob_count = 0; glob_count < globResult.gl_pathc && !hasErrors; glob_count++) { struct stat sbprev; + const char *oldName = globResult.gl_pathv[glob_count]; - if (asprintf(&oldName, "%s", (globResult.gl_pathv)[glob_count]) < 0) { - message_OOM(); - return 1; - } if (stat(oldName, &sbprev)) { if (errno == ENOENT) message(MESS_DEBUG, "previous log %s does not exist\n", oldName); @@ -1783,7 +1795,6 @@ } else { hasErrors = compressLogFile(oldName, log, &sbprev); } - free(oldName); } } else { message(MESS_DEBUG, @@ -1793,6 +1804,7 @@ free(glob_pattern); } else { struct stat sbprev; + char *oldName; if (asprintf(&oldName, "%s/%s.%d%s", rotNames->dirName, rotNames->baseName, logStart, fileext) < 0) { message_OOM(); @@ -1810,15 +1822,6 @@ } } - /* adding 2 due to / and \0 being added by snprintf */ - rotNames->firstRotated = - malloc(strlen(rotNames->dirName) + strlen(rotNames->baseName) + - strlen(fileext) + strlen(compext) + DATEEXT_LEN + 2 ); - if (rotNames->firstRotated == NULL) { - message_OOM(); - return 1; - } - if (log->flags & LOG_FLAG_DATEEXT) { /* glob for compressed files with our pattern * and compress ext */ @@ -1862,16 +1865,14 @@ } if (mail_out != (size_t)-1) { /* oldName is oldest Backup found (for unlink later) */ - if (asprintf(&oldName, "%s", (globResult.gl_pathv)[mail_out]) < 0) { - message_OOM(); - return 1; - } + const char *oldName = globResult.gl_pathv[mail_out]; rotNames->disposeName = strdup(oldName); if (rotNames->disposeName == NULL) { message_OOM(); + globfree(&globResult); + free(glob_pattern); return 1; } - free(oldName); } else { free(rotNames->disposeName); rotNames->disposeName = NULL; @@ -1882,14 +1883,21 @@ rotNames->disposeName = NULL; } /* firstRotated is most recently created/compressed rotated log */ - sprintf(rotNames->firstRotated, "%s/%s%s%s%s", + if (asprintf(&rotNames->firstRotated, "%s/%s%s%s%s", rotNames->dirName, rotNames->baseName, dext_str, fileext, - (log->flags & LOG_FLAG_DELAYCOMPRESS) ? "" : compext); + (log->flags & LOG_FLAG_DELAYCOMPRESS) ? "" : compext) < 0) { + message_OOM(); + rotNames->firstRotated = NULL; + globfree(&globResult); + free(glob_pattern); + return 1; + } globfree(&globResult); free(glob_pattern); } else { int i; char *newName = NULL; + char *oldName; if (rotateCount == -1) { rotateCount = findLastRotated(rotNames, fileext, compext); @@ -1911,13 +1919,19 @@ rotNames->disposeName = strdup(oldName); if (rotNames->disposeName == NULL) { message_OOM(); + free(oldName); return 1; } } - sprintf(rotNames->firstRotated, "%s/%s.%d%s%s", rotNames->dirName, + if (asprintf(&rotNames->firstRotated, "%s/%s.%d%s%s", rotNames->dirName, rotNames->baseName, logStart, fileext, - (log->flags & LOG_FLAG_DELAYCOMPRESS) ? "" : compext); + (log->flags & LOG_FLAG_DELAYCOMPRESS) ? "" : compext) < 0) { + message_OOM(); + free(oldName); + rotNames->firstRotated = NULL; + return 1; + } for (i = rotateCount + logStart - 1; (i >= 0) && !hasErrors; i--) { free(newName); @@ -1983,6 +1997,7 @@ if (asprintf(&(rotNames->finalName), "%s/%s%s%s", rotNames->dirName, rotNames->baseName, dext_str, fileext) < 0) { message_OOM(); + rotNames->finalName = NULL; return 1; } if (asprintf(&destFile, "%s%s", rotNames->finalName, compext) < 0) { @@ -2001,6 +2016,7 @@ if (asprintf(&(rotNames->finalName), "%s/%s.%d%s", rotNames->dirName, rotNames->baseName, logStart, fileext) < 0) { message_OOM(); + rotNames->finalName = NULL; } } @@ -2084,6 +2100,7 @@ free(rotNames->disposeName); if (asprintf(&rotNames->disposeName, "%s%s", rotNames->finalName, ext) < 0) { message_OOM(); + rotNames->disposeName = NULL; return 1; } @@ -2212,11 +2229,6 @@ struct logState **state; struct logNames **rotNames; - logHasErrors = calloc(log->numFiles, sizeof(int)); - if (!logHasErrors) { - message_OOM(); - return 1; - } message(MESS_DEBUG, "\nrotating pattern: %s ", log->pattern); if (force) { message(MESS_DEBUG, "forced from command line "); @@ -2277,10 +2289,15 @@ if (log->numFiles == 0) { message(MESS_DEBUG, "No logs found. Rotation not needed.\n"); - free(logHasErrors); return 0; } + logHasErrors = calloc(log->numFiles, sizeof(int)); + if (!logHasErrors) { + message_OOM(); + return 1; + } + if (log->flags & LOG_FLAG_SU) { if (switch_user(log->suUid, log->suGid) != 0) { free(logHasErrors); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logrotate-3.18.0/logrotate.spec new/logrotate-3.18.1/logrotate.spec --- old/logrotate-3.18.0/logrotate.spec 2021-01-08 08:34:23.000000000 +0100 +++ new/logrotate-3.18.1/logrotate.spec 2021-05-21 15:39:05.000000000 +0200 @@ -1,6 +1,6 @@ Summary: Rotates, compresses, removes and mails system log files Name: logrotate -Version: 3.18.0 +Version: 3.18.1 Release: 1%{?dist} License: GPLv2+ Group: System Environment/Base diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logrotate-3.18.0/test/test-common.sh new/logrotate-3.18.1/test/test-common.sh --- old/logrotate-3.18.0/test/test-common.sh 2021-01-05 14:01:16.000000000 +0100 +++ new/logrotate-3.18.1/test/test-common.sh 2021-04-16 18:32:39.000000000 +0200 @@ -15,10 +15,10 @@ if command -v md5sum > /dev/null 2>&1; then MD5SUM=md5sum -elif command -v gmd5sum > /dev/null 2>&1; then - MD5SUM=gmd5sum +elif command -v md5 > /dev/null 2>&1; then + MD5SUM=md5 else - echo "no md5sum command found" + echo "no md5sum/md5 command found" exit 1 fi diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logrotate-3.18.0/test/test-config.24.in new/logrotate-3.18.1/test/test-config.24.in --- old/logrotate-3.18.0/test/test-config.24.in 2017-12-06 15:39:03.000000000 +0100 +++ new/logrotate-3.18.1/test/test-config.24.in 2021-05-03 14:43:18.000000000 +0200 @@ -1,5 +1,8 @@ create +# will be overridden by copytruncate +renamecopy + &DIR&/test*.log { daily copytruncate diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logrotate-3.18.0/test/test-config.58.in new/logrotate-3.18.1/test/test-config.58.in --- old/logrotate-3.18.0/test/test-config.58.in 2017-12-06 15:39:03.000000000 +0100 +++ new/logrotate-3.18.1/test/test-config.58.in 2021-05-03 14:43:18.000000000 +0200 @@ -1,5 +1,8 @@ create +# will be overridden by renamecopy +copytruncate + &DIR&/test.log { renamecopy weekly diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logrotate-3.18.0/test/test-config.59.in new/logrotate-3.18.1/test/test-config.59.in --- old/logrotate-3.18.0/test/test-config.59.in 2017-12-06 15:39:03.000000000 +0100 +++ new/logrotate-3.18.1/test/test-config.59.in 2021-05-03 14:43:18.000000000 +0200 @@ -1,5 +1,8 @@ create +# will be overridden by renamecopy +copytruncate + &DIR&/test.log { renamecopy weekly diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logrotate-3.18.0/test/test-config.62.in new/logrotate-3.18.1/test/test-config.62.in --- old/logrotate-3.18.0/test/test-config.62.in 2017-12-06 15:39:03.000000000 +0100 +++ new/logrotate-3.18.1/test/test-config.62.in 2021-05-03 14:43:18.000000000 +0200 @@ -1,5 +1,8 @@ create +# will be overridden by copytruncate +renamecopy + &DIR&/test*.log { daily copytruncate diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/logrotate-3.18.0/test/test-config.63.in new/logrotate-3.18.1/test/test-config.63.in --- old/logrotate-3.18.0/test/test-config.63.in 2017-12-06 15:39:03.000000000 +0100 +++ new/logrotate-3.18.1/test/test-config.63.in 2021-05-03 14:43:18.000000000 +0200 @@ -1,5 +1,8 @@ create +# will be overridden by copytruncate +renamecopy + &DIR&/test*.log { daily copytruncate