Bug 258011 - mail/opendkim does not restart properly with "service -R"
Summary: mail/opendkim does not restart properly with "service -R"
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-23 18:14 UTC by ml
Modified: 2021-08-31 15:31 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (freebsd-ports)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ml 2021-08-23 18:14:26 UTC
When issuing "service -R", opendkim stops, but does not restart.
In syslog I see:
opendkim[...]: socket cleanup failed: Permission denied
"service milter-opendkim restart" does the job.

I tried debugging this, but so far I'm not able to see where something might lie.

This is no big trouble, but one must remember to start opendkim manually after restarting everything else.



Log when issuing "service -R":

/usr/sbin/service: DEBUG: checkyesno: apache24_configcheck_disable is set to NO.
Stopping apache24.
/usr/sbin/service: DEBUG: run_rc_command: doit: kill -TERM 81005
Waiting for PIDS: 81005.
/usr/sbin/service: DEBUG: Sourcing /usr/local/etc/rc.conf.d/clamav_freshclam
/usr/sbin/service: DEBUG: Sourcing /usr/local/etc/rc.conf.d/clamav_freshclam
Stopping clamav_freshclam.
/usr/sbin/service: DEBUG: run_rc_command: doit: su -m mailnull -c 'sh -c "kill -TERM 79370"'
Waiting for PIDS: 79370.
/usr/sbin/service: DEBUG: Sourcing /usr/local/etc/rc.conf.d/clamav_clamd
/usr/sbin/service: DEBUG: Sourcing /usr/local/etc/rc.conf.d/clamav_clamd
Stopping clamav_clamd.
/usr/sbin/service: DEBUG: run_rc_command: doit: su -m mailnull -c 'sh -c "kill -TERM 76373"'
Waiting for PIDS: 76373.
/usr/sbin/service: DEBUG: Sourcing /usr/local/etc/rc.conf.d/cyrus_imapd
/usr/sbin/service: DEBUG: Sourcing /usr/local/etc/rc.conf.d/cyrus_imapd
Stopping cyrus_imapd.
/usr/sbin/service: DEBUG: run_rc_command: doit: kill -TERM 72343
Waiting for PIDS: 72343.
/usr/sbin/service: DEBUG: run_rc_command: stop_postcmd: cyrus_imapd_poststop Stopping milteropendkim.
/usr/sbin/service: DEBUG: run_rc_command: doit: kill -TERM 84032
Waiting for PIDS: 84032.
/usr/sbin/service: DEBUG: run_rc_command: stop_postcmd: dkim_postcmd Stopping saslauthd.
/usr/sbin/service: DEBUG: run_rc_command: doit: su -m cyrus -c 'sh -c "kill -TERM 67912"'
/usr/sbin/service: DEBUG: pid file (/var/run/saslauthd/saslauthd.pid): not readable.
/usr/sbin/service: DEBUG: checkyesno: saslauthd_enable is set to YES.
Starting saslauthd.
/usr/sbin/service: DEBUG: run_rc_command: doit:  limits -C daemon  su -m cyrus -c 'sh -c "/usr/local/sbin/saslauthd -a ldap "'
/usr/sbin/service: DEBUG: pid file (/var/run/milteropendkim/pid): not readable.
/usr/sbin/service: DEBUG: checkyesno: milteropendkim_enable is set to YES.
/usr/sbin/service: DEBUG: run_rc_command: start_precmd: dkim_prepcmd Starting milteropendkim.
/usr/sbin/service: DEBUG: run_rc_command: doit:  limits -C daemon  /usr/local/sbin/opendkim  -l   -u mailnull:mailnull -P /var/run/milteropendkim/pid -x /usr/local/etc/mail/opendkim.conf    /usr/sbin/service: DEBUG: run_rc_command: start_postcmd: dkim_start_postcmd /usr/sbin/service: DEBUG: Sourcing /usr/local/etc/rc.conf.d/cyrus_imapd
/usr/sbin/service: DEBUG: pid file (/var/run/cyrus-master.pid): not readable.
/usr/sbin/service: DEBUG: checkyesno: cyrus_imapd_enable is set to YES.
Starting cyrus_imapd.
/usr/sbin/service: DEBUG: run_rc_command: doit:  limits -C daemon  /usr/local/cyrus/libexec/master -d /usr/sbin/service: DEBUG: Sourcing /usr/local/etc/rc.conf.d/clamav_clamd
/usr/sbin/service: DEBUG: checkyesno: clamav_clamd_enable is set to YES.
/usr/sbin/service: DEBUG: run_rc_command: start_precmd: clamav_clamd_precmd Starting clamav_clamd.
/usr/sbin/service: DEBUG: run_rc_command: doit:  limits -C daemon  su -m mailnull -c 'sh -c "/usr/local/sbin/clamd  "'
/usr/sbin/service: DEBUG: Sourcing /usr/local/etc/rc.conf.d/clamav_freshclam
/usr/sbin/service: DEBUG: pid file (/var/run/clamav/freshclam.pid): not readable.
/usr/sbin/service: DEBUG: checkyesno: clamav_freshclam_enable is set to YES.
/usr/sbin/service: DEBUG: run_rc_command: start_precmd: clamav_freshclam_precmd Starting clamav_freshclam.
/usr/sbin/service: DEBUG: run_rc_command: doit:  limits -C daemon  su -m mailnull -c 'sh -c "/usr/local/bin/freshclam  --daemon -p /var/run/clamav/freshclam.pid"'
/usr/sbin/service: DEBUG: checkyesno: apache24_http_accept_enable is set to NO.
/usr/sbin/service: DEBUG: checkyesno: apache24_configcheck_disable is set to NO.
/usr/sbin/service: DEBUG: pid file (/var/run/httpd.pid): not readable.
/usr/sbin/service: DEBUG: checkyesno: apache24_enable is set to YES.
/usr/sbin/service: DEBUG: run_rc_command: start_precmd: apache24_prestart /usr/sbin/service: DEBUG: checkyesno: apache24_configcheck_disable is set to NO.
Performing sanity check on apache24 configuration:
Syntax OK
/usr/sbin/service: DEBUG: checkyesno: apache24limits_enable is set to NO.
Starting apache24.
/usr/sbin/service: DEBUG: run_rc_command: doit:  limits -C daemon  /usr/local/sbin/httpd  -DNOHTTPACCEPT



Log when issuing "service milter-opendkim restart":

/usr/local/etc/rc.d/milter-opendkim: DEBUG: pid file (/var/run/milteropendkim/pid): not readable.
/usr/local/etc/rc.d/milter-opendkim: DEBUG: checkyesno: milteropendkim_enable is set to YES.
/usr/local/etc/rc.d/milter-opendkim: DEBUG: pid file (/var/run/milteropendkim/pid): not readable.
/usr/local/etc/rc.d/milter-opendkim: DEBUG: checkyesno: milteropendkim_enable is set to YES.
milteropendkim not running? (check /var/run/milteropendkim/pid).
/usr/local/etc/rc.d/milter-opendkim: DEBUG: pid file (/var/run/milteropendkim/pid): not readable.
/usr/local/etc/rc.d/milter-opendkim: DEBUG: checkyesno: milteropendkim_enable is set to YES.
/usr/local/etc/rc.d/milter-opendkim: DEBUG: run_rc_command: start_precmd: dkim_prepcmd Starting milteropendkim.
/usr/local/etc/rc.d/milter-opendkim: DEBUG: run_rc_command: doit:  limits -C daemon  /usr/local/sbin/opendkim  -l   -u mailnull:mailnull -P /var/run/milteropendkim/pid -x /usr/local/etc/mail/opendkim.conf    /usr/local/etc/rc.d/milter-opendkim: DEBUG: run_rc_command: start_postcmd: dkim_start_postcmd root@mail:~ # ps ax | grep milter
37977  -  SsJ  0:00.00 /usr/local/sbin/opendkim -l -u mailnull:mailnull -P /var/run/milteropendkim/pid -x /usr/local/etc/mail/opendkim.conf
Comment 1 ml 2021-08-31 15:31:30 UTC
After some more investigation:

1) opendkim does not start if called from /root:
I.e.
# cd /root
# mkdir /var/run/milteropendkim
# chown mailnull:mailnull /var/run/milteropendkim/
# chmod 755 /var/run/milteropendkim/
#/usr/local/sbin/opendkim -l -u mailnull:mailnull -P /var/run/milteropendkim/pid -x /usr/local/etc/mail/opendkim.conf -f
opendkim: socket cleanup failed: Permission denied
# cd /any_other_dir
#/usr/local/sbin/opendkim -l -u mailnull:mailnull -P /var/run/milteropendkim/pid -x /usr/local/etc/mail/opendkim.conf -f
(works)

I don't underestand why; possibly it's a bug upstream? I have not looked into this.



2) As a consequence, "/usr/local/etc/rc.d/milter-opendkim start" does NOT work if called from /root, but does if called from any other directory.



3) "service -R" does not set current dir (bug???), so the above still applies: if launched from /root it will fail to start milter-opendkim, while succeeding if run from any other directory.
("service milter-opendkim start" always works as /usr/sbin/service does "cd /" before calling any rc script in this case).




A simple workaround would be to put "cd /" as the second-last line of ${PREFIX}/etc/rc.d/milter-opendkim (just before 'run_rc_command "$1"').