From a624645d3bd49686c77559cee52900ec6f175909 Mon Sep 17 00:00:00 2001 From: Philipp Takacs Date: Fri, 2 May 2014 23:21:35 +0200 Subject: [PATCH] Check with witch exit-code sendmail/spost exit and give an better error message. So the User sees better wat's wrong. At the moment only exit-code 75 is handlel extra. --- uip/send.c | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/uip/send.c b/uip/send.c index e1e7518..adb2039 100644 --- a/uip/send.c +++ b/uip/send.c @@ -15,6 +15,8 @@ #include #include #include +#include +#include #ifdef HAVE_SYS_TIME_H # include @@ -22,6 +24,7 @@ #include int debugsw = 0; /* global */ +int verbosesw = 0; char *altmsg = NULL; char *annotext = NULL; char *distfile = NULL; @@ -50,6 +53,7 @@ static int signandenc(char *); static void clean_up_temporary_files(void); static int get_line(void); static void make_mime_composition_file_entry(char *); +static char* strexit(int status); static struct swit switches[] = { @@ -114,7 +118,9 @@ main(int argc, char **argv) debugsw++; /* fall */ case VERBSW: + verbosesw += 2; case NVERBSW: + verbosesw--; vec[vecp++] = --cp; continue; } @@ -636,13 +642,17 @@ sendaux(char **vec, int vecp, char *drft, struct stat *st) default: /* parent process -- wait for it */ - if ((status = pidwait(child_id, NOTOK)) == OK) { + status = pidwait(child_id, NOTOK); + if (WIFEXITED(status) && WEXITSTATUS(status) == EX_OK) { if (annotext) { anno(st); } - } else { - /* spost failed */ - advise(NULL, "message not delivered to anyone"); + } + else { + advise(NULL, "%s", strexit(status)); + if (verbosesw <= 0) { + advise(NULL, "Try using -v to get better output"); + } if (distfile) { unlink(drft); if (rename(backup, drft) == NOTOK) { @@ -651,9 +661,9 @@ sendaux(char **vec, int vecp, char *drft, struct stat *st) } } } - break; } + return status; } @@ -699,6 +709,24 @@ anno(struct stat *st) } +char* +strexit(int status) +{ + if (WIFSIGNALED(status)) { + return "spost or sendmail killed by signal"; + } + if (!WIFEXITED(status)) { + return "sendmail stopt for unknown reasen, message not deliverd to anyone"; + } + switch (WEXITSTATUS(status)) { + case EX_TEMPFAIL: + return "Temporary error, maby the MTA hase queued the Mail"; + default: + return "sendmail stopt for unknown reasen, message not deliverd to anyone"; + } +} + + static void armed_done(int status) { -- 1.7.10.4