New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mosquitto silently fails if there is no permission to write the log file and is binding on a priveleged port #234

Closed
mtreinish opened this Issue Aug 2, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@mtreinish

mtreinish commented Aug 2, 2016

If you enable a listener on a privileged port (like port 80) and set the log_dest file to be a path where the user doesn't have write permissions mosquitto will silently fail. There is no output anywhere (logfile, stdout, stderr, etc) and the return code is 1. This looks to be because it only outputs to the log file if that's the only log_dest that's set.

An easy reproduce is create a mosquitto.conf with:

log_dest file /var/log/mosquitto
listener 80

and then run:

sudo mosquitto -c mosquitto.conf

an strace will show the error is an EACCES on the bind:

bind(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("0.0.0.0")}, 16) = -1 EACCES (Permission denied)

but it works fine if you have write access to the file, like if change /var/log/mosquitto to /tmp/mosquitto.

I believe what is happening is that mosquitto is trying to write an error messages to the log file but doesn't have permission to write it and just exits. We probably should add a failback in this case and make sure we dump the errors to stderr (or stdout) if we fail to start and can't write to the log file.

@ralight ralight added this to the Fixes-next milestone Aug 8, 2016

@ralight ralight self-assigned this Aug 8, 2016

@ralight

This comment has been minimized.

Show comment
Hide comment
@ralight

ralight Aug 8, 2016

Contributor

Agreed, your analysis makes sense so adding the fallback would be a good approach.

Contributor

ralight commented Aug 8, 2016

Agreed, your analysis makes sense so adding the fallback would be a good approach.

ralight added a commit that referenced this issue Aug 16, 2016

@ralight

This comment has been minimized.

Show comment
Hide comment
@ralight

ralight Aug 16, 2016

Contributor

Thanks, I've pushed a commit to fix this.

Contributor

ralight commented Aug 16, 2016

Thanks, I've pushed a commit to fix this.

@ralight ralight closed this Aug 16, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment