bug-texinfo
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] install-info: Fix dir file mode being restricted


From: Arsen Arsenović
Subject: [PATCH] install-info: Fix dir file mode being restricted
Date: Fri, 24 Feb 2023 17:16:47 +0100

The recent switch to mkstemp and atomic updating of the directory
file unintentionally lead to overly restrictive permissions being
set on directory file.  This error was originally introduced in
93162b78d84f731710025b300bc0cd7ca8b14347 (2022-12-03 Gavin Smith
<gavinsmith0123@gmail.com>).
* install-info/install-info.c (output_dirfile): Change mode of
installed dir file back to its usual value, rather than the
mkstemp default of 0600.
---
Hi,

After updating my system to the latest Texinfo development version, I
noticed that my dir node became unreadable for regular users.  After a
bit of digging around portage sources, I noticed that this mode was set
by install-info.  This reminded me of the recent change to install-info,
with making it use mkstemp.  mkstemp creates files with a highly
restricted mode, rather than respecting umask.  This patch reverts that
unintentional effect.

OK for master?  Tested on x86_64-pc-linux-gnu.

 ChangeLog                   | 13 +++++++++++++
 install-info/install-info.c | 10 ++++++++++
 2 files changed, 23 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 4ae80e4dc7..de0d88666a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2023-02-24  Arsen Arsenović  <arsen@aarsen.me>
+
+       install-info: Fix dir file mode being restricted
+
+       The recent switch to mkstemp and atomic updating of the directory
+       file unintentionally lead to overly restrictive permissions being
+       set on directory file.  This error was originally introduced in
+       93162b78d84f731710025b300bc0cd7ca8b14347 (2022-12-03 Gavin Smith
+       <gavinsmith0123@gmail.com>).
+       * install-info/install-info.c (output_dirfile): Change mode of
+       installed dir file back to its usual value, rather than the
+       mkstemp default of 0600.
+
 2023-02-23  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/parsetexi/end_line.c
diff --git a/install-info/install-info.c b/install-info/install-info.c
index dcc36def2e..9d8201c977 100644
--- a/install-info/install-info.c
+++ b/install-info/install-info.c
@@ -1053,6 +1053,16 @@ output_dirfile (char *dirfile, int dir_nlines, struct 
line_data *dir_lines,
   else
     fclose (output);
 
+  /* Reset the mode that the file is set to.  */
+  mode_t um = umask (0022);
+  umask (um);
+  if (fchmod (tempfile, 0666 & um) < 0)
+    {
+      perror ("chmod");
+      remove (tempname);
+      exit (EXIT_FAILURE);
+    }
+
   /* Update dir file atomically.  This stops the dir file being corrupted
      if install-info is interrupted. */
   if (rename (tempname, dirfile) == -1)
-- 
2.39.2

<#secure method=pgpmime mode=sign>

-- 
Arsen Arsenović



reply via email to

[Prev in Thread] Current Thread [Next in Thread]