eclipse-mosquitto / mosquitto

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

Mosquitto on windows always opens files with write flag #3119

Closed DanielWorkWork closed 1 month ago

DanielWorkWork commented 1 month ago

Hey, I noticed that on windows file are always opened with the GENERIC_WRITE flag. I suggest it should be changed so it sets that flag based on the file mode.

https://github.com/eclipse/mosquitto/blob/e96ddfc6e58f7087b9fa57a717d7f56d2c00f9fe/lib/misc_mosq.c#L107

Background: We were setting up mosquitto to run on a windows VM as a service. We set up a password_file in the config and created the password_file with the personal user using mosquitto_passwd.exe. This ran fine when running as the personal user using mosquitto.exe -c mosquitto.conf, but it would not start as a service.

When we checked the permissions of the password_file, the SYSTEM account only had read and execute access to the file. After we gave the SYSTEM account write access the mosquitto service started without issue.

Now that I know it's an issue it is easy enough to workaround. But if this was fixed there would be one less pitfall to running as a service on windows.

ralight commented 1 month ago

Agreed, this seems like a pretty obvious fix.