]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tmpfile-util: modernize mkostemp_safe() a bit
authorLennart Poettering <lennart@poettering.net>
Thu, 4 Jul 2019 14:48:32 +0000 (16:48 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 4 Dec 2019 09:59:30 +0000 (10:59 +0100)
src/basic/tmpfile-util.c

index 89fae1c45346d898a66d3bfd43177519a1d0e907..2d201e1a57f34d918e7a84c3a6d3d437d7306f2c 100644 (file)
@@ -67,12 +67,12 @@ int fopen_temporary(const char *path, FILE **ret_f, char **ret_temp_path) {
 
 /* This is much like mkostemp() but is subject to umask(). */
 int mkostemp_safe(char *pattern) {
-        _unused_ _cleanup_umask_ mode_t u = umask(0077);
         int fd;
 
         assert(pattern);
 
-        fd = mkostemp(pattern, O_CLOEXEC);
+        RUN_WITH_UMASK(0077)
+                fd = mkostemp(pattern, O_CLOEXEC);
         if (fd < 0)
                 return -errno;