From 2b2afc93bce07f39d1eb1bc7575cb1f5fedd83a8 Mon Sep 17 00:00:00 2001 From: Roger Light Date: Wed, 3 Jul 2019 09:50:59 +0100 Subject: [PATCH] Allow other apps access to log file on Windows. This change means that users with the appropriate security permissions can open the log file for reading at the same time that it is being written. Closes #515. --- ChangeLog.txt | 3 +++ lib/util_mosq.c | 2 +- readme-windows.txt | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 5282e1dc..53a3dc13 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -4,6 +4,9 @@ Broker: - Fix persistent clients being incorrectly expired on Raspberry Pis. Closes #1272. +- Windows: Allow other applications access to the log file when running. + Closes #515. + 1.6.3 - 20190618 ================ diff --git a/lib/util_mosq.c b/lib/util_mosq.c index 5e1065e7..65fc2215 100644 --- a/lib/util_mosq.c +++ b/lib/util_mosq.c @@ -248,7 +248,7 @@ FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read) sec.bInheritHandle = FALSE; sec.lpSecurityDescriptor = &sd; - hfile = CreateFile(buf, GENERIC_READ | GENERIC_WRITE, 0, + hfile = CreateFile(buf, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, &sec, dwCreationDisposition, FILE_ATTRIBUTE_NORMAL, diff --git a/readme-windows.txt b/readme-windows.txt index 9325a4c9..7bf0d954 100644 --- a/readme-windows.txt +++ b/readme-windows.txt @@ -61,3 +61,11 @@ command line as follows: C:\Program Files\mosquitto\mosquitto install C:\Program Files\mosquitto\mosquitto uninstall + +Logging +------- + +If you use `log_dest file ...` in your configuration, the log file will be +created with security permissions for the current user only. If running as a +service, this means the SYSTEM user. You will only be able to view the log file +if you add permissions for yourself or whatever user you wish to view the logs.