FreeBSD Port: net/mosquitto pidfile or pid_file

Dan Langille dan at langille.org
Mon Mar 22 13:50:30 UTC 2021


On Fri, Mar 19, 2021, at 4:14 PM, Dan Langille wrote:
> Joe,
> 
> I updated my mosquitto a few days ago and today it was restarted, but 
> won't start.  I think it's related to the update.
> 
> Mar 14 01:47:40 supernews pkg[40249]: mosquitto upgraded: 1.6.7_1 -> 2.0.8
> 
> The rc.d sript for net/mosquitto greps for pidfile.
> 
> re: 
> https://svnweb.freebsd.org/ports/head/net/mosquitto/files/mosquitto.in?revision=481153&view=markup#l30
> 
> The documentation refers to pid_file, not pidfile.
> 
> re: http://mosquitto.org/man/mosquitto-conf-5.html
> 
> I think the rc.d script needs an update.  I'd help with a patch, but I 
> can't get a working solution.
> 
> $ grep pid /usr/local/etc/rc.d/mosquitto 
> pidfile=$(grep pid_file ${mosquitto_config} | awk '{print($2)}')
> echo "pidfile = '$pidfile'"
>   rm -f $pidfile
> 
> $ sudo service mosquitto start
> pidfile = '/var/run/mosquitto.pid'
> Starting mosquitto.
> 
> $ ps auwwx | grep mos
> dan        20215   0.0  0.0  11404   2260  1  S+   20:12       0:00.00 grep mos
> $ 
> 
> 
> 
> $ sudo /usr/local/sbin/mosquitto -c /usr/local/etc/mosquitto/mosquitto.conf -v
> 1616184446: Error: Unable to write pid file.
> 
> $ ls -ld /var/run
> drwxr-xr-x  15 root  wheel  1024 Mar 19 20:12 /var/run
> 
> $ ls -l /var/run/mosquitto.pid
> ls: /var/run/mosquitto.pid: No such file or directory

Solved.  At least for me.

In addition to the rc.d file change:

$ sudo mkdir /var/run/mosquitto
$ sudo chown mosquitto:mosquitto /var/run/mosquitto

Adjust /usr/local/etc/mosquitto/mosquitto.conf to use this new pid file location.


Alter passwd file permissions:

$ sudo chgrp mosquitto /usr/local/etc/mosquitto/mosquitto.passwd


Modify certificate permissions:

$ ls -l /us/usr/local/etc/ssl/example.org.key
-rw-------  1 root  wheel  1675 Apr 11  2018 /usr/local/etc/ssl/example.org.key
$ sudo chgrp mosquitto /usr/local/etc/ssl/example.org.key
$ sudo chmod g+r /usr/local/etc/ssl/example.org.key
$ ls -l /usr/local/etc/ssl/example.org.key
-rw-r-----  1 root  mosquitto  1675 Apr 11  2018 /usr/local/etc/ssl/example.org.key


Why all this? It seems that mosquitto is now dropping privs before writing the PID file and before reading the certificate and password files.

Hope this helps

-- 
  Dan Langille
  dan at langille.org


More information about the freebsd-ports mailing list