[Midnightbsd-cvs] src [10468] trunk/usr.sbin/mailwrapper/mailwrapper.c: support localbase
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Wed Jun 6 20:12:29 EDT 2018
Revision: 10468
http://svnweb.midnightbsd.org/src/?rev=10468
Author: laffer1
Date: 2018-06-06 20:12:28 -0400 (Wed, 06 Jun 2018)
Log Message:
-----------
support localbase
Modified Paths:
--------------
trunk/usr.sbin/mailwrapper/Makefile
trunk/usr.sbin/mailwrapper/mailwrapper.8
trunk/usr.sbin/mailwrapper/mailwrapper.c
Property Changed:
----------------
trunk/usr.sbin/mailwrapper/mailwrapper.8
Modified: trunk/usr.sbin/mailwrapper/Makefile
===================================================================
--- trunk/usr.sbin/mailwrapper/Makefile 2018-06-07 00:10:33 UTC (rev 10467)
+++ trunk/usr.sbin/mailwrapper/Makefile 2018-06-07 00:12:28 UTC (rev 10468)
@@ -1,4 +1,5 @@
# $MidnightBSD$
+# $FreeBSD: stable/10/usr.sbin/mailwrapper/Makefile 213749 2010-10-12 21:01:26Z markm $
.include <bsd.own.mk>
Modified: trunk/usr.sbin/mailwrapper/mailwrapper.8
===================================================================
--- trunk/usr.sbin/mailwrapper/mailwrapper.8 2018-06-07 00:10:33 UTC (rev 10467)
+++ trunk/usr.sbin/mailwrapper/mailwrapper.8 2018-06-07 00:12:28 UTC (rev 10468)
@@ -1,6 +1,7 @@
+.\" $MidnightBSD$
.\" $OpenBSD: mailwrapper.8,v 1.10 2009/02/07 16:58:23 martynas Exp $
.\" $NetBSD: mailwrapper.8,v 1.11 2002/02/08 01:38:50 ross Exp $
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.sbin/mailwrapper/mailwrapper.8 293242 2016-01-06 17:48:35Z bdrewery $
.\"
.\" Copyright (c) 1998
.\" Perry E. Metzger. All rights reserved.
@@ -31,7 +32,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 +110,8 @@
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 +129,8 @@
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
Property changes on: trunk/usr.sbin/mailwrapper/mailwrapper.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/mailwrapper/mailwrapper.c
===================================================================
--- trunk/usr.sbin/mailwrapper/mailwrapper.c 2018-06-07 00:10:33 UTC (rev 10467)
+++ trunk/usr.sbin/mailwrapper/mailwrapper.c 2018-06-07 00:12:28 UTC (rev 10468)
@@ -35,6 +35,8 @@
#include <sys/cdefs.h>
__MBSDID("$MidnightBSD$");
+#include <sys/param.h>
+
#include <err.h>
#include <stdio.h>
#include <string.h>
@@ -87,6 +89,8 @@
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 @@
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 @@
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 @@
/*NOTREACHED*/
parse_error:
errx(EX_CONFIG, "parse error in %s at line %lu",
- _PATH_MAILERCONF, (u_long)lineno);
+ mailerconf, (u_long)lineno);
/*NOTREACHED*/
}
More information about the Midnightbsd-cvs
mailing list