diff --git a/usr.sbin/mailwrapper/Makefile b/usr.sbin/mailwrapper/Makefile index 98222ae22cf..799d7e43fb7 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 5c0ddbe76ee..991757ecadc 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 diff --git a/usr.sbin/mailwrapper/mailwrapper.c b/usr.sbin/mailwrapper/mailwrapper.c index 9b57c458b16..1ad4053a843 100644 --- a/usr.sbin/mailwrapper/mailwrapper.c +++ b/usr.sbin/mailwrapper/mailwrapper.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -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;