]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
cp,mv,install: fix chown on Linux CIFS
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 1 Sep 2023 22:05:21 +0000 (15:05 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 1 Sep 2023 22:10:45 +0000 (15:10 -0700)
* src/copy.c (chown_failure_ok): Also treat EACCES as OK.

NEWS
src/copy.c

diff --git a/NEWS b/NEWS
index c00ff0cf20444aa109df398cf5bb22b219d2fa94..6801832f776a16af337cb20d5f3d76ed9cc71c65 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,10 @@ GNU coreutils NEWS                                    -*- outline -*-
 
 ** Bug fixes
 
+  cp, mv, install no longer issue spurious "failed to preserve ownership"
+  diagnostics when copying to GNU/Linux CIFS filesystems.  They do
+  this by working around a Linux CIFS bug.
+
   numfmt options like --suffix no longer have an arbitrary 127-byte limit.
   [bug introduced with numfmt in coreutils-8.21]
 
index 48587952556558fd8c723cc1313ea6acfb2946d9..0b3de04f34570349279af78bd5ab37dd80f69ecc 100644 (file)
@@ -3449,9 +3449,16 @@ chown_failure_ok (struct cp_options const *x)
 {
   /* If non-root uses -p, it's ok if we can't preserve ownership.
      But root probably wants to know, e.g. if NFS disallows it,
-     or if the target system doesn't support file ownership.  */
+     or if the target system doesn't support file ownership.
 
-  return ((errno == EPERM || errno == EINVAL) && !x->chown_privileges);
+     Treat EACCES like EPERM and EINVAL to work around a bug in Linux
+     CIFS <https://bugs.gnu.org/65599>.  Although this means coreutils
+     will ignore EACCES errors that it should report, problems should
+     occur only when some other process is racing with coreutils and
+     coreutils is not immune to races anyway.  */
+
+  return ((errno == EPERM || errno == EINVAL || errno == EACCES)
+          && !x->chown_privileges);
 }
 
 /* Similarly, return true if it's OK for chmod and similar operations