cp -R gives incorrect error message for "insufficient permissions" situation

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

cp -R gives incorrect error message for "insufficient permissions" situation

chefren
 >Submitter-Id:
 >Originator:    [hidden email]
 >Organization:
 >Synopsis:      cp -R gives incorrect error message for "insufficient
permissions" situation
 >Severity:      non-critical
 >Priority:      low
 >Category:      user
 >Class:         sw-bug
 >Release:       OpenBSD 3.8 Release
 >Environment:
         System      : OpenBSD 3.8
         Architecture: OpenBSD.i386
         Machine     : i386
 >Description:
         Doing a 'cp -R' as a user with insufficient permission for
the source directory causes an incorrect and misleading error message.

         The error message wrongfully indicates that the problem lies
at the destination instead of at the source directory.

         The error message indicates a nonsensical error type.

         This incorrect error message is highly disorientating for the
user.

 >How-To-Repeat:
As user 1:
mkdir /tmp/src
mkdir /tmp/src/bar
chmod 700 /tmp/src/bar

As user 2:
cp -R /tmp/src dst

Expected result:
cp: /tmp/src/bar: Permission denied

Actual result:
cp: dst/bar: File exists

 >Fix:
         unknown.

Reply | Threaded
Open this post in threaded view
|

Re: cp -R gives incorrect error message for "insufficient permissions" situation

Otto Moerbeek
On Mon, 7 Nov 2005, chefren wrote:

> >Submitter-Id:
> >Originator:    [hidden email]
> >Organization:
> >Synopsis:      cp -R gives incorrect error message for "insufficient
> permissions" situation
> >Severity:      non-critical
> >Priority:      low
> >Category:      user
> >Class:         sw-bug
> >Release:       OpenBSD 3.8 Release
> >Environment:
>         System      : OpenBSD 3.8
>         Architecture: OpenBSD.i386
>         Machine     : i386
> >Description:
>         Doing a 'cp -R' as a user with insufficient permission for the source
> directory causes an incorrect and misleading error message.
>
>         The error message wrongfully indicates that the problem lies at the
> destination instead of at the source directory.
>
>         The error message indicates a nonsensical error type.
>
>         This incorrect error message is highly disorientating for the user.
>
> >How-To-Repeat:
> As user 1:
> mkdir /tmp/src
> mkdir /tmp/src/bar
> chmod 700 /tmp/src/bar
>
> As user 2:
> cp -R /tmp/src dst
>
> Expected result:
> cp: /tmp/src/bar: Permission denied
>
> Actual result:
> cp: dst/bar: File exists
>
> >Fix:
>         unknown.
>
>

Try this.

Index: cp.c
===================================================================
RCS file: /cvs/src/bin/cp/cp.c,v
retrieving revision 1.29
diff -u -p -r1.29 cp.c
--- cp.c 13 Dec 2004 20:25:34 -0000 1.29
+++ cp.c 7 Nov 2005 19:36:31 -0000
@@ -279,6 +279,7 @@ copy(char *argv[], enum op type, int fts
  for (rval = 0; (curr = fts_read(ftsp)) != NULL;) {
  switch (curr->fts_info) {
  case FTS_NS:
+ case FTS_DNR:
  case FTS_ERR:
  warnx("%s: %s",
     curr->fts_path, strerror(curr->fts_errno));

Reply | Threaded
Open this post in threaded view
|

Re: cp -R gives incorrect error message for "insufficient permissions" situation

chefren
On 11/07/05 20:37, Otto Moerbeek wrote:

> Try this.
>
> Index: cp.c
> ===================================================================
> RCS file: /cvs/src/bin/cp/cp.c,v
> retrieving revision 1.29
> diff -u -p -r1.29 cp.c
> --- cp.c 13 Dec 2004 20:25:34 -0000 1.29
> +++ cp.c 7 Nov 2005 19:36:31 -0000
> @@ -279,6 +279,7 @@ copy(char *argv[], enum op type, int fts
>   for (rval = 0; (curr = fts_read(ftsp)) != NULL;) {
>   switch (curr->fts_info) {
>   case FTS_NS:
> + case FTS_DNR:
>   case FTS_ERR:
>   warnx("%s: %s",
>      curr->fts_path, strerror(curr->fts_errno));

Looks OK, tried and it works!

Great!

Fix within 2.5 hours...

Thank you!

+++chefren