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

From: Erik Auerswald <[email-masked]>
Date: Sun, 3 Mar 2019 13:43:49 +0100

Hi,

On 3/3/19 09:40, L A Walsh wrote:
> On 3/2/2019 11:31 AM, Bob Proulx wrote:
>> But regardless of that it does not change the fact that the entire
>> purpose of read-only directories is to prevent removing and renaming
>> of files within them.
>>    
> ----
>      But not by the user owning them.

The rationale given by the Go developers is to prevent downloaded test
code to remove or alter files in the modules directory, not to prevent
the user from doing that.

> [...]
>>> 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.
>>>      
> Yeah...I wouldn't do it, I'd write a script that invokes the app and
> clears out the cache dir when the app exits if it bothered me enough.

The Go developers implemented "go clean -modcache" for that purpose.
https://github.com/golang/go/issues/27161#issuecomment-415213240
https://tip.golang.org/cmd/go/#hdr-Remove_object_files_and_cached_files

> Much better to let the computer do the repetitive deletions.  If I do it
> manually, it increases the chances of me creating a problem the more often
> I do it.
> 
> Really -- scripts are much better at handling redundant/routine matters that
> turn parts of my brain off.  OTOH, some people are better at redundant
> detail
> and don't suffer the same problems I would.  People are different.

I concur to let software handle repetitive tasks.

If cleaning the cache occurs seldom, manually performing the changes, or
better invoking an existing specialized program (or script) for this
specific cache seems to be better than circumventing the safety net in a
general purpose utility. Especially if this circumvention means
transparently changing access rights on a directory that is not
mentioned in the utility invocation.

If cleaning the cache occurs all the time, using "go cache -modcache"
(or whatever program is appropriate for the specific cache) should be
the routine used. If there is no specialized program provided yet, a
script could be developed for that purpose.

Thanks,
Erik