Also I installed the attached, which I hope ameliorate the issue.
From 2fecd6061b08b0215a2b1cfe4f3d7e7781bd959d Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Fri, 17 Oct 2025 23:20:06 -0700
Subject: [PATCH 1/3] =?UTF-8?q?MKDIR=5FUMASK=20=E2=86=92=20MKDIR=5FPERMS?=
 =?UTF-8?q?=20refactoring?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* zic.c (MKDIR_PERMS): Rename from MKDIR_UMASK since these are
permission bits, not a umask (the negation of permission bits).
All uses changed.
---
 zic.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/zic.c b/zic.c
index 109dbef8..bcaa27cb 100644
--- a/zic.c
+++ b/zic.c
@@ -65,9 +65,9 @@ enum { FORMAT_LEN_GROWTH_BOUND = 5 };
 # include <sys/stat.h>
 #endif
 #ifdef S_IRUSR
-# define MKDIR_UMASK (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
+# define MKDIR_PERMS (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
 #else
-# define MKDIR_UMASK 0755
+# define MKDIR_PERMS 0755
 #endif
 
 /* The minimum alignment of a type, for pre-C23 platforms.
@@ -3982,7 +3982,7 @@ mkdirs(char const *argname, bool ancestors)
 		** not check first whether it already exists, as that
 		** is checked anyway if the mkdir fails.
 		*/
-		if (mkdir(name, MKDIR_UMASK) != 0) {
+		if (mkdir(name, MKDIR_PERMS) < 0) {
 			/* Do not report an error if err == EEXIST, because
 			   some other process might have made the directory
 			   in the meantime.  Likewise for ENOSYS, because
-- 
2.48.1

From 242a8338f707549adf05dac628eecccfe52b4634 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Sat, 18 Oct 2025 10:20:07 -0700
Subject: [PATCH 2/3] Fix mode_t issues on MS-Windows

Problem reported by Manuela Friedrich in:
https://lists.iana.org/hyperkitty/list/[email protected]/thread/2ASUTQ6MXJJFXDYQPWHWA2SN2E2HOWZX/
* zic.c (mode_t, mkdir, umask) [HAVE_DIRECT_H]:
New macros, if not already macros.
(umask) [!HAVE_POSIX_DECLS]: Declare if not a macro, ignoring S_IWGRP.
---
 zic.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/zic.c b/zic.c
index bcaa27cb..2cde34c6 100644
--- a/zic.c
+++ b/zic.c
@@ -44,8 +44,15 @@ enum { FORMAT_LEN_GROWTH_BOUND = 5 };
 #ifdef HAVE_DIRECT_H
 # include <direct.h>
 # include <io.h>
-# undef mkdir
-# define mkdir(name, mode) _mkdir(name)
+# ifndef mode_t
+#  define mode_t int
+# endif
+# ifndef mkdir
+#  define mkdir(name, mode) _mkdir(name)
+# endif
+# ifndef umask
+#  define umask(mode) _umask(mode)
+# endif
 #endif
 
 #ifndef HAVE_GETRANDOM
@@ -151,7 +158,7 @@ extern int	link(const char * target, const char * linkname);
 # ifndef mkdir
 extern int	mkdir(char const *, mode_t);
 # endif
-# ifdef S_IWGRP
+# ifndef umask
 extern mode_t	umask(mode_t);
 # endif
 extern char *	optarg;
-- 
2.48.1

From f57caddafc719d89080804b8275a8449724647a1 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Sat, 18 Oct 2025 11:05:58 -0700
Subject: [PATCH 3/3] Always invoke umask at start

* zic.c (ALL_PERMS, TROUBLE_PERMS): New macros.
(MKDIR_PERMS): Define in terms of these macros.
(main): Always invoke umask at start, using TROUBLE_PERMS.
---
 zic.c | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/zic.c b/zic.c
index 2cde34c6..39e1e2bc 100644
--- a/zic.c
+++ b/zic.c
@@ -68,15 +68,29 @@ enum { FORMAT_LEN_GROWTH_BOUND = 5 };
 # include <sys/random.h>
 #endif
 
+
 #if HAVE_SYS_STAT_H
 # include <sys/stat.h>
 #endif
-#ifdef S_IRUSR
-# define MKDIR_PERMS (S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
+
+#ifdef S_IRWXU
+/* All file permission bits.  */
+# define ALL_PERMS (S_IRWXU | S_IRWXG | S_IRWXO)
+
+/* Troublesome file permission bits.  */
+# define TROUBLE_PERMS (S_IWGRP | S_IWOTH)
 #else
-# define MKDIR_PERMS 0755
+# define ALL_PERMS	0777
+# define TROUBLE_PERMS	0022
 #endif
 
+/* File permission bits for making directories.
+   The initial umask modifies these bits.
+   Although the "& ~TROUBLE_PERMS" is redundant because we remove
+   TROUBLE_PERMS from the umask early on, the redundancy does not hurt.  */
+#define MKDIR_PERMS (ALL_PERMS & ~TROUBLE_PERMS)
+
+
 /* The minimum alignment of a type, for pre-C23 platforms.
    The __SUNPRO_C test is because Oracle Developer Studio 12.6 lacks
    <stdalign.h> even though __STDC_VERSION__ == 201112.  */
@@ -993,9 +1007,10 @@ main(int argc, char **argv)
 	register ptrdiff_t i, j;
 	bool timerange_given = false;
 
-#ifdef S_IWGRP
-	umask(umask(S_IWGRP | S_IWOTH) | (S_IWGRP | S_IWOTH));
-#endif
+	/* Adjust umask so that created files lack troublesome permission bits.
+	   Needed because regular files are created via fopen not openat.  */
+	umask(umask(TROUBLE_PERMS) | TROUBLE_PERMS);
+
 #if HAVE_GETTEXT
 	setlocale(LC_ALL, "");
 # ifdef TZ_DOMAINDIR
-- 
2.48.1

Reply via email to