From owner-svn-src-all@FreeBSD.ORG Tue Aug 26 22:20:03 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6E33EB5B; Tue, 26 Aug 2014 22:20:03 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 593C535FE; Tue, 26 Aug 2014 22:20:03 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s7QMK3hn048662; Tue, 26 Aug 2014 22:20:03 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s7QMK2Lr048657; Tue, 26 Aug 2014 22:20:02 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201408262220.s7QMK2Lr048657@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Tue, 26 Aug 2014 22:20:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r270675 - head/usr.sbin/mailwrapper X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Aug 2014 22:20:03 -0000 Author: bapt Date: Tue Aug 26 22:20:02 2014 New Revision: 270675 URL: http://svnweb.freebsd.org/changeset/base/270675 Log: Allow mailwrapper to use mailer.conf from localbase (respecting LOCALBASE env var if set) Phabric: https://reviews.freebsd.org/D412 Reviewed by: bdrewery MFC after: 2 weeks Relnotes: yes Modified: head/usr.sbin/mailwrapper/mailwrapper.8 head/usr.sbin/mailwrapper/mailwrapper.c Modified: head/usr.sbin/mailwrapper/mailwrapper.8 ============================================================================== --- head/usr.sbin/mailwrapper/mailwrapper.8 Tue Aug 26 21:21:57 2014 (r270674) +++ head/usr.sbin/mailwrapper/mailwrapper.8 Tue Aug 26 22:20:02 2014 (r270675) @@ -31,7 +31,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd August 7, 2006 +.Dd August 27, 2014 .Dt MAILWRAPPER 8 .Os .Sh NAME @@ -109,6 +109,8 @@ utility is designed to replace and to invoke an appropriate MTA instead of .Xr sendmail 8 based on configuration information placed in +.Pa ${LOCALBASE}/etc/mail/mailer.conf +falling back on .Pa /etc/mail/mailer.conf . This permits the administrator to configure which MTA is to be invoked on the system at run time. @@ -126,6 +128,8 @@ should be turned off in Configuration for .Nm is kept in +.Pa ${LOCALBASE}/etc/mail/mailer.conf +or .Pa /etc/mail/mailer.conf . .Pa /usr/sbin/sendmail is typically set up as a symbolic link to Modified: head/usr.sbin/mailwrapper/mailwrapper.c ============================================================================== --- head/usr.sbin/mailwrapper/mailwrapper.c Tue Aug 26 21:21:57 2014 (r270674) +++ head/usr.sbin/mailwrapper/mailwrapper.c Tue Aug 26 22:20:02 2014 (r270675) @@ -35,6 +35,8 @@ #include __FBSDID("$FreeBSD$"); +#include + #include #include #include @@ -87,6 +89,8 @@ main(int argc, char *argv[], char *envp[ FILE *config; char *line, *cp, *from, *to, *ap; const char *progname; + char localmailerconf[MAXPATHLEN]; + const char *mailerconf; size_t len, lineno = 0; int i; struct arglist al; @@ -98,11 +102,18 @@ main(int argc, char *argv[], char *envp[ initarg(&al); addarg(&al, argv[0]); - if ((config = fopen(_PATH_MAILERCONF, "r")) == NULL) { + snprintf(localmailerconf, MAXPATHLEN, "%s/etc/mail/mailer.conf", + getenv("LOCALBASE") ? getenv("LOCALBASE") : "/usr/local"); + + mailerconf = localmailerconf; + if ((config = fopen(localmailerconf, "r")) == NULL) + mailerconf = _PATH_MAILERCONF; + + if (config == NULL && ((config = fopen(mailerconf, "r")) == NULL)) { addarg(&al, NULL); openlog(getprogname(), LOG_PID, LOG_MAIL); syslog(LOG_INFO, "cannot open %s, using %s as default MTA", - _PATH_MAILERCONF, _PATH_DEFAULTMTA); + mailerconf, _PATH_DEFAULTMTA); closelog(); execve(_PATH_DEFAULTMTA, al.argv, envp); err(EX_OSERR, "cannot exec %s", _PATH_DEFAULTMTA); @@ -112,7 +123,7 @@ main(int argc, char *argv[], char *envp[ for (;;) { if ((line = fparseln(config, &len, &lineno, NULL, 0)) == NULL) { if (feof(config)) - errx(EX_CONFIG, "no mapping in %s", _PATH_MAILERCONF); + errx(EX_CONFIG, "no mapping in %s", mailerconf); err(EX_CONFIG, "cannot parse line %lu", (u_long)lineno); } @@ -157,6 +168,6 @@ main(int argc, char *argv[], char *envp[ /*NOTREACHED*/ parse_error: errx(EX_CONFIG, "parse error in %s at line %lu", - _PATH_MAILERCONF, (u_long)lineno); + mailerconf, (u_long)lineno); /*NOTREACHED*/ }