[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[Popcon-developers] Bug#310327: popularity-contest: broken pipeo



reassign 310327 ssmtp

> On Mon, May 23, 2005 at 06:51:07AM +0200, Wouter Van Hemel wrote:
>> Package: popularity-contest
>> Version: 1.28
>> Severity: normal
>> Tags: sid
>>
>> I've just received an email from cron and popularity-contest seems to
>> break with:
>>
>> /etc/cron.weekly/popularity-contest:
>> tee: standard output: Broken pipe
>> tee: write error
>

I think I traced this back to ssmtp weirdness. For instance, this command
fails:

(echo "From: bob"; echo; HOME=/tmp su nobody -pc "sh -c
/usr/sbin/popularity-contest") | tee /tmp/delme | strace
/usr/sbin/sendmail -oi "my@email.address"; tail -1 /var/log/mail.log

... but this one works (notice one missing echo):

(echo; HOME=/tmp su nobody -pc "sh -c /usr/sbin/popularity-contest") | tee
/tmp/delme | strace /usr/sbin/sendmail -oi "my@email.address"; tail -1
/var/log/mail.log

The some problem occurs with a 'cat *.txt' as "a long, interleaved
command", so it is not related to popcon. In some circumstances, ssmtp
sends the email before the pipe has ended.

Without looking at the code, I dare to make a wild guess -- I think that
when ssmtp receives a timeout on stdin, it just thinks that the pipe ended
and sends the email without the body -- in this case the popcon output.

Note the last write which ends the email prematurely (command above):

[...]
write(3, "Received: by mysystem.mydomain.org (s"..., 91) = 91
write(3, "Date: Tue, 24 May 2005 05:34:53 "..., 39) = 39
write(3, "From: jim@example.com\r\n", 23) = 23
alarm(300)                              = 300
write(3, "\r\n", 2)                     = 2
fcntl64(0, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
read(0, 0xb7fe8000, 4096)               = -1 EAGAIN (Resource temporarily
unavailable)
write(3, ".\r\n", 3)                    = 3
alarm(600)                              = 300
read(3, "2", 1)                         = 1
read(3, "5", 1)                         = 1
read(3, "0", 1)                         = 1
read(3, " ", 1)                         = 1
read(3, "o", 1)                         = 1
read(3, "k", 1)                         = 1
[...]

another one (cat *.txt):

[...]
write(3, "onze noord-westelijke samenlevin"..., 73) = 73
alarm(300)                              = 300
write(3, "wat normaal is in het echte leve"..., 72) = 72
alarm(300)                              = 300
write(3, "de natuur in gaat, maakt ze heil"..., 65) = 65
alarm(300)                              = 300
read(0, 0xb7fe8000, 4096)               = -1 EAGAIN (Resource temporarily
unavailable)
write(3, "Nietzsche, de haat van het leve\r"..., 33) = 33
alarm(300)                              = 300
read(0, 0xb7fe8000, 4096)               = -1 EAGAIN (Resource temporarily
unavailable)
write(3, ".\r\n", 3)                    = 3
alarm(600)                              = 300
read(3, "2", 1)                         = 1
read(3, "5", 1)                         = 1
read(3, "0", 1)                         = 1
read(3, " ", 1)                         = 1
read(3, "o", 1)                         = 1
read(3, "k", 1)                         = 1
[...]

If this indeed is the problem, upstream or ssmtp maintainer (perhaps they
are one and the same for ssmtp?) could add a check on the type of error
when reading from stdin, so EAGAIN just keeps on looping instead of ending
the pipe prematurely.

Thanks for your time,

  Wouter Van Hemel





Reply to: