Re: [patch] mailwrapper: remove broken fallback code

2015-12-08 Thread Sunil Nimmagadda
> If /etc/mailer.conf doesn't exist, mailwrapper tries to run sendmail,
> giving a confusing error message:
> 
> mailwrapper: cannot exec /usr/libexec/sendmail/sendmail: No such
> file or directory
> 
> This patch removes this fallback code. I believe this is cleaner than
> updating the fallback since we would have to put two paths in: one for
> sendmail/send-mail/mailq and one for makemap/newaliases.

I am not sure about removing the fallback code but if we decide to
keep it, this diff should fix the fallback case.

Index: mailwrapper.c
===
RCS file: /cvs/src/usr.sbin/mailwrapper/mailwrapper.c,v
retrieving revision 1.20
diff -u -p -r1.20 mailwrapper.c
--- mailwrapper.c   12 Oct 2015 22:01:08 -  1.20
+++ mailwrapper.c   8 Dec 2015 09:36:18 -
@@ -41,7 +41,7 @@
 #include 
 
 #define _PATH_MAILERCONF   "/etc/mailer.conf"
-#define _PATH_DEFAULTMTA   "/usr/libexec/sendmail/sendmail"
+#define _PATH_DEFAULTMTA   "/usr/sbin/smtpctl"
 
 struct arglist {
size_t argc, maxc;



Re: [patch] mailwrapper: remove broken fallback code

2015-12-08 Thread Joerg Jung

> On 08 Dec 2015, at 10:39, Sunil Nimmagadda  wrote:
> 
>> If /etc/mailer.conf doesn't exist, mailwrapper tries to run sendmail,
>> giving a confusing error message:
>> 
>> mailwrapper: cannot exec /usr/libexec/sendmail/sendmail: No such
>> file or directory
>> 
>> This patch removes this fallback code. I believe this is cleaner than
>> updating the fallback since we would have to put two paths in: one for
>> sendmail/send-mail/mailq and one for makemap/newaliases.
> 
> I am not sure about removing the fallback code but if we decide to
> keep it, this diff should fix the fallback case.

ok jung@ for the fix below.

I’m also unsure about the fallback code. It was introduced with -r1.4 more than 
16 yrs ago. However, I fail to understand what’s the point of it? I mean why 
running mailwrapper without a config file, that does not make much sense 
and defeats it's purpose, right? AFAIU, the mailer.conf is a must-have,
so the proposed removal of the fallback code makes sense to me.

> Index: mailwrapper.c
> ===
> RCS file: /cvs/src/usr.sbin/mailwrapper/mailwrapper.c,v
> retrieving revision 1.20
> diff -u -p -r1.20 mailwrapper.c
> --- mailwrapper.c 12 Oct 2015 22:01:08 -  1.20
> +++ mailwrapper.c 8 Dec 2015 09:36:18 -
> @@ -41,7 +41,7 @@
> #include 
> 
> #define _PATH_MAILERCONF  "/etc/mailer.conf"
> -#define _PATH_DEFAULTMTA "/usr/libexec/sendmail/sendmail"
> +#define _PATH_DEFAULTMTA "/usr/sbin/smtpctl"
> 
> struct arglist {
>   size_t argc, maxc;
> 



Re: [patch] mailwrapper: remove broken fallback code

2015-12-08 Thread Serguey Parkhomovsky
On Tue, Dec 08, 2015 at 10:39:56AM +0100, Sunil Nimmagadda wrote:
> > If /etc/mailer.conf doesn't exist, mailwrapper tries to run sendmail,
> > giving a confusing error message:
> > 
> > mailwrapper: cannot exec /usr/libexec/sendmail/sendmail: No such
> > file or directory
> > 
> > This patch removes this fallback code. I believe this is cleaner than
> > updating the fallback since we would have to put two paths in: one for
> > sendmail/send-mail/mailq and one for makemap/newaliases.
> 
> I am not sure about removing the fallback code but if we decide to
> keep it, this diff should fix the fallback case.

Good catch; I didn't realize you could also call newaliases/makemap
through /usr/sbin/smtpctl.

If we choose to keep the fallback code, we should probably fix the
manpage for mailwrapper as well. I've attached a revised version of your
patch that documents the fallback behavior.

Index: mailwrapper.8
===
RCS file: /cvs/src/usr.sbin/mailwrapper/mailwrapper.8,v
retrieving revision 1.12
diff -u -p -r1.12 mailwrapper.8
--- mailwrapper.8   27 Mar 2014 22:34:42 -  1.12
+++ mailwrapper.8   8 Dec 2015 16:32:01 -
@@ -120,9 +120,11 @@ is typically set up as a symlink to
 which is not usually invoked on its own.
 .Sh DIAGNOSTICS
 .Nm
-will return an error value and print a diagnostic if its configuration
-file is missing or malformed, or does not contain a mapping for the
-name under which
+will invoke
+.Xr smtpd 8
+if its configuration file is missing.
+It will return an error value and print a diagnostic if its configuration
+file is malformed, or does not contain a mapping for the name under which
 .Nm
 was invoked.
 .Sh SEE ALSO
Index: mailwrapper.c
===
RCS file: /cvs/src/usr.sbin/mailwrapper/mailwrapper.c,v
retrieving revision 1.20
diff -u -p -r1.20 mailwrapper.c
--- mailwrapper.c   12 Oct 2015 22:01:08 -  1.20
+++ mailwrapper.c   8 Dec 2015 16:32:01 -
@@ -41,7 +41,7 @@
 #include 
 
 #define _PATH_MAILERCONF   "/etc/mailer.conf"
-#define _PATH_DEFAULTMTA   "/usr/libexec/sendmail/sendmail"
+#define _PATH_DEFAULTMTA   "/usr/sbin/smtpctl"
 
 struct arglist {
size_t argc, maxc;



[patch] mailwrapper: remove broken fallback code

2015-12-07 Thread Serguey Parkhomovsky
If /etc/mailer.conf doesn't exist, mailwrapper tries to run sendmail,
giving a confusing error message:

mailwrapper: cannot exec /usr/libexec/sendmail/sendmail: No such
file or directory

This patch removes this fallback code. I believe this is cleaner than
updating the fallback since we would have to put two paths in: one for
sendmail/send-mail/mailq and one for makemap/newaliases.

Index: mailwrapper.c
===
RCS file: /cvs/src/usr.sbin/mailwrapper/mailwrapper.c,v
retrieving revision 1.20
diff -u -p -r1.20 mailwrapper.c
--- mailwrapper.c   12 Oct 2015 22:01:08 -  1.20
+++ mailwrapper.c   7 Dec 2015 21:33:57 -
@@ -36,12 +36,10 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 
 #define _PATH_MAILERCONF   "/etc/mailer.conf"
-#define _PATH_DEFAULTMTA   "/usr/libexec/sendmail/sendmail"
 
 struct arglist {
size_t argc, maxc;
@@ -100,21 +98,11 @@ main(int argc, char *argv[], char *envp[
for (len = 0; len < argc; len++)
addarg(, argv[len], 0);
 
-   config = fopen(_PATH_MAILERCONF, "r");
+   if ((config = fopen(_PATH_MAILERCONF, "r")) == NULL)
+   err(1, "cannot open %s", _PATH_MAILERCONF);
 
if (pledge("stdio exec", NULL) == -1)
err(1, "pledge");
-
-   if (config == NULL) {
-   addarg(, NULL, 0);
-   openlog(__progname, LOG_PID, LOG_MAIL);
-   syslog(LOG_INFO, "cannot open %s, using %s as default MTA",
-   _PATH_MAILERCONF, _PATH_DEFAULTMTA);
-   closelog();
-   execve(_PATH_DEFAULTMTA, al.argv, envp);
-   err(1, "cannot exec %s", _PATH_DEFAULTMTA);
-   /*NOTREACHED*/
-   }
 
for (;;) {
if ((line = fparseln(config, , , NULL, 0)) == NULL) {