diff --git a/ChangeLog.txt b/ChangeLog.txt index cf1ac6d2..8938ff7e 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -2,6 +2,10 @@ Broker: - Fix usage message only mentioning v3.1.1. Closes #1713. - Fix broker refusing to start if only websockets listeners were defined. Closes #1740. +- Change systemd unit files to create /var/log/mosquitto before starting. + Closes #821. +- Don't quit with an error if opening the log file isn't possible. + Closes #821. Client library: - Improved documentation around connect callback return codes. Close #1730. diff --git a/service/systemd/mosquitto.service.notify b/service/systemd/mosquitto.service.notify index 584a1101..84b08f84 100644 --- a/service/systemd/mosquitto.service.notify +++ b/service/systemd/mosquitto.service.notify @@ -1,5 +1,5 @@ [Unit] -Description=Mosquitto MQTT v3.1/v3.1.1 Broker +Description=Mosquitto MQTT Broker Documentation=man:mosquitto.conf(5) man:mosquitto(8) After=network.target Wants=network.target @@ -10,6 +10,8 @@ NotifyAccess=main ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure +ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto +ExecStartPre=/bin/chown mosquitto: /var/log/mosquitto [Install] WantedBy=multi-user.target diff --git a/service/systemd/mosquitto.service.simple b/service/systemd/mosquitto.service.simple index 4346ea14..d0e657e6 100644 --- a/service/systemd/mosquitto.service.simple +++ b/service/systemd/mosquitto.service.simple @@ -1,5 +1,5 @@ [Unit] -Description=Mosquitto MQTT v3.1/v3.1.1 Broker +Description=Mosquitto MQTT Broker Documentation=man:mosquitto.conf(5) man:mosquitto(8) After=network.target Wants=network.target @@ -8,6 +8,8 @@ Wants=network.target ExecStart=/usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf ExecReload=/bin/kill -HUP $MAINPID Restart=on-failure +ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto +ExecStartPre=/bin/chown mosquitto: /var/log/mosquitto [Install] WantedBy=multi-user.target diff --git a/src/logging.c b/src/logging.c index a43ca22e..c1bc10b1 100644 --- a/src/logging.c +++ b/src/logging.c @@ -114,7 +114,6 @@ int log__init(struct mosquitto__config *config) log_destinations = MQTT3_LOG_STDERR; log_priorities = MOSQ_LOG_ERR; log__printf(NULL, MOSQ_LOG_ERR, "Error: Unable to open log file %s for writing.", config->log_file); - return MOSQ_ERR_INVAL; } restore_privileges(); }