X-Git-Url: http://git.marmaro.de/?a=blobdiff_plain;f=uip%2Fsend.c;h=c2c9f17828e13f5337a87adc3c57d0cc790713f9;hb=1e42112bb983f886f389b1fa3ef4d90a4dad4f91;hp=e1e751866243e2e363c1eada0e513b56c058c7f6;hpb=5b093c3d779ddbbd09a233c8cf7a20c0d0d15d1c;p=mmh diff --git a/uip/send.c b/uip/send.c index e1e7518..c2c9f17 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,7 +24,7 @@ #include int debugsw = 0; /* global */ -char *altmsg = NULL; +char *altmsg = NULL; char *annotext = NULL; char *distfile = NULL; @@ -50,6 +52,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[] = { @@ -442,8 +445,8 @@ attach(char *draft_file_name) fclose(composition_file); /* We're ready to roll! */ - sprintf(buf, "mhbuild %s", composition_file_name); - if (system(buf) != 0) { + if (execprogl("mhbuild", "mhbuild", composition_file_name, + (char *)NULL) != 0) { /* some problem */ clean_up_temporary_files(); return (NOTOK); @@ -463,6 +466,7 @@ signandenc(char *draft_file_name) char buf[BUFSIZ]; int dosign = 0; int doenc = 0; + int ret; if (!(draft_file = fopen(draft_file_name, "r"))) { adios(NULL, "can't open draft file `%s'.", draft_file_name); @@ -489,9 +493,14 @@ signandenc(char *draft_file_name) strcpy(composition_file_name, draft_file_name); /* We're ready to roll! */ - sprintf(buf, "mhsign -m%s '%s'", doenc ? " -e" : "", - draft_file_name); - if (system(buf) != 0) { + if (doenc) { + ret = execprogl("mhsign", "mhsign", "-m", "-e", + draft_file_name, (char *)NULL); + } else { + ret = execprogl("mhsign", "mhsign", "-m", + draft_file_name, (char *)NULL); + } + if (ret != 0) { /* some problem */ return (NOTOK); } @@ -636,13 +645,14 @@ 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"); + advise(NULL, "%s", strexit(status)); 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 "message not delivered to anyone"; + } + switch (WEXITSTATUS(status)) { + case EX_TEMPFAIL: + return "Temporary error, maybe the MTA has queued the message"; + default: + return "message not delivered to anyone"; + } +} + + static void armed_done(int status) {