fetchmail-friends
[Top] [All Lists]

[fetchmail] [PATCH] exit with non zero code, 2nd

2002-09-12 16:21:26
"Carlo Luchetti" <cluchetti(_at_)toplan(_dot_)it> writes:

Hello, (this is the second time that I sent this message, perhaps!)
I've configured fetchmail to retrieve all message from a single
account out of the organization and to redistribuite the email
to the local accounts. It's seem to work fine but when arrived
a mail to unknown local user, sendmail end with status code not 0
end fetchmail cannot continue to delete the erroeus message.
Where i failed?

    mda '/usr/sbin/sendmail -oem -f %F %T'

You need to insert an "-i" for this to work reliably.

But note the man page:

:      Fetchmail's  method of sending bouncemail and spam bounces
:      requires that port 25 of localhost be available for  send-
:      ing mail via SMTP.

So you can just remove the mda option from your config file and let
fetchmail forward to your sendmail's SMTP port (port 25) instead. That
should work.

this is log file (maillog):
---------------------------------------
Sep  9 12:53:09 fwvgm fetchmail[21748]: 
  MDA returned nonzero status 17152

17152 >> 8 = 67 (EX_NOUSER, see /usr/include/sysexits.h)

This looks very sane to me from sendmail's point of view, it's just that
fetchmail lacks handling this at close_sink time -- it simply does not
expect EX_NOUSER condition at that time, and if it were a real MDA, then
something would be wrong. In fact, it should be able to treat the exit
code properly, try again on EX_TEMPFAIL, and bounce on any other error
(or optionally forward to postmaster on EX_NOUSER).

It looks as though fetchmail could not be used in multidrop mode with
the mda option for now.

As a workaround, try setting up sendmail to listen on an SMTP
port (I believe you can somehow make it listen only on 127.0.0.1 if
that's your concern) and comment out the mda option. fetchmail will then
talk SMTP to your sendmail and should be able to recognize the SMTP
error codes.

To make these codes easier to read, I suggest this patch. Note that this
raises the need to translate two more messages:

Index: sink.c
===================================================================
RCS file: /var/CVS/fetchmail/sink.c,v
retrieving revision 1.2
diff -u -r1.2 sink.c
--- sink.c:1.2  2002/09/06 16:27:37     1.2
+++ sink.c      2002/09/12 23:12:36
@@ -33,6 +33,14 @@
 #include  <ctype.h>
 #include  <time.h>
 
+/* for W* macros after pclose() */
+#define _USE_BSD
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <sys/wait.h>
+
+
 #include  "fetchmail.h"
 #include  "socket.h"
 #include  "smtp.h"
@@ -1246,8 +1254,17 @@
 
        if (rc)
        {
-           report(stderr, 
-                  GT_("MDA returned nonzero status %d\n"), rc);
+           if (WIFSIGNALED(rc)) {
+               report(stderr, 
+                       GT_("MDA died of signal %d\n"), WTERMSIG(rc));
+           } else if (WIFEXITED(rc)) {
+               report(stderr, 
+                       GT_("MDA returned nonzero status %d\n"), 
WEXITSTATUS(rc));
+           } else {
+               report(stderr,
+                       GT_("Strange: MDA pclose returned %d, cannot handle at 
%s:%d\n"), rc, __FILE__, __LINE__);
+           }
+
            return(FALSE);
        }
     }

-- 
Matthias Andree