Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 474572 - app-admin/logrotate-3.8.4 - segmentation fault with bad command in {pre,post}rotate script
Summary: app-admin/logrotate-3.8.4 - segmentation fault with bad command in {pre,post}...
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Chema Alonso Josa (RETIRED)
URL: https://fedorahosted.org/logrotate/ti...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-24 07:28 UTC by László Szalma
Modified: 2013-07-15 15:05 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description László Szalma 2013-06-24 07:28:15 UTC
After upgrading to logrotate-3.8.4 the daily logrotate sends segmentation fault in email. I found a connection to a specific logrotate config file.

Reproducible: Always

Steps to Reproduce:
1. apache2 modified logrotate config file in /etc/logrotate.d
2. /usr/sbin/logrotate /etc/logrotate.conf

Actual Results:  
Segmentation fault.

Expected Results:  
rotateting log files, and exit status 0 (or error)

/etc/logrotate.d/apache2 file:

/var/log/apache2/*log /var/www/_log/blade-a/*log {
        daily
        missingok
        rotate 7
        compress
        delaycompress
        notifempty
        create 640 root adm
        sharedscripts
        prerotate
                /usr/bin/awstats_updateall.pl now
        endscript
        postrotate
                /etc/init.d/apache2 reload > /dev/null
        endscript
}


without this config, the logrotate works. The directories not exists, this apache script shouldn't be on this machine, but anyway, it shouldn't segfault, and it works with 3.8.3

Tiwhout sharedscripts it works. (but syslog-ng has sharedscripts too, and it works) maybe it has existing directories?
Comment 1 Jeroen Roovers gentoo-dev 2013-06-24 15:11:07 UTC
It works properly with

/path/to/[this is no directory]/file

but I see segmentation faults with

/path/to/[this is no directory]/*
Comment 2 Jeroen Roovers gentoo-dev 2013-06-24 15:18:37 UTC
(In reply to Jeroen Roovers from comment #1)
> It works properly with
> 
> /path/to/[this is no directory]/file
> 
> but I see segmentation faults with
> 
> /path/to/[this is no directory]/*

Please ignore that. :)
Comment 3 Jeroen Roovers gentoo-dev 2013-06-24 15:23:41 UTC
# gdb `which logrotate` core 
GNU gdb (Gentoo 7.5.1 p2) 7.5.1
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
For bug reporting instructions, please see:
<http://bugs.gentoo.org/>...
Reading symbols from /usr/sbin/logrotate...Reading symbols from /usr/lib64/debug/usr/sbin/logrotate.debug...done.
done.
[New LWP 23516]

warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
Core was generated by `logrotate -f /etc/logrotate.d/test'.
Program terminated with signal 11, Segmentation fault.
#0  0x0000000000406a89 in rotateLogSet (log=0x6db150, force=0) at logrotate.c:1680
1680    logrotate.c: No such file or directory.
(gdb) t a a bt full

Thread 1 (LWP 23516):
#0  0x0000000000406a89 in rotateLogSet (log=0x6db150, force=0) at logrotate.c:1680
        i = 0
        j = 0
        hasErrors = 0
        logHasErrors = <optimized out>
        numRotated = <optimized out>
        state = 0x6d8370
        rotNames = 0x6e07b0
#1  0x0000000000402c62 in main (argc=<optimized out>, argv=<optimized out>)
    at logrotate.c:2229
        force = 1
        stateFile = 0x40aed8 "/var/lib/logrotate.status"
        rc = 0
        arg = <optimized out>
        files = <optimized out>
        optCon = <optimized out>
        log = 0x6db150
        options = {{longName = 0x40aef2 "debug", shortName = 100 'd', argInfo = 0, 
            arg = 0x0, val = 100, 
            descrip = 0x40bca8 "Don't do anything, just test (implies -v)", 
            argDescrip = 0x0}, {longName = 0x40aef8 "force", shortName = 102 'f', 
            argInfo = 0, arg = 0x7fff022a8cdc, val = 0, 
            descrip = 0x40aefe "Force file rotation", argDescrip = 0x0}, {
            longName = 0x40afda "mail", shortName = 109 'm', argInfo = 1, 
            arg = 0x60e398 <mailCommand>, val = 0, 
            descrip = 0x40bcd8 "Command to send mail (instead of `/bin/mail')", 
            argDescrip = 0x40af12 "command"}, {longName = 0x40af1a "state", 
            shortName = 115 's', argInfo = 1, arg = 0x7fff022a8cd0, val = 0, 
            descrip = 0x40af20 "Path of state file", 
            argDescrip = 0x40af33 "statefile"}, {longName = 0x40af3d "verbose", 
            shortName = 118 'v', argInfo = 0, arg = 0x0, val = 118, 
            descrip = 0x40bd08 "Display messages during rotation", argDescrip = 0x0}, 
          {longName = 0x40af45 "version", shortName = 0 '\000', argInfo = 0, 
            arg = 0x0, val = 86, descrip = 0x40af4d "Display version information", 
            argDescrip = 0x0}, {longName = 0x0, shortName = 0 '\000', argInfo = 4, 
            arg = 0x60e3c0 <poptHelpOptions>, val = 0, 
            descrip = 0x40af69 "Help options:", argDescrip = 0x0}, {longName = 0x0, 
            shortName = 0 '\000', argInfo = 0, arg = 0x0, val = 0, descrip = 0x0, 
            argDescrip = 0x0}}
Comment 4 Chema Alonso Josa (RETIRED) gentoo-dev 2013-06-26 17:14:48 UTC
Thanks for reporting.

Which platform are you using?

I've tried to reproduce this in my amd64 box with no luck. I'll get to an x86 in the following days to test in there.
Comment 5 Jeroen Roovers gentoo-dev 2013-06-27 12:12:16 UTC
Thu Jun 27 14:11:55 CEST 2013
emerge --info logrotate
Portage 2.2.0_alpha185 (default/linux/amd64/13.0/no-multilib, gcc-4.6.3, glibc-2.15-r3, 3.8.13-gentoo-JeR x86_64)
=================================================================
                        System Settings
=================================================================
System uname: Linux-3.8.13-gentoo-JeR-x86_64-AMD_Athlon-tm-_64_X2_Dual_Core_Processor_4200+-with-gentoo-2.2
KiB Mem:     3087744 total,   1651372 free
KiB Swap:    3145724 total,   3145724 free
Timestamp of tree: Thu, 27 Jun 2013 03:15:01 +0000
ld GNU ld (GNU Binutils) 2.22
distcc 3.1 x86_64-pc-linux-gnu [enabled]
app-shells/bash:          4.2_p45
dev-java/java-config:     2.1.12-r1
dev-lang/python:          2.7.3-r3, 3.2.3-r2
dev-util/cmake:           2.8.10.2-r2
dev-util/pkgconfig:       0.28
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.11.8
sys-apps/sandbox:         2.6-r1
sys-devel/autoconf:       2.13, 2.69
sys-devel/automake:       1.11.6, 1.12.6, 1.13.4, 1.14
sys-devel/binutils:       2.22-r1
sys-devel/gcc:            4.6.3, 4.7.3
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4-r1
sys-devel/make:           3.82-r4
sys-kernel/linux-headers: 3.7 (virtual/os-headers)
sys-libs/glibc:           2.15-r3
Repositories: gentoo JeR
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* AdobeFlash-10.1"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=k8-sse3 -msahf --param l1-cache-size=64 --param l1-cache-line-size=64 --param l2-cache-size=512 -mtune=k8 -O2 -g -pipe -Wall"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /etc/tinyproxy.conf /usr/lib/distcc/bin /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=k8-sse3 -msahf --param l1-cache-size=64 --param l1-cache-line-size=64 --param l2-cache-size=512 -mtune=k8 -O2 -g -pipe -Wall"
DISTDIR="/world/distfiles"
EMERGE_DEFAULT_OPTS="--quiet-build=n"
FCFLAGS="-march=k8-sse3 -msahf --param l1-cache-size=64 --param l1-cache-line-size=64 --param l2-cache-size=512 -mtune=k8 -O2 -g -pipe -Wall"
FEATURES="assume-digests binpkg-logs buildpkg config-protect-if-modified distcc distlocks ebuild-locks fixlafiles merge-sync multilib-strict news notitles parallel-fetch preserve-libs protect-owned sandbox sfperms sign splitdebug strict test-fail-continue unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox"
FFLAGS="-march=k8-sse3 -msahf --param l1-cache-size=64 --param l1-cache-line-size=64 --param l2-cache-size=512 -mtune=k8 -O2 -g -pipe -Wall"
GENTOO_MIRRORS=" http://ftp.snt.utwente.nl/pub/os/linux/gentoo http://gentoo.tiscali.nl/ http://mirror.leaseweb.com/gentoo/ "
LC_ALL="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed"
MAKEOPTS="-j5"
PKGDIR="/world/gentoo/packages/wieneke"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/world/gentoo/portage"
PORTDIR_OVERLAY="/keeps/gentoo/local"
SYNC="rsync://rsync.de.gentoo.org/gentoo-portage"
USE="256-color 3dnow 3dnowext 64bit X a52 aac aalib acl alsa amd64 amr avx bash-completion berkdb bzip2 cli cracklib crypt cups custom-cflags custom-optimization cxx dbus device-mapper dirac dmalloc dnssec dri dts dv dvd exif extras faac fortran gdbm geoip gif gsm gstreamer gtk gtk3 gudev hwdb iconv idn ipq ipv6 jpeg jpeg2k kde keymap kmod kqemu kvm lcms libdnet libnet libnl lzo mjpeg mms mmx mmxext modules mp3 mpeg mpi mudflap multislot multitarget musepack ncurses nethack network nfq nfsidmap nfsv41 nls nptl ntfsprogs ogg opengl openmp pam pcre pdf perl perl-geoipupdate playlist png python qt3support qt4 quicktime readline romio rtmp schroedinger session smp speex spidermonkey spoof-source sse sse2 sse3 ssl svg symux tcpd tfo theora threads tiff truetype unicode upcall v4l v4l2 vaapi vcd vde vim-syntax vorbis vpx wavpack wmf x264 xcb xft xml xnest xvid zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en en_GB nl" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-3" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_2" QEMU_SOFTMMU_TARGETS="i386 x86_64" QEMU_USER_TARGETS="i386 x86_64" RUBY_TARGETS="ruby19 ruby18" USERLAND="GNU" VIDEO_CARDS="mga nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, INSTALL_MASK, LANG, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON

=================================================================
                        Package Settings
=================================================================

app-admin/logrotate-3.8.5 was built with the following:
USE="acl (-selinux)"
Comment 6 Chema Alonso Josa (RETIRED) gentoo-dev 2013-07-04 12:49:00 UTC
I've reinstalled apache and awstats and used Lászlo config file on a platform quite similar to Jeroen's, but I can't get the segfault.

Sure I'm missing something, but I don't know what. I'll keep trying.

Here is the emerge --info of the platform in which I made the test:


Portage 2.1.12.2 (default/linux/amd64/13.0, gcc-4.6.3, glibc-2.15-r3, 3.8.13-gentoo x86_64)
=================================================================
                        System Settings
=================================================================
System uname: Linux-3.8.13-gentoo-x86_64-AMD_Phenom-tm-_II_X6_1045T_Processor-with-gentoo-2.2
KiB Mem:    15925660 total,  10678980 free
KiB Swap:          0 total,         0 free
Timestamp of tree: Thu, 04 Jul 2013 00:45:01 +0000
ld GNU ld (GNU Binutils) 2.22
distcc 3.1 x86_64-pc-linux-gnu [enabled]
app-shells/bash:          4.2_p45
dev-java/java-config:     2.1.12-r1
dev-lang/python:          2.7.5, 3.2.3-r2
dev-util/cmake:           2.8.10.2-r2
dev-util/pkgconfig:       0.28
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.11.8
sys-apps/sandbox:         2.6-r1
sys-devel/autoconf:       2.13, 2.69
sys-devel/automake:       1.11.6, 1.12.6
sys-devel/binutils:       2.22-r1
sys-devel/gcc:            4.6.3, 4.7.3
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4-r1
sys-devel/make:           3.82-r4
sys-kernel/linux-headers: 3.7 (virtual/os-headers)
sys-libs/glibc:           2.15-r3
Repositories: gentoo ago lisp
ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="@FREE-SOFTWARE @FREE-DOCUMENTS Aladdin HyperSpec radeon-ucode MPEG-4 PSTT freedist unRAR MOTIF Kermit MSttfEULA RAR XMAME as-is xref.lisp 2dboy-EULA"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=k8-sse3 -msahf --param l1-cache-size=64 --param l1-cache-line-size=64 --param l2-cache-size=512 -mtune=k8 -O2 -g -pipe -Wall"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.4/ext-active/ /etc/php/cgi-php5.4/ext-active/ /etc/php/cli-php5.4/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=k8-sse3 -msahf --param l1-cache-size=64 --param l1-cache-line-size=64 --param l2-cache-size=512 -mtune=k8 -O2 -g -pipe -Wall"
DISTDIR="/mnt/tmp/portage/distfiles"
FCFLAGS="-march=k8-sse3 -msahf --param l1-cache-size=64 --param l1-cache-line-size=64 --param l2-cache-size=512 -mtune=k8 -O2 -g -pipe -Wall"
FEATURES="assume-digests binpkg-logs buildpkg config-protect-if-modified distcc distlocks ebuild-locks fixlafiles merge-sync multilib-strict news notitles parallel-fetch preserve-libs protect-owned sandbox sfperms sign splitdebug strict test-fail-continue unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox"
FFLAGS="-march=k8-sse3 -msahf --param l1-cache-size=64 --param l1-cache-line-size=64 --param l2-cache-size=512 -mtune=k8 -O2 -g -pipe -Wall"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LC_ALL="en_US.utf8"
LDFLAGS="-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed"
MAKEOPTS="-j12"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/mnt/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/var/lib/layman/ago /home/nimiux/gentoo-lisp"
SYNC="rsync://rsync.europe.gentoo.org/gentoo-portage"
USE="X acl alsa amd64 bash-completion berkdb bzip2 cli cracklib crypt cxx doc dri fortran gdbm gpm iconv ipv6 jpeg logrotate mmx mng modules mudflap multilib ncurses nls nptl ogg opengl openmp pam pcre png readline session sse sse2 ssl syslog tcpd unicode v4l vorbis zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ubx" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-3" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_2" RUBY_TARGETS="ruby18" SANE_BACKENDS="genesys" USERLAND="GNU" VIDEO_CARDS="radeon fbdev vesa" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"
USE_PYTHON="2.7 3.2"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS

=================================================================
                        Package Settings
=================================================================

app-admin/logrotate-3.8.5 was built with the following:
USE="acl (-selinux)"
Comment 7 Jeroen Roovers gentoo-dev 2013-07-04 13:42:49 UTC
(In reply to Chema Alonso from comment #6)
> I've reinstalled apache and awstats and used Lászlo config file on a
> platform quite similar to Jeroen's, but I can't get the segfault.

You missed the Summary change in this bug report. It's about *bad* commands in the prerotate/postrotate. I tested on a system with *no* apache installed, FWIW.
Comment 8 Chema Alonso Josa (RETIRED) gentoo-dev 2013-07-09 15:15:01 UTC
I've managed to reproduce it (thanks Jeroen).

I've found that the problem occurs when the pattern proposed by László is the first processed by logrotate, so I've filed a ticket describing the problem.

https://fedorahosted.org/logrotate/ticket/31

As a workaround, ensure that the pattern exists and that the pattern (config) file is not the first processed by logrotate.