eclipse-mosquitto / mosquitto

Eclipse Mosquitto - An open source MQTT broker
https://mosquitto.org
Other
9.13k stars 2.41k forks source link

Let systemd create directories #3122

Open gchamp20 opened 1 month ago

gchamp20 commented 1 month ago

Context

Manually creating directories conflicts with systemd service hardening features. Particularly, ProtectSystem=strict mounts the filesystem has read-only for the processes started by the unit which leads to mkdir failing.

By setting User=mosquitto and adding RuntimeDirectory and LogsDirectory, systemd creates /run/mosquitto and /var/log/mosquitto with the right permissions even ProtectSystem=strict is used.

Adding User=mosquitto also has the side effect of running the daemon as the user mosquitto. I

Checklist