From nobody Fri Apr 19 22:34:05 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VLqF95SnWz5Hsrj; Fri, 19 Apr 2024 22:34:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VLqF94tRrz4JZk; Fri, 19 Apr 2024 22:34:05 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713566045; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jII6fwA5e71JYlMcrEUglimX7ClfLumPKFoy6NHu0F0=; b=ng5FV58CiiIrIdZyzUKosLRMLoVD6FWucA0FRlVycCLpKF/3emjeyO4eR8Dy+v68jbamAh iGuZ3m/KxKlA0BjJl2whlAn5d6Bf1+XsPqDd9o2zA1HhisjpZk+eKAPYB4zOyBIeejN2VC w3sfUGSegnJPp5uWaFhBMScFeI3TnmsQNijFZyH10H4GZibU91YklamoNVfrAKms8FVwxl g1XUNGPLa6XWEy9arDvSIgnBuYuLDIOtOvRqcyJ8YynjmF+xcWXzpQOE7eqMaAiWHrrev8 fJNV4xJVxo6LsAKYslQCDau+lfB3mXsfdPO8DphSUMRPRmFlMlTiD7kBm183LQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713566045; a=rsa-sha256; cv=none; b=cvKB88CHA4Q92QkgDxObalRE7oG2l34EHcdQyVy6CuZjNpLR9ecMAI/a7LyTEOuXVro/Q+ cO7Savsi6mzok0hZ1DUxXfDHn6yyn+3TX92UTu7S1l3rYuz2ohqLByzOhybzd1lOgfRqu1 4sH3L9ErNi2c7x1uoFmDMOchFJY9ONlbD47WxKRgt16Zyyremi3WSnZfONmLUjJwraWRgR LKulI/BMnuwlX6KnjUXElEKOPQ17McaI/GdZm7COR5JXGWWYtVZjMA4o7mwMYtK2WAXJMX mE4JIyRo62W3Afrb+qUcwSP7V6sVxl4Pcxfja3/aNC2D8w829nyp31OtMaTXCw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713566045; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jII6fwA5e71JYlMcrEUglimX7ClfLumPKFoy6NHu0F0=; b=lWa7YkireW9H53YT8lGwyVumPULUqhvDeZVgTc5EHUnmhz2LFh0VFY2412ph33nzZ++aVk WscE96AZnEnhVC14iAh89LP952dZT4Dh5xywi3fqc4vOfA54SdlJGixEBlp9u0ccIpkDqG CwVNexM15pZ5EHwdiKb9In1P0eB94sv/MUZbXCnpcM9hXWRQoq5rcGguS95ucmayF0D9hY QdHoFvT1IjZNGOuwoMIwvr7XEl38cCsRDSTu97z6lG4K9+FbpeKMROnEaKYDabYjwBS2wQ +/XzQDL9CYTvjiRMaHi8VerfGcZjgK3IWrsLB3Vg9zxW2PWz6y/dXknVnLX13Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VLqF94TKRz1B24; Fri, 19 Apr 2024 22:34:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43JMY5Tl092520; Fri, 19 Apr 2024 22:34:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43JMY5vv092517; Fri, 19 Apr 2024 22:34:05 GMT (envelope-from git) Date: Fri, 19 Apr 2024 22:34:05 GMT Message-Id: <202404192234.43JMY5vv092517@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 961bcbeef251 - main - mailwrapper(8): change behaviour if mailer.conf cannot be opened List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 961bcbeef251b87463446860fca9910a461a3909 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=961bcbeef251b87463446860fca9910a461a3909 commit 961bcbeef251b87463446860fca9910a461a3909 Author: Lexi Winter AuthorDate: 2023-12-30 15:09:15 +0000 Commit: Warner Losh CommitDate: 2024-04-19 22:20:44 +0000 mailwrapper(8): change behaviour if mailer.conf cannot be opened Previously, mailwrapper(8) would default to invoking _PATH_DEFAULTMTA (i.e., dma) if mailer.conf couldn't be opened for any reason, including transient errors like ENFILE. This behaviour is undesirable, because if the administrator has configured a different MTA in mailer.conf, they almost certainly don't want mailwrapper to unpredictably fall back to the compiled-in default; and in any case, the default MTA is probably not running, meaning the mail may be queued and then never delivered, which is worse than not accepting it to begin with. Change this behaviour depending on why mailer.conf can't be opened: - If it doesn't exist, keep the existing behaviour of falling back to the default MTA, on the assumption that this is a reasonable default if mailer.conf hasn't been configured at all. - If it cannot be opened for any other reason, do not invoke an MTA and instead return an error to the caller. PR: 25218 Reviewed by: imp, emaste, markj Pull Request: https://github.com/freebsd/freebsd-src/pull/969 --- usr.sbin/mailwrapper/mailwrapper.c | 23 +++++++++++++++++------ 1 file 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 #include #include +#include #include #include #include @@ -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*/ }