Bug 236553 - mail/sendmail: improve mailer.conf vs. mailer.base targets
Summary: mail/sendmail: improve mailer.conf vs. mailer.base targets
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Dirk Meyer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-15 15:55 UTC by Helge Oldach
Modified: 2019-04-29 09:59 UTC (History)
1 user (show)

See Also:
dinoex: maintainer-feedback+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Helge Oldach 2019-03-15 15:55:11 UTC
mailwrapper effectively prefers ${LOCALBASE}/etc/mail/mailer.conf before looking anywhere else. This allows us to simplify and straighten the logic of the mailer.conf and mailer.base targets:

"make mailer.conf" creates a fresh ${LOCALBASE}/etc/mail/mailer.conf file, pointing to the proper locations of the port's sendmail binary, while

"make mailer.base" will simply remove this file, thereby putting the system /etc/mail/mailer.conf back in production.

Apart form simplifying the logic, this would avoid tinkering with the system mailer.conf (as it is done by the current logic).

Let me know if you'd like to see a patch as it's pretty straightforward.
Comment 1 Dirk Meyer freebsd_committer freebsd_triage 2019-03-18 11:04:08 UTC
I will test a path
Comment 2 commit-hook freebsd_committer freebsd_triage 2019-03-24 20:37:15 UTC
A commit references this bug:

Author: dinoex
Date: Sun Mar 24 20:36:28 UTC 2019
New revision: 496780
URL: https://svnweb.freebsd.org/changeset/ports/496780

Log:
  - simplify mailer.conf
  PR:		236553
  Submitted by:	Helge Oldach

Changes:
  head/mail/sendmail/Makefile
  head/mail/sendmail/pkg-message
  head/mail/sendmail/pkg-plist
Comment 3 Dirk Meyer freebsd_committer freebsd_triage 2019-03-24 20:39:09 UTC
Thanks.
Comment 4 Helge Oldach 2019-03-25 05:19:01 UTC
(In reply to commit-hook from comment #2)
Thanks.

Please note that we cannot rely on the base /etc/mail/mailer.conf and tweak that one for sendmail use, as it might be different if the system is built WITHOUT_SENDMAIL. In that case, the dma(8) style mailer.conf will be installed as /etc/mail/mailer.conf which is much shorter than sendmail's because dma(8) doesn't have newaliases, purgestat, nor hoststat.

I suggest to simply install a fixed mailer.conf for this port's use as ${PREFIX}/etc/mail/mailer.conf.sample according to pkg's sample file logic. That way, the user can revert back to the system's /etc/mail/mailer.conf by simply deleting ${PREFIX}/etc/mail/mailer.conf - but still be able to revert by restoring it from the sample file later.

Furthermore I suggest to add the -p flag to the mkdir commands, otherwise we might stumble over already existing directories.
Comment 5 Dirk Meyer freebsd_committer freebsd_triage 2019-03-30 10:39:27 UTC
(In reply to Helge Oldach from comment #4)

1)
In progress.

2)
mailer.conf.sample would conflict with other ports.
automatic activation work block use cases,
where the binaries are needed but not the service in base.

3)
Where is -p missing ?

The macro has -p included;

$ make -V MKDIR
/bin/mkdir -p
Comment 6 commit-hook freebsd_committer freebsd_triage 2019-03-30 21:15:06 UTC
A commit references this bug:

Author: dinoex
Date: Sat Mar 30 21:14:20 UTC 2019
New revision: 497361
URL: https://svnweb.freebsd.org/changeset/ports/497361

Log:
  - use independent copy of mailer.conf
  PR:		236553

Changes:
  head/mail/sendmail/Makefile
  head/mail/sendmail/files/mailer.conf
Comment 7 Helge Oldach 2019-03-31 08:13:43 UTC
(In reply to Dirk Meyer from comment #5)
Thanks!

You are of course right about ${MKDIR}.

But I still don't get the complicated logic of running sed against a ports-provided files/mailer.conf to create %PREFiX%/etc/mail/mailer.conf. Why not simply copy that file (with an in-place replacement of %PREFIX%)?

Further, the sendmail.base target would suffice to simply delete the manually generated %PREFIX%/etc/mail/mailer.conf, which would force us back to the base system's /etc/mail/mailer.conf? That's just what the "base" in the target name says...
Comment 8 Dirk Meyer freebsd_committer freebsd_triage 2019-04-04 14:37:42 UTC
The in-place replacement of %PREFIX% would take more lines in the Makefile,
and it would not work in all setups.

The sendmail.base target needs to work with the existing installations as well.
Comment 9 Helge Oldach 2019-04-04 15:27:18 UTC
(In reply to Dirk Meyer from comment #8)
True, but the current implementation of mailer.base does assume that mailer.base will revert to the base /sendmail/. That assumption is wrong in the WITHOUT_SENDMAIL case. When base has dma(8) instead of sendmail (which is a sensible option if one wants to have a simple MSA ready before installing the sendmail port), this target will break the system by creating an unusable mailer.conf as this will be pointing to the base sendmail's binaries, and these don't exist because of WITHOUT_SENDMAIL. Just deleting ${PREFIX}/etc/mail/mailer.conf however would put the specific dma(8) mailer.conf in base back to service.

These targets should be a knob switching between the base mailer (whichever it is) and this port's sendmail, and therefore between the base mailer.conf (whatever is installed in base) and this port's mailer.conf. The implicit assumption that base has sendmail is not exactly sensible, as a user specifically wants to install the sendmail port, so what is the point of having sendmail in base as well?
Comment 10 Helge Oldach 2019-04-05 11:55:08 UTC
(In reply to Dirk Meyer from comment #8)
Regarding use of %%PREFIX%% in the sample mailer.conf.sendmail: Please crosscheck with how the postfix ports does it:

files/mailer.conf.postfix indeed just employs %%PREFIX%% in order to reference the right places, and Makefile just has this trivial bit:

${INSTALL_DATA} ${WRKDIR}/mailer.conf.postfix ${STAGEDIR}${DATADIR}

That is for sure much shorter and easier to understand than space-and-tab-loaded convulsions with sed(1).
Comment 11 Dirk Meyer freebsd_committer freebsd_triage 2019-04-29 09:59:28 UTC
Copying the logic from postfix will fail.

1) This does not work without defining SUB_FILES too.

2) SUB_FILES will not work with a plain ports tree without working dir,
   making the target depend on a populated working dir create pitfalls for users.

3) Reducing this to PREFIX will fail for mailer.base too.