Subject: Re: bug#34700: rm refuses to remove files owned by the user, even in force mode

From: Erik Auerswald <[email-masked]>
Date: Sat, 2 Mar 2019 18:53:20 +0100

Hi,

On 3/2/19 07:18, Bob Proulx wrote:
> Nicolas Mailhot wrote:
>> For their own reasons, the Go maintainers have decided the user Go cache
>> will now be read-only.
>> https://github.com/golang/go/issues/27161#issuecomment-433098406
>> That means cleaning up cache artefacts with rm does not work anymore
>> https://github.com/golang/go/issues/30502
> [...]
> However regardless of intentions and design if one really wants to
> smash it then this is easily scripted.  No code modifications are
> needed.
> 
>    #!/bin/sh
>    chmod -R u+w $1
>    rm -rf $1

To everyone considering the above "script": do not use it! It does not 
even guard against spaces in file names. Besides being dangerously 
buggy, it does not even solve the problem of deleting a file inside a 
read-only directory.

I would suggest people with specific directories that inhibit deletion 
of files inside although they should not (e.g. a "cache") to deliberatly 
change the permissions of said directories prior to deleting files 
inside. Using a script like the above, even without the basic mistakes 
in the script, is quite dangerous.

Thanks,
Erik