Bug 35371

Summary: /etc/rc virecover script starts sendmail even if sendmail should be off
Product: Base System Reporter: Michael Wardle <michael>
Component: confAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description Michael Wardle 2002-02-27 09:30:01 UTC
I installed FreeBSD on a low-end machine to make it essentially a terminal, and decided to turn off network services including sendmail.

On boot, sendmail is started by the virecover script in /etc/rc, even if sendmail is configured off.

Fix: 

The way I worked around it was to check the value of ${sendmail_enable}.  It would also be possible to check whether sendmail is running or see if there's a sendmail pid or lock file (but it doesn't seem to put one in /var/run).

I'll attach a patch when I find a form that lets me upload files.
How-To-Repeat: Turn off sendmail in /etc/rc.conf (sendmail_enable="NO"), reboot.

It's probably also necessary to have a crashed vi session.
Comment 1 setantae 2002-02-27 10:17:59 UTC
On Wed, Feb 27, 2002 at 01:23:03AM -0800, Michael Wardle wrote:

> On boot, sendmail is started by the virecover script in /etc/rc, even if sendmail is configured off.

This is the only reference to sendmail in /etc/rc :

          # Delete any recovery files that are zero length,
          # corrupted, or that have no corresponding backup file.
          # Else send mail to the user.
          recfile=`awk '/^X-vi-recover-path:/{print $2}' < "${i}"`
          if [ -n "${recfile}" -a -s "${recfile}" ]; then
                  sendmail -t < "${i}"
          else
                  rm -f "${i}"
          fi

It's sending mail, which is not quite the same as starting sendmail.

Or do you mean something else ?

Ceri
Comment 2 setantae 2002-02-27 10:40:52 UTC
On Wed, Feb 27, 2002 at 02:20:02AM -0800, Ceri wrote:

>  This is the only reference to sendmail in /etc/rc :

Whoops, I mean w.r.t. vi.recover, of course..

Ceri

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Comment 3 Crist J. Clark freebsd_committer freebsd_triage 2002-02-27 23:01:01 UTC
State Changed
From-To: open->closed

As Ceri points out, the code in question is not starting sendmail(8) 
as a daemon.
Comment 4 Michael Wardle 2002-02-28 10:18:51 UTC
1) shouldn't we test to see if sendmail is installed before calling it?
2) shouldn't it be possible to disable calling "sendmail" (particularly
   if ${sendmail_enable} is NO)?
3) is there any reason why we shouldn't call "mail" instead of
   "sendmail"? (admittedly, i don't know too much about these
utilities,
   but I thought it would be preferred to invoke a MUA rather than an
   MTA if all we wanted to do was send a message)
4) if we're going to call an MTA rather than an MUA, shouldn't we at
   least test whether it's already running
   (i don't think it's correct to invoke what seems to be a system
    utility (usually invoked as a daemon) from a shell script in this
    way -- i could be wrong) 
5) shouldn't we call whatever MTA the user has configured (e.g.
   sendmail, postfix, exim, qmail)?

I'd really like to be able to disable the behavior I mentioned in the 
original report.


__________________________________________________
Do You Yahoo!?
Yahoo! Greetings - Send FREE e-cards for every occasion!
http://greetings.yahoo.com
Comment 5 Peter Pentchev 2002-02-28 10:59:26 UTC
Oof; let GNATS know about this, too..

----- Forwarded message from Peter Pentchev <roam@ringlet.net> -----

Date: Thu, 28 Feb 2002 12:56:31 +0200
From: Peter Pentchev <roam@ringlet.net>
To: Michael Wardle <michael@endbracket.net>
Cc: freebsd-bugs@FreeBSD.org
Subject: Re: conf/35371: /etc/rc virecover script starts sendmail even if sendmail should be off
Mail-Followup-To: Michael Wardle <michael@endbracket.net>,
	freebsd-bugs@FreeBSD.org
User-Agent: Mutt/1.2.5i
In-Reply-To: <200202281020.g1SAK2R65822@freefall.freebsd.org>; from michael@endbracket.net on Thu, Feb 28, 2002 at 02:20:02AM -0800

On Thu, Feb 28, 2002 at 02:20:02AM -0800, Michael Wardle wrote:
> The following reply was made to PR conf/35371; it has been noted by GNATS.
> 
> From: Michael Wardle <michael@endbracket.net>
> To: freebsd-gnats-submit@FreeBSD.org
> Cc:  
> Subject: Re: conf/35371: /etc/rc virecover script starts sendmail even if sendmail should be off
> Date: Thu, 28 Feb 2002 02:18:51 -0800 (PST)
> 
>  1) shouldn't we test to see if sendmail is installed before calling it?

/usr/sbin/sendmail is simply a symlink to mailwrapper(8); see below.

>  2) shouldn't it be possible to disable calling "sendmail" (particularly
>     if ${sendmail_enable} is NO)?

Yes, edit your mailer.conf to run e.g. /bin/true when /usr/sbin/sendmail
is invoked :)

>  3) is there any reason why we shouldn't call "mail" instead of
>     "sendmail"? (admittedly, i don't know too much about these
>  utilities,
>     but I thought it would be preferred to invoke a MUA rather than an
>     MTA if all we wanted to do was send a message)

With the arguments it is invoked, sendmail would actually function
as a MUA; any sendmail wrappers installed by ports (e.g. qmail's
/var/qmail/bin/sendmail) would recognize that and act appropriately.

>  4) if we're going to call an MTA rather than an MUA, shouldn't we at
>     least test whether it's already running
>     (i don't think it's correct to invoke what seems to be a system
>      utility (usually invoked as a daemon) from a shell script in this
>      way -- i could be wrong) 

We are not running it as an MTA; we are only calling it as a MUA,
all it is supposed to do is (somehow) queue a message for delivery
by the actual system MTA.

>  5) shouldn't we call whatever MTA the user has configured (e.g.
>     sendmail, postfix, exim, qmail)?

Invoking /usr/sbin/sendmail actually invokes mailwrapper(8) under
the name of 'sendmail'; that is, it is exactly what you want -
invoking whatever MTA the user has chosen to install.

I suspect that a large part of the confusion here is caused by
the fact that sendmail may function as an MTA, MUA or even simply
an MSA, depending on its command-line arguments.

G'luck,
Peter

-- 
Peter Pentchev	roam@ringlet.net	roam@FreeBSD.org
PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
I am not the subject of this sentence.

----- End forwarded message -----