summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-02-09 02:03:39 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:17:51 -0500
commit86e5659abac9938e7ac0cea989ca33e807b3e181 (patch)
tree0f40cf6be9480356660189e83ad6009579178d8c /source3/smbd
parent5920d870cfc6be3c5bbc65ab63a6e63d1d7286f4 (diff)
downloadsamba-86e5659abac9938e7ac0cea989ca33e807b3e181.tar.gz
samba-86e5659abac9938e7ac0cea989ca33e807b3e181.tar.bz2
samba-86e5659abac9938e7ac0cea989ca33e807b3e181.zip
r21257: Better fix for bug #4188 :
Windows Vista RC1 and RC2 can't delete directory on Samba share based on work by Joe Meadows <jmeadows@webopolis.com>. Jeremy. (This used to be commit 2dab8928769938ab79da7b7ce2d165fc388f9b00)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/dir.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index 9f0350fe6d..2795b2a24b 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -1279,3 +1279,42 @@ BOOL SearchDir(struct smb_Dir *dirp, const char *name, long *poffset)
}
return False;
}
+
+/*****************************************************************
+ Is this directory empty ?
+*****************************************************************/
+
+NTSTATUS can_delete_directory(struct connection_struct *conn,
+ const char *dirname)
+{
+ NTSTATUS status = NT_STATUS_OK;
+ long dirpos = 0;
+ const char *dname;
+ struct smb_Dir *dir_hnd = OpenDir(conn, dirname, NULL, 0);
+
+ if (!dir_hnd) {
+ return map_nt_error_from_unix(errno);
+ }
+
+ while ((dname = ReadDirName(dir_hnd,&dirpos))) {
+ SMB_STRUCT_STAT st;
+
+ /* Quick check for "." and ".." */
+ if (dname[0] == '.') {
+ if (!dname[1] || (dname[1] == '.' && !dname[2])) {
+ continue;
+ }
+ }
+
+ if (!is_visible_file(conn, dirname, dname, &st, True)) {
+ continue;
+ }
+
+ DEBUG(10,("can_delete_directory: got name %s - can't delete\n", dname ));
+ status = NT_STATUS_DIRECTORY_NOT_EMPTY;
+ break;
+ }
+ CloseDir(dir_hnd);
+
+ return status;
+}