[Toybox] rm -rf doesn't chmod high enough

Rob Landley rob at landley.net
Mon Sep 22 06:19:21 PDT 2014


On 09/20/14 08:22, Felix Janda wrote:
> Isaac Dunham wrote:
> [..]
>> A trickier bug is that rm -r dir will skip dir, saying 
>> "rm: dir: is a directory"
>> I guess the fix involves rm -r calling rmdir instead of unlink.
> 
> unlinkat() also removes directories when given AT_REMOVEDIR.
> The following patch makes rm pass the tests and it still asks
> me when I try to remove a readonly dir.
> 
> -Felix
> 
> diff -r 434c4ae19f05 toys/posix/rm.c
> --- a/toys/posix/rm.c	Thu Sep 18 18:07:58 2014 -0500
> +++ b/toys/posix/rm.c	Sat Sep 20 15:19:09 2014 +0200
> @@ -50,7 +50,6 @@
>      // Handle chmod 000 directories when -f
>      if (faccessat(fd, try->name, R_OK, AT_SYMLINK_NOFOLLOW)) {
>        if (toys.optflags & FLAG_f) wfchmodat(fd, try->name, 0700);
> -      else goto skip;
>      }
>      if (!try->again) return DIRTREE_COMEAGAIN;
>      using = AT_REMOVEDIR;

I'm confused: rm is currently passing for me? "scripts/test.sh rm"
passes, and "mkdir blah; rm -r blah" also works for me...

How do I reproduce the failure? (Try on fedora maybe?)

Rob

 1411391961.0


More information about the Toybox mailing list