diff options
author | 2018-12-09 20:42:50 +0100 | |
---|---|---|
committer | 2018-12-09 20:42:50 +0100 | |
commit | d6d9e3e9cc455ac52647bfb4af99a0f8e6693622 (patch) | |
tree | f96dbba82e34f8c1d75b4556fc72715e4dd4e358 /smtpd/mail.mda.c | |
parent | Merge branch 'master' into portable (diff) | |
parent | sync (diff) | |
download | OpenSMTPD-d6d9e3e9cc455ac52647bfb4af99a0f8e6693622.tar.xz OpenSMTPD-d6d9e3e9cc455ac52647bfb4af99a0f8e6693622.zip |
Merge branch 'master' into portable
Diffstat (limited to 'smtpd/mail.mda.c')
-rw-r--r-- | smtpd/mail.mda.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/smtpd/mail.mda.c b/smtpd/mail.mda.c index ce27f05a..23958071 100644 --- a/smtpd/mail.mda.c +++ b/smtpd/mail.mda.c @@ -18,6 +18,7 @@ #include <sys/types.h> #include <sys/stat.h> +#include <sys/wait.h> #include <ctype.h> #include <err.h> @@ -28,12 +29,14 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sysexits.h> #include <unistd.h> int main(int argc, char *argv[]) { int ch; + int ret; if (! geteuid()) errx(1, "mail.mda: may not be executed as root"); @@ -53,5 +56,15 @@ main(int argc, char *argv[]) if (argc > 1) errx(1, "mail.mda: only one command is supported"); - return system(argv[0]) == 0 ? 0 : 1; + /* could not obtain a shell or could not obtain wait status, + * tempfail */ + if ((ret = system(argv[0])) == -1) + errx(EX_TEMPFAIL, "%s", strerror(errno)); + + /* not exited properly but we have no details, + * tempfail */ + if (! WIFEXITED(ret)) + exit(EX_TEMPFAIL); + + exit(WEXITSTATUS(ret)); } |