1
0
Fork 0
mirror of https://github.com/logrotate/logrotate.git synced 2026-12-03 13:44:33 +00:00
The logrotate utility is designed to simplify the administration of log files on a system which generates a lot of log files.
  • C 63.1%
  • Shell 25.4%
  • Roff 8.8%
  • M4 1.7%
  • Makefile 1%
Find a file
Christian Göttsche 4a54194cd9 logrotate: escape glob meta-characters in log names for rotation lookups
The glob(3) patterns used to find a log's own previous rotations, in
findRotatedIndices() and in the dateext lookups of prerotateSingleLog(),
are built from the log's real directory and base name. Glob
meta-characters in those names, e.g. a literal '*' in the access log of
an nginx wildcard vhost or a file named "[...].log" created in a
directory rotated via a wildcard pattern, are interpreted as wildcards
instead of matching literally. As a result:

  - rotations of unrelated logs are matched, and removed as excess
    rotations;
  - in compGlobResult() the date is parsed at an offset computed from
    the unescaped name, which can be beyond the end of a shorter
    matched path, causing an out-of-bounds heap read in strptime(3).

Escape the directory and base name before building the patterns, so
matches always start with the literal name. Additionally never parse
past the end of a matched path in compGlobResult().

The suffixes (date pattern, extension, compression extension) are left
unescaped as before; they stem from the configuration and follow the
escaped prefix.

Test 128 is adopted from GitHub PR #722 by Alexander Bakin, which fixes
the same issue, using fixed dates.

Reported-by: Alexander Bakin (https://github.com/logrotate/logrotate/pull/722)
Reported-by: David Padilla Alvarado (TIM Security Red Team Research, TIM S.p.A)
Reported-by: Arthur Lima (TIM Security Red Team Research, TIM S.p.A)
Reported-by: Massimiliano Brolli (TIM Security Red Team Research, TIM S.p.A)
2026-11-10 18:31:54 +01:00
.github ci: fix compiler and keyring inconsistencies 2026-11-10 17:41:27 +01:00
build-aux docs: drop mentions of Travis CI 2026-11-09 17:42:13 +01:00
examples Stretch systemd timer over one hour 2024-03-15 20:08:01 +01:00
test logrotate: escape glob meta-characters in log names for rotation lookups 2026-11-10 18:31:54 +01:00
.gitattributes .gitattributes: add merge=union policy for changelog merges 2016-09-23 17:29:17 +02:00
.gitignore gitignore: ignore compilation database 2026-11-09 17:38:12 +01:00
.shellcheckrc .shellcheckrc: tell ShellCheck where to look for sourced scripts 2022-09-23 12:42:37 +02:00
autogen.sh autogen.sh: enable autoreconf warnings 2019-11-19 16:20:26 +01:00
ChangeLog.md logrotate: escape glob meta-characters in log names for rotation lookups 2026-11-10 18:31:54 +01:00
config.c config: limit minage so it can be converted into seconds 2026-11-10 18:05:29 +01:00
configure.ac configure: drop unused check 2026-05-21 14:11:03 +02:00
CONTRIBUTING.md docs: drop mentions of Travis CI 2026-11-09 17:42:13 +01:00
COPYING docs: FSF moved back in 2005 2017-04-16 22:24:52 +01:00
INSTALL test: let tests run on 'make distcheck' 2016-08-03 11:01:44 +02:00
log.c log: unify handling of log levels 2022-06-02 09:04:51 +02:00
log.h log: unify handling of log levels 2022-06-02 09:04:51 +02:00
logrotate.8.in config: parse all numeric option values as checked decimal numbers 2026-11-10 18:05:29 +01:00
logrotate.c logrotate: escape glob meta-characters in log names for rotation lookups 2026-11-10 18:31:54 +01:00
logrotate.conf.5 new man page for config, exit if config file too large, change cron script not to open stdio and stderr 2009-09-25 12:00:51 +00:00
logrotate.h config: limit minage so it can be converted into seconds 2026-11-10 18:05:29 +01:00
logrotate.spec.in skip locking if state file is world-readable 2022-05-24 17:20:14 +02:00
Makefile.am Makefile.am: keep logrotate version in .tarball-version 2018-02-06 14:32:05 +01:00
queue.h fix minor codestyle deviations 2021-08-30 14:53:34 +02:00
README.HPUX whitespace cleanup 2020-03-30 15:35:22 +02:00
README.md add support for rotation by minutes 2024-11-05 20:48:58 +01:00
README.Solaris fix misspellings in documentation and comments 2020-03-31 17:51:34 +02:00
upload-release.sh upload-release: use main 2023-07-20 12:52:23 +02:00

logrotate

The logrotate utility is designed to simplify the administration of log files on a system which generates a lot of log files. Logrotate allows for the automatic rotation compression, removal and mailing of log files. Logrotate can be set to handle a log file hourly, daily, weekly, monthly, when time in minutes has elapsed or when the log file gets to a certain size.

Download

The latest release is:

Previous releases:

Git checkout

You can also obtain code by using git checkout:

git clone https://github.com/logrotate/logrotate.git -b main

Replace main with branch or tag you intend to checkout

Verify and unpack

After downloading the tarball and .asc signature file, check the signature:

Get Christian's PGP key rsa4096/C78CE737A3C3E28E (almost any keyserver will do if pgp.mit.edu is temporarily unavailable):

$ gpg --keyserver pgp.mit.edu --recv-key 8ECCDF12100AD84DA2EE7EBFC78CE737A3C3E28E

Older releases are signed with Kamil's PGP key rsa4096/72A37B36

$ gpg --keyserver pgp.mit.edu --recv-key 992A96E075056E79CD8214F9873DB37572A37B36

and verify the PGP signature on the distribution tarball:

$ gpg --verify logrotate-3.22.0.tar.xz.asc logrotate-3.22.0.tar.xz

If successful your GPG output should look like this:

gpg: Signature made Sat 01 Jun 2024 05:41:38 PM CEST
gpg:                using RSA key 8ECCDF12100AD84DA2EE7EBFC78CE737A3C3E28E
gpg: Good signature from "Christian Göttsche <cgzones@googlemail.com>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 8ECC DF12 100A D84D A2EE  7EBF C78C E737 A3C3 E28E

You may then unpack the tarball:

$ tar -xJf logrotate-3.22.0.tar.xz

Notice that git tags are signed with same key:

$ git tag --verify 3.22.0

Compiling

Obtain source either by Downloading it or doing Git checkout.

Install dependencies for Debian systems:

apt-get update
apt-get install autoconf automake libpopt-dev libtool make xz-utils

Install dependencies for Fedora/CentOS systems:

yum install autoconf automake libtool make popt-devel xz

Compilation (autoreconf is optional if you obtained source from tarball):

cd logrotate-X.Y.Z
autoreconf -fiv
./configure
make

Patches and Questions

Open issues or pull requests on GitHub.

More details in CONTRIBUTING.md file for pull requests.