coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: rm should exit immediately if the user cannot write to the parent di


From: Jim Meyering
Subject: Re: rm should exit immediately if the user cannot write to the parent directory
Date: Thu, 3 Sep 2015 10:55:02 -0700

On Thu, Sep 3, 2015 at 7:56 AM, Alex Henrie <address@hidden> wrote:
> Hi,
>
> I have run into an annoying problem with GNU rm. When I try to remove
> a file to which I do not have write permission from a directory to
> which I do not have write permission, rm warns me about the file being
> read-only before telling me that I do not actually have permission to
> delete it:
>
> $ sudo mkdir foo
> $ sudo touch foo/bar
> $ rm foo/bar
> rm: remove write-protected regular empty file 'foo/bar'? yes
> rm: cannot remove 'foo/bar': Permission denied
>
> It looks like rm could use dirname and faccessat to check for write
> permission on the parent directory before showing a prompt. Would you
> be willing to add a preliminary check like this to rm to avoid useless
> prompts?

Those have bothered me, too, but...
I'm pretty sure the only alternative would involve adding nontrivial
cost to the default code path for nearly every use of rm, and that
feels like it would be disproportionately high, for very small gain.

If you can find a way to avoid the spurious prompt without
the cost of an additional stat-style FS access, or a way to
ensure that the cost is incurred only when we're going to
present an interactive prompt (in which case it's negligible),
then maybe.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]