tag 704082 + confirmed upstream
thanks

Alexander V. Kudrevatykh wrote:
> When trying to delete not-empty directory that cannot be deleted by rights on
> parent dir with option --ignore-fail-on-non-empty user got simply 'failed to
> remove' message, without exact reason. When trying to delete empty directory
> that cannot be deleted by rights - it says nothing and exit status is zero.

Thank you for your clear and detailed bug report.

> Example:
> $ mkdir d1
> $ mkdir d1/d2
> $ chmod a-w d1
> $ rmdir d1/d2/
> rmdir: failed to remove 'd1/d2/': Permission denied

  $ strace -v -e trace=rmdir rmdir d1/d2
  rmdir("d1/d2")                          = -1 EACCES (Permission denied)
  rmdir: failed to remove ‘d1/d2’: Permission denied
  $ echo $?
  1

Correct.

> $ rmdir --ignore-fail-on-non-empty d1/d2/
> $ echo $?
> 0

This is the interesting case.

  $ rmdir --ignore-fail-on-non-empty d1/d2
  $ strace -v -e trace=rmdir rmdir --ignore-fail-on-non-empty d1/d2
  rmdir("d1/d2")                          = -1 EACCES (Permission denied)
  $ echo $?
  0

The error does seem to be incorrectly suppressed by the
--ignore-fail-on-non-empty option.

> $ touch d1/d2/f1
> $ rmdir --ignore-fail-on-non-empty d1/d2/
> rmdir: failed to remove 'd1/d2/'
> $ rmdir d1/d2/
> rmdir: failed to remove 'd1/d2/': Permission denied

  $ touch d1/d2/f1
  $ strace -v -e trace=rmdir rmdir --ignore-fail-on-non-empty d1/d2
  rmdir("d1/d2")                          = -1 EACCES (Permission denied)
  rmdir: failed to remove ‘d1/d2’
  $ echo $?
  1

This above is also interesting because no reason for the failure is
printed.  It isn't wrong but it is failing to print all of the
available information.

  $ chmod u+w d1
  $ touch d1/d2/f1
  $ strace -v -e trace=rmdir rmdir --ignore-fail-on-non-empty d1/d2
  rmdir("d1/d2")                          = -1 ENOTEMPTY (Directory not empty)
  $ echo $?
  0

Correct.

> I think rmdir should say 'Permission denied' with exit status 1 in first case
> and say 'Permission denied' or do not report error in second case

Unfortunately the cases were not numbered but I think there are two
very closely related problems.  One is incorrect and one is minor.

Bob

Attachment: signature.asc
Description: Digital signature

Reply via email to