diff options
| author | Lexi Winter <lexi@le-Fay.ORG> | 2023-12-30 15:09:15 +0000 |
|---|---|---|
| committer | Warner Losh <imp@FreeBSD.org> | 2024-04-19 22:20:44 +0000 |
| commit | 961bcbeef251b87463446860fca9910a461a3909 (patch) | |
| tree | 19e79caece996f263a9f74f6b6bf474020d48d65 /usr.sbin/mailwrapper | |
| parent | f0bd655a615e5edad45e25c1699bd847be01f959 (diff) | |
Diffstat (limited to 'usr.sbin/mailwrapper')
| -rw-r--r-- | usr.sbin/mailwrapper/mailwrapper.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/usr.sbin/mailwrapper/mailwrapper.c b/usr.sbin/mailwrapper/mailwrapper.c index f11361f10daa..b060ff970045 100644 --- a/usr.sbin/mailwrapper/mailwrapper.c +++ b/usr.sbin/mailwrapper/mailwrapper.c @@ -42,6 +42,7 @@ #include <string.h> #include <unistd.h> #include <stdlib.h> +#include <errno.h> #include <libutil.h> #include <sysexits.h> #include <syslog.h> @@ -110,13 +111,23 @@ main(int argc, char *argv[], char *envp[]) mailerconf = _PATH_MAILERCONF; if (config == NULL && ((config = fopen(mailerconf, "r")) == NULL)) { - addarg(&al, NULL); + int serrno = errno; openlog(getprogname(), LOG_PID, LOG_MAIL); - syslog(LOG_INFO, "cannot open %s, using %s as default MTA", - mailerconf, _PATH_DEFAULTMTA); - closelog(); - execve(_PATH_DEFAULTMTA, al.argv, envp); - err(EX_OSERR, "cannot exec %s", _PATH_DEFAULTMTA); + + if (serrno == ENOENT) { + addarg(&al, NULL); + syslog(LOG_INFO, "%s does not exist, using %s as default MTA", + mailerconf, _PATH_DEFAULTMTA); + closelog(); + execve(_PATH_DEFAULTMTA, al.argv, envp); + err(EX_OSERR, "cannot exec %s", _PATH_DEFAULTMTA); + } else { + syslog(LOG_INFO, "cannot open %s: %s", + mailerconf, strerror(serrno)); + closelog(); + errno = serrno; + err(EX_OSERR, "cannot open %s", mailerconf); + } /*NOTREACHED*/ } |
