mosquitto
mosquitto copied to clipboard
Support tilde character as HOME in config paths
- [X] If you are contributing a new feature, is your work based off the develop branch?
- [ ] If you are contributing a bugfix, is your work based off the fixes branch?
- [X] Have you added an explanation of what your changes do and why you'd like us to include them?
- [X] Have you successfully run
make testwith your changes locally? - [X] Have you signed the Eclipse Contributor Agreement, using the same email address as you used in your commits?
- [X] Do each of your commits have a "Signed-off-by" line, with the correct email address? Use "git commit -s" to generate this line for you.
This feature provides path expansion for the log file path when reading the mosquitto broker configuration. It expands the tilde character (~) to the home directory of the current user.
e.g.
log_dest file ~/log/mosquitto.log
I fear the implementation of this may be a bit trickier than what you've got. At the moment you only look for ~ in the first character. If I use ~roger/mosquitto.log then I'll get unexpected results. It's not unreasonable to assume that if ~/ works then ~roger/ would work as well. Going down the full route of all user paths being expanded is a lot of complexity I wouldn't want to get into just for tilde substitution.
As it stands, I'm not sure about whether this is something to merge. As a minimum it would have to check for ~/, not just ~. I would also want it to work for other config paths as well. I need a bit of convincing that this is widely worthwhile as well, so go on, persuade me.
For reference, if you do pull requests in the future here or anywhere else, and you have to modify them, then you can do the following:
# Make changes needed
git add file.c
git commit --amend
git push -f
This updates the existing commit and the pull request copes with it correctly.
@ralight Thank you for your feedback.
You are absolutely right. We implemented all your suggestions in the updated PR.
In our current setup we are not able to use a relative path in the mosquitto configuration because we can not control from which current directory it will be started. We also cannot use an absolute path because the broker with the same configuration is started on different machines with different users.
We already implemented a workaround with a shell script as wrapper which changes the current directory to the users HOME and use a relative path in the configuration.
But we think it would be nice if mosquitto could provide path expansion. We are sure this feature would also be interesting for others too.
Is this commit also considering the "user" in mosquitto.conf?