# What's starting postfix?



## ph0enix (Oct 25, 2011)

I commented out 
	
	



```
postfix_enable="YES"
```
 in my rc.conf because I was seeing messages saying that postfix is already running every time I rebooted the system.  The messages went away but I want to understand the issue better.  Postfix is working as expected despite it not being enabled via rc.conf.  What's starting it?  I could see that postfix was loaded via rc.conf first, then the message would show up after the "Starting cron." line.

I'm running 8.2-RELEASE-p4, postfix-2.8.5 and dbmail-2.2.17 with clamsmtp-1.10_3.

```
clamsmtpd_enable="YES"
dbmail_lmtpd_enable="YES"
dbmail_pop3d_enable="YES"
```

inetd is explicitly disabled via:


```
inetd_enable="NO"
```

*scratching head*


----------



## SirDice (Oct 25, 2011)

Did you perhaps edit /usr/local/etc/rc.d/postfix.sh and changed the default to "YES"?


----------



## wblock@ (Oct 25, 2011)

Check /etc/crontab.


----------



## ph0enix (Oct 25, 2011)

SirDice said:
			
		

> Did you perhaps edit /usr/local/etc/rc.d/postfix.sh and changed the default to "YES"?



There is no /usr/local/etc/rc.d/postfix.sh on my system.  There is /usr/local/etc/rc.d/postfix though which I have not edited.  It contains the following:


```
#!/bin/sh
#
# $FreeBSD: ports/mail/postfix/files/postfix.sh.in,v 1.9 2010/09/13 02:09:35 sahil Exp $
#
# PROVIDE: postfix mail
# REQUIRE: LOGIN cleanvar mysql
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable postfix:
# postfix_enable (bool):        Set it to "YES" to enable postfix.
#                               Default is "NO".
# postfix_pidfile (path):       Set full path to master.pid.
#                               Default is "/var/spool/postfix/pid/master.pid".
# postfix_procname (command):   Set command that start master. Used to verify if
#                               postfix is running.
#                               Default is "/usr/local/libexec/postfix/master".
# postfix_flags (str):          Flags passed to postfix-script on startup.
#                               Default is "".
#

. /etc/rc.subr

name="postfix"
rcvar=${name}_enable

load_rc_config $name

: ${postfix_enable:="NO"}
: ${postfix_pidfile:="/var/spool/postfix/pid/master.pid"}
: ${postfix_procname:="/usr/local/libexec/postfix/master"}

start_cmd=${name}_start
stop_cmd=${name}_stop
extra_commands="reload"

pidfile=${postfix_pidfile}
procname=${postfix_procname}

postfix_start() {
        /usr/local/sbin/postfix ${postfix_flags} start
}

postfix_stop() {
        /usr/local/sbin/postfix ${postfix_flags} stop
}

run_rc_command "$1"
```


----------



## ph0enix (Oct 25, 2011)

wblock@ said:
			
		

> Check /etc/crontab.



Nothing there either:


```
# /etc/crontab - root's crontab for FreeBSD
#
# $FreeBSD: src/etc/crontab,v 1.33.2.1.6.1 2010/12/21 17:09:25 kensmith Exp $
#
SHELL=/bin/sh
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin
#
#minute hour    mday    month   wday    who     command
#
*/5     *       *       *       *       root    /usr/libexec/atrun
#
# Save some entropy so that /dev/random can re-seed on boot.
*/11    *       *       *       *       operator /usr/libexec/save-entropy
#
# Rotate log files every hour, if necessary.
0       *       *       *       *       root    newsyslog
#
# Perform daily/weekly/monthly maintenance.
1       3       *       *       *       root    periodic daily
15      4       *       *       6       root    periodic weekly
30      5       1       *       *       root    periodic monthly
#
# Adjust the time zone if the CMOS clock keeps local time, as opposed to
# UTC time.  See adjkerntz(8) for details.
1,31    0-5     *       *       *       root    adjkerntz -a
```


----------



## wblock@ (Oct 25, 2011)

Hmm: Changing Your Mail Transfer Agent.  mailwrapper(8) used to set up /etc/mail/mailwrapper.conf but not disabling sendmail could end up running Postfix once as sendmail, then again as Postfix.

Brute force:
`# find /etc -exec grep -H postfix {} \+`
`# find /usr/local/etc -exec grep -H postfix {} \+`


----------



## ph0enix (Oct 25, 2011)

wblock@ said:
			
		

> Hmm: Changing Your Mail Transfer Agent.  mailwrapper(8) used to set up /etc/mail/mailwrapper.conf but not disabling sendmail could end up running Postfix once as sendmail, then again as Postfix.
> 
> Brute force:
> `# find /etc -exec grep -H postfix {} \+`
> `# find /usr/local/etc -exec grep -H postfix {} \+`



Thank you! I added:


```
sendmail_enable="NO"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"
```

to rc.conf before 
	
	



```
postfix_enable="YES"
```
 and that did the trick.


----------



## wblock@ (Oct 25, 2011)

Woohoo!  But it doesn't matter where in /etc/rc.conf it's added, that code is all assignments.  Well, it does matter if there's more than one assignment to the same variable, but like they say in the Perl docs, don't do that.


----------



## ph0enix (Oct 25, 2011)

wblock@ said:
			
		

> Woohoo!  But it doesn't matter where in /etc/rc.conf it's added, that code is all assignments.  Well, it does matter if there's more than one assignment to the same variable, but like they say in the Perl docs, don't do that.



Good to know.  Thanks!


----------

