[Toybox] rm -rf doesn't chmod high enough
Isaac Dunham
ibid.ag at gmail.com
Tue Sep 23 08:17:35 PDT 2014
On Mon, Sep 22, 2014 at 08:19:21AM -0500, Rob Landley wrote:
> 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?)
Both "rm -r" tests fail on Alpine Linux (musl) for me.
rm -rf passes.
And the mount test hangs in an infinite loop for me.
Per strace, it's not doing any syscalls.
Workaround-hit it with a hammer:
while killall mount; do sleep 1; done
(I'll be poking at that, if I get the time...)
Thanks,
Isaac Dunham
1411485455.0
More information about the Toybox
mailing list