Skip to content

Commit

Permalink
Allow broker to always restart on Windows when using log_dest file.
Browse files Browse the repository at this point in the history
Closes #1080. Thanks to lcouz.
  • Loading branch information
ralight committed Feb 3, 2019
1 parent 5df00f6 commit 927c2aa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Broker:
- Handle mismatched handshakes (e.g. QoS1 PUBLISH with QoS2 reply) properly.
- Fix spaces not being allowed in the bridge remote_username option. Closes
#1131.
- Allow broker to always restart on Windows when using `log_dest file`. Closes
#1080.

Library:
- Fix TLS connections not working over SOCKS.
Expand Down
17 changes: 16 additions & 1 deletion lib/util_mosq.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,21 @@ FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read)
char username[UNLEN + 1];
int ulen = UNLEN;
SECURITY_DESCRIPTOR sd;
DWORD dwCreationDisposition;

switch(mode[0]){
case 'a':
dwCreationDisposition = OPEN_ALWAYS;
break;
case 'r':
dwCreationDisposition = OPEN_EXISTING;
break;
case 'w':
dwCreationDisposition = CREATE_ALWAYS;
break;
default:
return NULL;
}

GetUserName(username, &ulen);
if (!InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION)) {
Expand All @@ -424,7 +439,7 @@ FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read)

hfile = CreateFile(buf, GENERIC_READ | GENERIC_WRITE, 0,
&sec,
CREATE_NEW,
dwCreationDisposition,
FILE_ATTRIBUTE_NORMAL,
NULL);

Expand Down

0 comments on commit 927c2aa

Please sign in to comment.