After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 322841 - incorrect permissions required to delete directory
incorrect permissions required to delete directory
Status: RESOLVED OBSOLETE
Product: nautilus
Classification: Core
Component: File and Folder Operations
3.22.x
Other Linux
: Normal normal
: ---
Assigned To: Nautilus Maintainers
Nautilus Maintainers
Depends on:
Blocks:
 
 
Reported: 2005-11-30 14:25 UTC by Sebastien Bacher
Modified: 2021-06-18 15:50 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Try to remove directories even if we can't read the contents (8.63 KB, patch)
2012-08-30 19:26 UTC, William Jon McCann
needs-work Details | Review
Fix deleting writable but not readable directory (6.64 KB, patch)
2016-03-03 08:06 UTC, Daniel Beal
needs-work Details | Review
Fix not being able to delete writable directory that is not readable (5.60 KB, patch)
2016-03-03 17:39 UTC, Daniel Beal
needs-work Details | Review
Delete an empty folder with -wx- permissions. (1.86 KB, patch)
2017-01-20 19:32 UTC, Atul Anand
needs-work Details | Review

Description Sebastien Bacher 2005-11-30 14:25:18 UTC
This bug has been opened here: http://bugzilla.ubuntu.com/show_bug.cgi?id=18670

"Description:
Nautilus requires directory foo to have read and write permissions to permit
deletion.

Expected Results:
User only requires write and execute permission (with sticky bit off) on foo's
parent directory in order to delete foo (or any other file in foo's parent).

Steps to reproduce:
jconte@kunto:~/Desktop $ mkdir foo
jconte@kunto:~/Desktop $ chmod 600 foo
jconte@kunto:~/Desktop $ sudo chown root.root foo
Password:
jconte@kunto:~/Desktop $ ls -ld . foo
drwxr-xr-x  4 jconte jconte 496 2005-10-30 10:55 .
drw-------  2 root   root    48 2005-10-30 10:55 foo

Foo cannot be deleted from Nautilus at this point.

jconte@kunto:~/Desktop $ sudo chmod 606 foo
jconte@kunto:~/Desktop $ ls -ld . foo
drwxr-xr-x  4 jconte jconte 496 2005-10-30 11:19 .
drw----rw-  2 root   root    48 2005-10-30 11:19 foo

Nautilus will now enable the user to delete foo.

Build and Version:
Ubuntu 5.10 Breezy Badger
Nautilus 2.12.1"
Comment 1 Christian Kellner 2005-12-01 09:05:50 UTC
GnomeVFS Only exports the permsissions (and the effective access rights ala
GNOME_VFS_PERM_ACCESS_*). To do The Right Thing[tm] with those information is up
to the specific application. I am reassigning that to nautilus therefore.
Comment 2 Christian Kellner 2005-12-01 09:07:01 UTC
Maybe I could suck less.
Comment 3 Chris Ball 2006-03-23 21:25:14 UTC
Confirmed as described on 2.14.0, but I'm not sure this is a bug.  I can `rmdir foo` at a shell but not delete foo in Nautilus -- but the delete action in Nautilus is really `mv foo .Trash`, which wouldn't work in a shell.

So, since we don't provide an `rmdir` in Nautilus, I think this is NOTABUG.  Does that make sense?
Comment 4 Jonathon Conte 2006-04-07 23:40:11 UTC
Perhaps the user could get a dialog asking "This item cannot be moved to the trash. Would you like to delete it immediately?". I'm not sure if that is optimal but it seems better than displaying an error message and requiring the user to drop to a shell.
Comment 5 Sebastien Bacher 2006-08-14 10:17:29 UTC
reopening, as suggested by the previous comment it should open a dialog asking if the user want to delete them directly
Comment 6 Cosimo Cecchi 2008-01-29 01:22:28 UTC
Still valid.
In 2.21.6 we got the dialog asking to delete it directly, but does not work (it gives a message saying it requires read permissions to the directory to delete it).
Comment 7 Marcus Carlson 2010-07-04 21:09:47 UTC
Still valid, seems

	enumerator = g_file_enumerate_children (dir,
						G_FILE_ATTRIBUTE_STANDARD_NAME,
						G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS,
						job->cancellable,
						&error);

in nautilus-file-operations.c ~1479 is the root of the problem.

But maybe should_skip_readdir_error() could help somehow...
Comment 8 Marcin Szewczyk 2011-09-15 09:45:17 UTC
Still here.

Test case:
drwxr-xr-x 3 wodny wodny 4096 Sep  1 12:39 .
drwxr-xr-x 5 wodny wodny 4096 Sep  1 12:39 ..
drwx------ 2 root  root  4096 Sep  1 12:39 testdir

Testdir is empty.

Rmdir testdir will succeed.
Gvfs-rm will succeed.
Removing testdir through nautilus will fail.

Tested with nautilus 2.30.1-0ubuntu1.2 which is old but git blame 
suggests not much happened with the code in 
libnautilus-private/nautilus-file-operations.c.

I've reported a similar bug for libfm0:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=639982

The problem is somewhere here I suppose:
  • #0 g_file_enumerate_children
    from /usr/lib/libgio-2.0.so.0
  • #1 scan_dir
    at nautilus-file-operations.c line 2460
  • #2 scan_file
    at nautilus-file-operations.c line 2643
  • #3 scan_sources
    at nautilus-file-operations.c line 2669
  • #4 delete_files
    at nautilus-file-operations.c line 1691
  • #5 trash_files
    at nautilus-file-operations.c line 1826
  • #6 delete_job
    at nautilus-file-operations.c line 1919

Comment 9 William Jon McCann 2012-08-30 19:26:37 UTC
Created attachment 222979 [details] [review]
Try to remove directories even if we can't read the contents
Comment 10 Carlos Soriano 2016-02-29 16:12:22 UTC
Review of attachment 222979 [details] [review]:

sorry it took so long to review.
This patch doesn't work as expected since even if we try to delete it it doesn't delete it and doesn't provide any feedback. I guess we need another check somewhere.

So I'm marking as needs-work
Comment 11 Carlos Soriano 2016-02-29 16:13:27 UTC
Also I expect this to be not so difficult and we have a patch from Jon, so marking as newcomer (or Jon in case you want to update it feel free!)
Comment 12 Daniel Beal 2016-03-03 08:06:23 UTC
Created attachment 322950 [details] [review]
Fix deleting writable but not readable directory

I'm new. I am open to any feedback on this patch, though.
Comment 13 Carlos Soriano 2016-03-03 16:01:56 UTC
Review of attachment 322950 [details] [review]:

Thanks for the patch!

For now I will point some minor issues, and later I will review the code itself.

The commit message is not wrapped and doesn't follow the guidelines[0], although it's well explained, so congrats for that.

Also you do some unrelated changes. Do not do any style change or so, just code that changes behavior.

Also seems some indentation is wrong, try to make it aligned like other parts of the code.

[0]https://wiki.gnome.org/Newcomers/CodeContributionWorkflow#Commit_guidelines

Also some comments inline (you can check the whole code clicking "review").

::: libnautilus-private/nautilus-file-operations.c
@@ +1658,3 @@
 			if (IS_IO_ERROR (error, PERMISSION_DENIED)) {
+				secondary = f (_("The folder “%B” cannot be deleted because you do not have "
+					 "permissions to read it."), dir);

why this change?
Comment 14 Daniel Beal 2016-03-03 16:43:20 UTC
FYI, I was reading the commit guidelines located on the Submitting Patches page[0]. Those guidelines seem to be different from the ones you sent me. I will certainly fix the message, though.

Looks like I am using tabs instead of spaces. That would explain the bad indentation. I will go ahead and fix that. Sorry.

Did not mean to make style changes. I was debugging some other code and I might have left a newline or something like that. I will fix that also.

Thanks for the feedback!
Comment 15 Carlos Soriano 2016-03-03 16:56:36 UTC
(In reply to Daniel Beal from comment #14)
> FYI, I was reading the commit guidelines located on the Submitting Patches
> page[0]. Those guidelines seem to be different from the ones you sent me. I
> will certainly fix the message, though.

I'm not aware on any other commit guideline page, so not sure what page I sent to you. This one linked here is the one to follow.

It's good to check the patch before attaching, you can do it in for example gitg, I normally use it for this purpose and it's the one GNOME provides.

About the tabs & spaces.. actually nautilus it's in a weird state, so no worries, try to follow the code around it and we can discuss it further on IRC.

yw about the feedback!
Comment 16 Daniel Beal 2016-03-03 17:39:45 UTC
Created attachment 323013 [details] [review]
Fix not being able to delete writable directory that is not readable

This is a bug which prevents the user from
being able to delete a directory which
they can write to, but not read the contents
of. If the directory is empty, the folder
can still be deleted even if the user
cannot read it.

This fix works by first having nautilus
try to delete the folder even if it cannot
recursively delete sub files or folders.
Also, if the user attempts to move the file
to trash, nautilus will inform the user that
this cannot be done and offer to permanently
delete the file instead. In order for this fix
to be made, the trash_file function had to be
modified to return the value of the to_delete
GList pointer so that calling functions
could keep track of the delete file list response.
Comment 17 Carlos Soriano 2016-10-04 15:09:40 UTC
Review of attachment 323013 [details] [review]:

Hey, this patch slipped my emails, sorry about that. If that happens again, feel free to ping me on here. The code changed slightly, do you want to update the patch accordingly? I believe the code is going to be simpler now.
I think the idea it's mostly fine, but worth double check when it's updated.

::: libnautilus-private/nautilus-file-operations.c
@@ +2001,3 @@
 }
 
+static GList*

We are trashing just one file. I believe with the to_delete handling we have now ins mater you will be fine.
Comment 18 Daniel Beal 2016-10-04 16:49:31 UTC
Hi Carlos,

Unfortunately it has been too long. Months ago I was considering this project as a new venture, but I then decided I would prefer elsewhere. If I were to update this patch now, I would have to reinstall and setup the environment again, and I would rather not do that.

Thank you for the feedback, though. Sorry.
Comment 19 Carlos Soriano 2016-10-05 07:57:45 UTC
(In reply to Daniel Beal from comment #18)
> Hi Carlos,
> 
> Unfortunately it has been too long. Months ago I was considering this
> project as a new venture, but I then decided I would prefer elsewhere. If I
> were to update this patch now, I would have to reinstall and setup the
> environment again, and I would rather not do that.
> 
> Thank you for the feedback, though. Sorry.

No problem, thanks for your work!
Comment 20 Atul Anand 2017-01-20 19:32:48 UTC
Created attachment 343917 [details] [review]
Delete an empty folder with -wx- permissions.

Kindly review, thanks.
Atul Anand.
Comment 21 Carlos Soriano 2017-02-28 13:11:13 UTC
Review of attachment 343917 [details] [review]:

Heya, I'm looking at the code and the issue is that you are not using the to_delete list, so it doesn't report the progress of deleting files and also is not reporting of any error trashing the file happens.
So I think what we need is to make to_delete work in this case.
Comment 22 André Klapper 2021-06-18 15:50:39 UTC
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org.
As part of that, we are mass-closing older open tickets in bugzilla.gnome.org
which have not seen updates for a longer time (resources are unfortunately
quite limited so not every ticket can get handled).

If you can still reproduce the situation described in this ticket in a recent
and supported software version of Files (nautilus), then please follow
  https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines
and create a new ticket at
  https://gitlab.gnome.org/GNOME/nautilus/-/issues/

Thank you for your understanding and your help.