eclipse / mosquitto

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

Relative paths in include_dir #2082

Open pierbiag opened 3 years ago

pierbiag commented 3 years ago

In the mosquitto.conf file, for the include_dir key, are relative paths allowed? If so, what's the correct sintax? E.g. can I use include_dir conf.d or include_dir ./conf.d in place of include_dir /etc/mosquitto/conf.d ?

Thanks, Pier

P.S. the reason is that i want to use the same files for a standard installation and a docker container

ralight commented 3 years ago

Yes, relative paths are allowed. Either of those examples you've suggested would work.

pierbiag commented 3 years ago

I'm having some trouble making this work.

It works fine when i use the absolute path but it doesn't seem to start when using the relative.

The full mosquitto.conf is as follows:

# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example

#pid_file /var/run/mosquitto.pid

persistence true
persistence_location /var/lib/mosquitto/

log_dest file /var/log/mosquitto/mosquitto.log
#log_dest topic

log_type error
log_type warning
log_type notice
log_type information

connection_messages true
log_timestamp true

include_dir ./conf.d

listener 1883

listener 8883
#tls_version tlsv1
cafile /etc/ssl/certs/DST_Root_CA_X3.pem
certfile /etc/letsencrypt/live/[...]/fullchain.pem
keyfile /etc/letsencrypt/live/[...]/privkey.pem

listener 18883
#tls_version tlsv1
cafile /etc/ssl/certs/DST_Root_CA_X3.pem
certfile /etc/letsencrypt/live/[...]/fullchain.pem
keyfile /etc/letsencrypt/live/[...]/privkey.pem

The log is empty when running like this, but the systemd status says "exited" rather than "running":

● mosquitto.service - LSB: mosquitto MQTT v3.1 message broker
   Loaded: loaded (/etc/init.d/mosquitto; generated; vendor preset: enabled)
   Active: active (exited) since Tue 2021-02-09 22:36:00 UTC; 6s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 31792 ExecStop=/etc/init.d/mosquitto stop (code=exited, status=0/SUCCESS)
  Process: 32190 ExecStart=/etc/init.d/mosquitto start (code=exited, status=0/SUCCESS)
      CPU: 63ms

Feb 09 22:36:00 host-1 systemd[1]: Starting LSB: mosquitto MQTT v3.1 message broker...
Feb 09 22:36:00 host-1 mosquitto[32190]: Starting network daemon:: mosquitto.
Feb 09 22:36:00 host-1 systemd[1]: Started LSB: mosquitto MQTT v3.1 message broker.

I'm on version 1.4.10 and again, the only change i made is using the relative paths instead of the absolute

ralight commented 3 years ago

If you're on 1.4.10, then I'm betting you're on Debian Stretch. If that's the case you should be aware that Debian Stretch is out of security support so you would be well advised to upgrade to something more recent.

Now, with relative paths the import point is to know where the command is being run from. If you are on Debian Stretch, then I think I'm correct in saying that the init script changes to the / directory before executing the command, so all of you paths need to be relative to there.

pierbiag commented 3 years ago

I see! Thanks! I was in the process of upgrading stuff but wanted to first migrate my config to work on a docker image. In the end I'm just changing the config files as needed.

zoechi commented 1 year ago

I tried with latest Docker image (2.0.15), but relative path didn't work for me.