Bug 16544 - logrotate does not process errors correctly
Summary: logrotate does not process errors correctly
Status: CLOSED RAWHIDE
Alias: None
Product: Red Hat Linux
Classification: Retired
Component: logrotate   
(Show other bugs)
Version: 7.0
Hardware: i386 Linux
medium
medium
Target Milestone: ---
Assignee: Preston Brown
QA Contact:
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2000-08-18 18:18 UTC by mal
Modified: 2008-05-01 15:37 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-06-21 19:06:27 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Configuration example (153 bytes, text/plain)
2000-08-18 20:31 UTC, mal
no flags Details
strace logtotate -f t.conf (7.17 KB, text/plain)
2000-08-18 20:33 UTC, mal
no flags Details

Description mal 2000-08-18 18:18:39 UTC
logrotate does not process postinstallation script errors correctly.
there is postrotation script:

set -ex
echo AAAAAAA
echo EEEEEEEE >&2

During rotation
logrotate -f /etc/logrotate.conf
 what is printed to stdout (AAAAAAA)
is seen on the screen.
What is printed to stderr is not seen anywhere.
Output is just missed. (It is not mailed to root).
The part of strace is below:
First what is clear that close(2) is executed twice.
Check it, there is a bug somewhere.

stat("/home/test/files/logs/error_log", {st_mode=S_IFREG|0644, st_size=0,
...}) = 0
time(NULL)                              = 966622278
gettimeofday({966622278, 138194}, NULL) = 0
getpid()                                = 16429
stat("/tmp/logrotCwRlS0", 0xbffff5f0)   = -1 ENOENT (No such file or
directory)
open("/tmp/logrotCwRlS0", O_WRONLY|O_CREAT|O_EXCL, 0700) = 3
stat("/tmp/logrotCwRlS0", {st_mode=S_IFREG|0700, st_size=0, ...}) = 0
write(3, "#!/bin/sh\n\n", 11)           = 11
write(3, "\nset -ex\necho AAAAAAA\necho EEEEE"..., 531) = 531
close(3)                                = 0
rt_sigaction(SIGINT, {SIG_IGN}, {SIG_DFL}, 8) = 0
rt_sigaction(SIGQUIT, {SIG_IGN}, {SIG_DFL}, 8) = 0
rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
vfork(AAAAAAA
)                                 = 16478
wait4(16478, [WIFEXITED(s) && WEXITSTATUS(s) == 0], 0, NULL) = 16478
rt_sigaction(SIGINT, {SIG_DFL}, NULL, 8) = 0
rt_sigaction(SIGQUIT, {SIG_DFL}, NULL, 8) = 0
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
--- SIGCHLD (Child exited) ---
unlink("/tmp/logrotCwRlS0")             = 0
close(2)                                = 0
munmap(0x40019000, 4096)                = 0
close(2)                                = -1 EBADF (Bad file descriptor)
dup2(4, 2)                              = 2
close(4)                                = 0
unlink("/tmp/fileHy83RQ")               = 0
stat("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=4096, ...}) = 0
gettimeofday({966622280, 81712}, NULL)  = 0
getpid()                                = 16429
stat("/tmp/filebk7AG5", 0xbffff640)     = -1 ENOENT (No such file or
directory)
open("/tmp/filebk7AG5", O_WRONLY|O_CREAT|O_EXCL, 0600) = 3

Comment 1 mal 2000-08-18 20:29:53 UTC
This is more info.
The file t.conf (attached).
when errors is commented
then I have
touch /tmp/AA ; logrotate -f  t.conf
STDOUT
STDERR
DONE

so stderr is printed
When I uncomment errors I have:
touch /tmp/AA ; logrotate -f  t.conf
STDOUT
DONE

No stderr is printed. And also it does not attempt to 
send an e-mail (see strace attached).
So there is a bug with sending an e-mail.
This bug should be fixed, 

but I think that errors directive
SHOULD BE REMOVED from 
logrotate.conf
because the only place from which logrotate 
is called is cron.
It does not make sense to send stderr by logrotate
and stdout by cron.
I think that logrotate should not send any e-mails.
Leave this to cron.
It will be much more consistent.

Comment 2 mal 2000-08-18 20:31:43 UTC
Created attachment 2678 [details]
Configuration example

Comment 3 mal 2000-08-18 20:33:14 UTC
Created attachment 2679 [details]
strace logtotate -f t.conf

Comment 4 mal 2000-08-26 22:07:01 UTC
Can this problem be fixed before the release?

If not I would recommend to comment
errors root
line as a workaround. Then no messages will be sent
by logrotate.
Both stdout and stderr will be sent by cron.

Comment 5 Preston Brown 2001-06-21 19:06:23 UTC
The bug does exist, and I agree with your assessment -- logrotate is more or less 
always run from cron, and if it isn't, it is an interactive command where you will see 
the errors.  From release 3.5.6, I am ignoring the deprecated "errors" directive, and 
relying on cron to mail the errors out.  Thus stderr will be printed as expected.



Note You need to log in before you can comment on or make changes to this bug.