From 94978ac89ba6a2c385b5b231c40d879a635365ab Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Tue, 27 Jun 2017 09:57:47 +0100 Subject: [PATCH] Restore old umask after creating file. --- lib/util_mosq.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/util_mosq.c b/lib/util_mosq.c index 3281a579..055b310a 100644 --- a/lib/util_mosq.c +++ b/lib/util_mosq.c @@ -404,9 +404,17 @@ FILE *_mosquitto_fopen(const char *path, const char *mode, bool restrict_read) } #else if (restrict_read) { - umask(0700); + FILE *fptr; + mode_t old_mask; + + old_mask = umask(0700); + fptr = fopen(path, mode); + umask(old_mask); + + return fptr; + }else{ + return fopen(path, mode); } - return fopen(path, mode); #endif }