From 8642f7867d800e616b1e079d86bcd47c561dd41a Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Sep 26 2018 19:22:14 +0000 Subject: lock_file_create: Set and reset umask before and after creating the lockfile Merges: https://pagure.io/libuser/issue/25 This is not a big deal, but static analyzers are happier when umask is set explicitly. --- diff --git a/modules/files.c b/modules/files.c index 6a7787e..2d049f8 100644 --- a/modules/files.c +++ b/modules/files.c @@ -287,11 +287,14 @@ lock_file_create(const char *filename, struct lu_error **error) char pid_string[sizeof (pid_t) * CHAR_BIT + 1]; int fd; gboolean ret = FALSE; + mode_t old_umask; lock_filename = g_strconcat(filename, ".lock", NULL); tmp_filename = g_strdup_printf("%s.lock.XXXXXX", filename); + old_umask = umask(0177); fd = mkstemp(tmp_filename); + umask(old_umask); if (fd == -1) { lu_error_new(error, lu_error_open, _("error opening temporary file for `%s': %s"),