bug#79072: install -d onto readonly fs prints the wrong error

Pádraig Brady <[email protected]>
Newsgroups gmane.comp.gnu.core-utils.bugs
Message-ID <[email protected]>
On 22/07/2025 20:17, Paul Eggert wrote:
> Thanks for reporting that inaccurate diagnostic. Sorry about the tricky
> code; it's a tricky situation. Looks like Collin's patch is not quite right.
> 
> I installed the attached patches into Gnulib. The first one fixes the
> two cases you mentioned, the second an unlikely bug I discovered in the
> neighborhood. Please give the patches a try. As they fix the bugs for me
> I am boldly closing the Coreutils bug report; we can reopen it if I'm wrong.

Seems to work with the attached coreutils patch
to add NEWS and a test.

thanks!
Padraig
install-d-diag.patch (text/x-patch, 2 KB)
From 5a106af2d69af9477e614d50cf5c22315ef402ea Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?= <[email protected]>
Date: Tue, 22 Jul 2025 20:34:50 +0100
Subject: [PATCH] install: with -d, use more accurate diagnostics

* gnulib: Update to latest to get the fix to
propagate the appropriate error message.
* tests/install/basic-1.sh: Add a test case.
* NEWS: Mention the bug fix.
Addresses https://bugs.gnu.org/79072
---
 NEWS                     | 5 +++++
 gnulib                   | 2 +-
 tests/install/basic-1.sh | 7 +++++++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index f4a4739a8..17a43b064 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,11 @@ GNU coreutils NEWS                                    -*- outline -*-
   copying to non-NFS files from NFSv4 files with trivial ACLs.
   [bug introduced in coreutils-9.6]
 
+  install -d now produces the correct diagnostic upon failure
+  to create a directory.  Previously it would have produced
+  a confusing error about changing permissions.
+  [This bug was present in "the beginning".]
+
   od --strings with -N now works correctly.  Previously od might
   write a NUL byte after a heap buffer, or output invalid addresses.
   [These bugs were present in "the beginning".]
diff --git a/gnulib b/gnulib
index 91aacb553..84ddfc7bd 160000
--- a/gnulib
+++ b/gnulib
@@ -1 +1 @@
-Subproject commit 91aacb5536d4e768064c4f4d8d28bef6aa37e534
+Subproject commit 84ddfc7bd29853ed91cdd65c7ce818072959f974
diff --git a/tests/install/basic-1.sh b/tests/install/basic-1.sh
index e311dbb9e..fd13eb68b 100755
--- a/tests/install/basic-1.sh
+++ b/tests/install/basic-1.sh
@@ -148,4 +148,11 @@ returns_ 1 ginstall . . 2>err || fail=1
 printf '%s\n' "ginstall: omitting directory '.'" >exp || framework_failure_
 compare exp err || fail=1
 
+# Ensure correct diagnostic for failing to create dir
+mkdir -m 111 sub-ro || framework_failure_
+if ! mkdir sub-ro/d; then
+  returns_ 1 ginstall -d sub-ro/d 2>err || fail=1
+  grep 'cannot create directory' err || { cat err; fail=1; }
+fi
+
 Exit $fail
-- 
2.50.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.