From: Paul Eggert Date: Fri, 1 Sep 2023 22:05:21 +0000 (-0700) Subject: cp,mv,install: fix chown on Linux CIFS X-Git-Tag: v9.5~173 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f971361608749e1245c5eb12096de2acd32bf83;p=thirdparty%2Fcoreutils.git cp,mv,install: fix chown on Linux CIFS * src/copy.c (chown_failure_ok): Also treat EACCES as OK. --- diff --git a/NEWS b/NEWS index c00ff0cf20..6801832f77 100644 --- 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] diff --git a/src/copy.c b/src/copy.c index 4858795255..0b3de04f34 100644 --- a/src/copy.c +++ b/src/copy.c @@ -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 . 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