Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 497854

Summary: media-sound/mpd - logrotate script complains when mpd is run as non-standard user
Product: Gentoo Linux Reporter: dtr <presentmeaninvite>
Component: Current packagesAssignee: Christoph Mende (RETIRED) <angelos>
Status: RESOLVED FIXED    
Severity: normal CC: hwoarang, sound
Priority: Normal Keywords: PATCH
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description dtr 2014-01-12 03:58:53 UTC
The problem is in /etc/logrotate.d/mpd file.

It contains the following lines:

/var/lib/mpd/log {
        missingok
        postrotate
        [ -f /var/run/mpd.pid ] && /bin/kill -HUP `cat /var/run/mpd.pid`
        endscript
}

I run MPD as an ordinary user, hence there is no file /var/run/mpd.pid on my system. The problem is that /bin/bash, which is the shell that all the cron jobs run in, evaluates the subshell call BEFORE the test command, i.e. from the beginning it outputs the error I get on email from my cron daemon about nonexisted file /var/run/mpd.pid:

error: error running non-shared postrotate script for /var/lib/mpd/log of '/var/lib/mpd/log '

and only then the command proceedes (as it should be). 
Since any output produced by a script running as a cron job is treated as failure, I get these messages, which is annoying.

I’d recommend to change the script to

        [ -f /var/run/mpd.pid ] && cat /var/run/mpd.pid | xargs /bin/kill -HUP 

I tested it with ‘/bin/bash -c’ and it doesn’t produce unnecessary output unlike the command that is in logrotate script now.

If somebody doubts about whether xargs is installed on the end-user system, default busybox which comes with stage3 archive has a version of xargs.
Comment 1 Christoph Mende (RETIRED) gentoo-dev 2014-03-22 16:00:26 UTC
Thanks, fixed in CVS