summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-06-26 23:36:03 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:18:57 -0500
commita24c4049670e6837705ac7013c7d2da596a95f6a (patch)
tree5f23b51c9eb11c39e777458996b4df7efc0b1a59
parent6612988d09d78fc98b964456a10c4de9a4dfdb31 (diff)
downloadsamba-a24c4049670e6837705ac7013c7d2da596a95f6a.tar.gz
samba-a24c4049670e6837705ac7013c7d2da596a95f6a.tar.bz2
samba-a24c4049670e6837705ac7013c7d2da596a95f6a.zip
r16537: Fix for bug #3858, all files in a directory not
being deleted when hide unreadable set to true. Here's the scoop. This one is really interesting. The pattern of deleting a directory is to do a findfirst to get the first part of the list, then for each name returned it does a open/set delete on close/close -> thus deleting the file. Then it does a findnext with the last file name THAT IT JUST DELETED ! Now we can handle this in the findnext in the case where hide unreadable is set to false as we look back in our cache of names and just seek to the right point. The bug is actually fixed in the first hunk of this patch - the one that removes the is_visible_file() check after SearchDir returns false. We don't actually need it and in this case it's causing the delete to be aborted because it can't find the name (doh ! it was just deleted). We don't need it as SearchDir is only ever called from findnext, and findnext should only ever be returning names we gave it. The rest of the patch are the debugs I used to find the problem but they're generically useful. Phew - that one took a while to track down..... Jerry, please merge for 3.0.23 final. Jeremy. (This used to be commit cd048cb775f0a8525fc19aa463db07c477521f5b)
-rw-r--r--source3/smbd/dir.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index 27a4182c22..5ba9e1ed57 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -636,12 +636,7 @@ BOOL dptr_SearchDir(struct dptr_struct *dptr, const char *name, long *poffset, S
return False;
}
- if (SearchDir(dptr->dir_hnd, name, poffset)) {
- if (is_visible_file(dptr->conn, dptr->path, name, pst, True)) {
- return True;
- }
- }
- return False;
+ return SearchDir(dptr->dir_hnd, name, poffset);
}
/****************************************************************************
@@ -854,6 +849,8 @@ static BOOL user_can_read_file(connection_struct *conn, char *name, SMB_STRUCT_S
/* If we can't stat it does not show it */
if (!VALID_STAT(*pst) && (SMB_VFS_STAT(conn, name, pst) != 0)) {
+ DEBUG(10,("user_can_read_file: SMB_VFS_STAT failed for file %s with error %s\n",
+ name, strerror(errno) ));
return False;
}
@@ -992,6 +989,7 @@ BOOL is_visible_file(connection_struct *conn, const char *dir_path, const char *
/* If it's a vetoed file, pretend it doesn't even exist */
if (use_veto && IS_VETO_PATH(conn, name)) {
+ DEBUG(10,("is_visible_file: file %s is vetoed.\n", name ));
return False;
}
@@ -1003,16 +1001,19 @@ BOOL is_visible_file(connection_struct *conn, const char *dir_path, const char *
}
/* Honour _hide unreadable_ option */
if (hide_unreadable && !user_can_read_file(conn, entry, pst)) {
+ DEBUG(10,("is_visible_file: file %s is unreadable.\n", entry ));
SAFE_FREE(entry);
return False;
}
/* Honour _hide unwriteable_ option */
if (hide_unwriteable && !user_can_write_file(conn, entry, pst)) {
+ DEBUG(10,("is_visible_file: file %s is unwritable.\n", entry ));
SAFE_FREE(entry);
return False;
}
/* Honour _hide_special_ option */
if (hide_special && file_is_special(conn, entry, pst)) {
+ DEBUG(10,("is_visible_file: file %s is special.\n", entry ));
SAFE_FREE(entry);
return False;
}