aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/mailwrapper
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2018-01-02 16:50:57 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2018-01-02 16:50:57 +0000
commit8b081eaa55b1eb7a457f7bf43be5997a1fef3ac0 (patch)
tree98df16da0f60f4fbac376f0189e7343e4195e7f9 /usr.sbin/mailwrapper
parent0316d485877320b746a94182b49d0d3ddcee332b (diff)
Notes
Diffstat (limited to 'usr.sbin/mailwrapper')
-rw-r--r--usr.sbin/mailwrapper/Makefile2
-rw-r--r--usr.sbin/mailwrapper/Makefile.depend3
-rw-r--r--usr.sbin/mailwrapper/mailwrapper.c18
3 files changed, 10 insertions, 13 deletions
diff --git a/usr.sbin/mailwrapper/Makefile b/usr.sbin/mailwrapper/Makefile
index 98222ae22cfc..799d7e43fb71 100644
--- a/usr.sbin/mailwrapper/Makefile
+++ b/usr.sbin/mailwrapper/Makefile
@@ -5,6 +5,8 @@
.if ${MK_MAILWRAPPER} != "no"
PROG= mailwrapper
MAN= mailwrapper.8
+
+LIBADD= util
.endif
.if ${MK_MAILWRAPPER} != "no" || ${MK_SENDMAIL} != "no"
diff --git a/usr.sbin/mailwrapper/Makefile.depend b/usr.sbin/mailwrapper/Makefile.depend
index 5c0ddbe76ee3..991757ecadc0 100644
--- a/usr.sbin/mailwrapper/Makefile.depend
+++ b/usr.sbin/mailwrapper/Makefile.depend
@@ -7,7 +7,8 @@ DIRDEPS = \
include/xlocale \
lib/${CSU_DIR} \
lib/libc \
- lib/libcompiler_rt
+ lib/libcompiler_rt \
+ lib/libutil \
.include <dirdeps.mk>
diff --git a/usr.sbin/mailwrapper/mailwrapper.c b/usr.sbin/mailwrapper/mailwrapper.c
index 9b57c458b165..1ad4053a843e 100644
--- a/usr.sbin/mailwrapper/mailwrapper.c
+++ b/usr.sbin/mailwrapper/mailwrapper.c
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
+#include <libutil.h>
#include <sysexits.h>
#include <syslog.h>
@@ -88,17 +89,14 @@ int
main(int argc, char *argv[], char *envp[])
{
FILE *config;
- char *line, *cp, *from, *to, *ap, *walk;
+ char *line, *cp, *from, *to, *ap;
const char *progname;
char localmailerconf[MAXPATHLEN];
const char *mailerconf;
- size_t linecap = 0, lineno = 0;
- ssize_t linelen;
+ size_t len, lineno = 0;
int i;
struct arglist al;
- line = NULL;
-
/* change __progname to mailwrapper so we get sensible error messages */
progname = getprogname();
setprogname("mailwrapper");
@@ -125,16 +123,12 @@ main(int argc, char *argv[], char *envp[])
}
for (;;) {
- if ((linelen = getline(&line, &linecap, config)) <= 0) {
- if (feof(config)) {
+ if ((line = fparseln(config, &len, &lineno, NULL, 0)) == NULL) {
+ if (feof(config))
errx(EX_CONFIG, "no mapping in %s", mailerconf);
- }
err(EX_CONFIG, "cannot parse line %lu", (u_long)lineno);
}
- lineno++;
- walk = line;
- /* strip comments */
- strsep(&walk, "#");
+
#define WS " \t\n"
cp = line;