Hi,
Wladimir Mutel <[email protected]> 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 <[email protected]> Sun, 15 Nov 2009 20:36:44 +0900
+
at (3.1.11-1) unstable; urgency=low
* New "upstream" release: