Bug#316442: at does not mail job output if at command is installed by root
Ansgar Burchardt wrote: On my system, root's mail is redirected to my own account (mwg) through /etc/aliases : root: mwg so, the testcase is to submit at/batch job under root, and then you don't get its output when you use courier-mta as sendmail. Can you please try to send mail directly using sendmail? $ echo Subject: foo\n\nbar | /usr/sbin/sendmail -i root This should send a mail to root. Please try it as both root and your usual user account. You can also try sending mail as root to your own account. Does this produce any error messages? Or does something show up in the log files? sendmail run by hand works well in all 4 cases ({mwg,root} - {mwg,root}) I would also say, that the script submitted as root's at/batch job is run and does what it has been told. Just don't get its output by mail, every time with courier-mta. ... Finally, I dared to strace atd and its subprocesses, and found the difference between sendmail run for root and non-root user. Being run from atd, sendmail process does not have open stdout and stderr file descriptors. And courier's sendmail, being run for ordinary user, checks that (fcntl(..., F_GETFD)) and reopens them to /dev/null. For root user, it does not check/reopen them, so FDs 1 and 2 get reused for other file descriptors (probably, in dlopen, as a socket to connect to nscd service, and so on), and certain hell ensues as a result. As you may imagine, sendmail run from the interactive terminal session inherits open stdout/stderr and so probably does not have these issues at all. Don't know what is the root cause. Probably it has something to do with O_CLOEXEC flag. Don't know what would be simpler, to fix that at courier-mta level, or at atd's (just ensure we have stdout and stderr open without CLOEXEC before running sendmail). -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#316442: at does not mail job output if at command is installed by root
tags 316442 - moreinfo clone 316442 -1 reassign -1 courier-mta retitle -1 courier-mta: cannot use sendmail as root with stdout, stderr closed thanks Hi, Wladimir Mutel m...@mwg.dp.ua writes: Finally, I dared to strace atd and its subprocesses, and found the difference between sendmail run for root and non-root user. Being run from atd, sendmail process does not have open stdout and stderr file descriptors. And courier's sendmail, being run for ordinary user, checks that (fcntl(..., F_GETFD)) and reopens them to /dev/null. For root user, it does not check/reopen them, so FDs 1 and 2 get reused for other file descriptors (probably, in dlopen, as a socket to connect to nscd service, and so on), and certain hell ensues as a result. That looks like a bug in courier's implementation of sendmail. It should do the same if executed as root. If mail (from mailutils) also closed stdout and stderr, this might be the same issue as #430166. Regards, Ansgar -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#316442: at does not mail job output if at command is installed by root
Hi, Wladimir Mutel m...@mwg.dp.ua writes: Finally, I dared to strace atd and its subprocesses, and found the difference between sendmail run for root and non-root user. Being run from atd, sendmail process does not have open stdout and stderr file descriptors. And courier's sendmail, being run for ordinary user, checks that (fcntl(..., F_GETFD)) and reopens them to /dev/null. For root user, it does not check/reopen them, so FDs 1 and 2 get reused for other file descriptors (probably, in dlopen, as a socket to connect to nscd service, and so on), and certain hell ensues as a result. I reported this issue to the courier-mta maintainers, but it shouldn't hurt to fix this in at as well. Can you try the patch below? A dsc and deb (for amd64) is available from http://www.43-1.org/~ansgar/at/ as well. Regards, Ansgar diff --git a/atd.c b/atd.c index bf28102..ed52327 100644 --- a/atd.c +++ b/atd.c @@ -468,6 +468,18 @@ run_file(const char *filename, uid_t uid, gid_t gid) if (open(filename, O_RDONLY) != STDIN_FILENO) perr(Open of jobfile failed); +/* some sendmail implementations are confused if stdout, stderr are + * not available, so let them point to /dev/null + */ +if ((fd_in = open(/dev/null, O_WRONLY)) 0) + perr(Could not open /dev/null.); +if (dup2(fd_in, STDOUT_FILENO) 0) + perr(Could not use /dev/null as standard output.); +if (dup2(fd_in, STDERR_FILENO) 0) + perr(Could not use /dev/null as standard error.); +if (fd_in != STDOUT_FILENO fd_in != STDERR_FILENO) + close(fd_in); + unlink(filename); /* The job is now finished. We can delete its input file. diff --git a/debian/changelog b/debian/changelog index c003ee1..80fba2b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +at (3.1.11-1+ab1) UNRELEASED; urgency=low + + * make stdout, stderr available to sendmail process (Closes: #316442) + + -- Ansgar Burchardt ans...@43-1.org Sun, 15 Nov 2009 20:36:44 +0900 + at (3.1.11-1) unstable; urgency=low * New upstream release:
Bug#316442: at does not mail job output if at command is installed by root
Ansgar Burchardt wrote: Finally, I dared to strace atd and its subprocesses, and found the difference between sendmail run for root and non-root user. Being run from atd, sendmail process does not have open stdout and stderr file descriptors. And courier's sendmail, being run for ordinary user, checks that (fcntl(..., F_GETFD)) and reopens them to /dev/null. For root user, it does not check/reopen them, so FDs 1 and 2 get reused for other file descriptors (probably, in dlopen, as a socket to connect to nscd service, and so on), and certain hell ensues as a result. Can you try the patch below? A dsc and deb (for amd64) is available from http://www.43-1.org/~ansgar/at/ as well. Great, now it works as I long wanted. I applied your patch only to atd.c in Ubuntu 9.10 'at' package, rebuilt and reinstalled it, and now my root jobs output gets mailed to me. Thank you. -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#316442: at does not mail job output if at command is installed by root
Ansgar Burchardt wrote: tags 316442 + moreinfo thanks Hi, I recently took over maintenance of at and am going over the open bug reports. You reported quite some time ago, that at will not mail command output for jobs queued by root when using ssmtp or courier-mta. Is this still the case? If so, can you send mail to root using /usr/sbin/sendmail? On my system, root's mail is redirected to my own account (mwg) through /etc/aliases : root: mwg so, the testcase is to submit at/batch job under root, and then you don't get its output when you use courier-mta as sendmail. # id uid=0(root) gid=0(root) groups=0(root) # echo echo test | batch warning: commands will be executed using /bin/sh job 3487 at Sat Nov 14 11:09:00 2009 (output is not mailed from this job) $ id uid=1001(mwg) gid=1001(mwg) groups=0(root),4(adm),6(disk),13(proxy),20(dialout),24(cdrom),25(floppy),29(audio),30(dip),40(src),44(video),46(plugdev),108(camera),134(jabber),706(dos),1001(mwg) $ echo echo test | batch warning: commands will be executed using /bin/sh job 3488 at Sat Nov 14 11:09:00 2009 (for this job, I get the output well) I did not try to trace every operation of atd daemon, though . Only noted that with other MTAs like postfix, the output is mailed well from both root and non-root jobs. Can not provide details about ssmtp as I don't use it. -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#316442: at does not mail job output if at command is installed by root
Hi, Wladimir Mutel m...@mwg.dp.ua writes: On my system, root's mail is redirected to my own account (mwg) through /etc/aliases : root: mwg so, the testcase is to submit at/batch job under root, and then you don't get its output when you use courier-mta as sendmail. Can you please try to send mail directly using sendmail? $ echo Subject: foo\n\nbar | /usr/sbin/sendmail -i root This should send a mail to root. Please try it as both root and your usual user account. You can also try sending mail as root to your own account. Does this produce any error messages? Or does something show up in the log files? Regards, Ansgar -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#316442: at does not mail job output if at command is installed by root
tags 316442 + moreinfo thanks Hi, I recently took over maintenance of at and am going over the open bug reports. You reported quite some time ago, that at will not mail command output for jobs queued by root when using ssmtp or courier-mta. Is this still the case? If so, can you send mail to root using /usr/sbin/sendmail? Regards, Ansgar -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#316442: at does not mail job output if at command is installed by root
Package: at Version: 3.1.8-11 Severity: important When root installs an at command the command is run but the results are not mailed. User IDs other than 0 work as expected. -- System Information: Debian Release: testing/unstable APT prefers testing APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental') Architecture: i386 (i586) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.8-2-386 Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968) (ignored: LC_ALL set to C) Versions of packages at depends on: ii libc6 2.3.2.ds1-22 GNU C Library: Shared libraries an ii ssmtp [mail-transport-agent 2.61-3 extremely simple MTA to get mail o -- no debconf information -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]