summaryrefslogtreecommitdiff
path: root/source3/smbd/reply.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2005-02-01 18:33:50 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:55:30 -0500
commit021011f90030f6f4c39c9ef27db17eec5d4536ad (patch)
tree98292958a3a2ce9f10c3afcfd622a73b2ccf0bc2 /source3/smbd/reply.c
parentb75ebde786540d24de7a911ae3e55a6d796b19aa (diff)
downloadsamba-021011f90030f6f4c39c9ef27db17eec5d4536ad.tar.gz
samba-021011f90030f6f4c39c9ef27db17eec5d4536ad.tar.bz2
samba-021011f90030f6f4c39c9ef27db17eec5d4536ad.zip
r5160: First cut at refactoring of directory code to handle non-wildcard
directory match more efficiently. Passes RAW-SEARCH under valgrind but needs more testing (which I'll do later today :-). Jeremy. (This used to be commit 0b04dd9d0c6d1fe02d1b5e43f203577bf5466f33)
Diffstat (limited to 'source3/smbd/reply.c')
-rw-r--r--source3/smbd/reply.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 899dba56d8..748d9958bc 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -1610,7 +1610,7 @@ NTSTATUS unlink_internals(connection_struct *conn, int dirtype, char *name)
const char *dname;
if (check_name(directory,conn))
- dir_hnd = OpenDir(conn, directory, True);
+ dir_hnd = OpenDir(conn, directory);
/* XXXX the CIFS spec says that if bit0 of the flags2 field is set then
the pattern matches against the long name, otherwise the short name
@@ -1625,10 +1625,15 @@ NTSTATUS unlink_internals(connection_struct *conn, int dirtype, char *name)
pstrcpy(mask,"*");
while ((dname = ReadDirName(dir_hnd, &offset))) {
+ SMB_STRUCT_STAT st;
pstring fname;
BOOL sys_direntry = False;
pstrcpy(fname,dname);
+ if (!is_visible_file(conn, directory, dname, &st, True)) {
+ continue;
+ }
+
/* Quick check for "." and ".." */
if (fname[0] == '.') {
if (!fname[1] || (fname[1] == '.' && !fname[2])) {
@@ -3368,7 +3373,7 @@ static BOOL recursive_rmdir(connection_struct *conn, char *directory)
const char *dname = NULL;
BOOL ret = False;
long offset = 0;
- struct smb_Dir *dir_hnd = OpenDir(conn, directory, False);
+ struct smb_Dir *dir_hnd = OpenDir(conn, directory);
if(dir_hnd == NULL)
return True;
@@ -3380,6 +3385,9 @@ static BOOL recursive_rmdir(connection_struct *conn, char *directory)
if((strcmp(dname, ".") == 0) || (strcmp(dname, "..")==0))
continue;
+ if (!is_visible_file(conn, directory, dname, &st, False))
+ continue;
+
/* Construct the full name. */
if(strlen(directory) + strlen(dname) + 1 >= sizeof(fullname)) {
errno = ENOMEM;
@@ -3421,6 +3429,7 @@ static BOOL recursive_rmdir(connection_struct *conn, char *directory)
BOOL rmdir_internals(connection_struct *conn, char *directory)
{
BOOL ok;
+ SMB_STRUCT_STAT st;
ok = (SMB_VFS_RMDIR(conn,directory) == 0);
if(!ok && ((errno == ENOTEMPTY)||(errno == EEXIST)) && lp_veto_files(SNUM(conn))) {
@@ -3432,13 +3441,15 @@ BOOL rmdir_internals(connection_struct *conn, char *directory)
*/
BOOL all_veto_files = True;
const char *dname;
- struct smb_Dir *dir_hnd = OpenDir(conn, directory, False);
+ struct smb_Dir *dir_hnd = OpenDir(conn, directory);
if(dir_hnd != NULL) {
long dirpos = TellDir(dir_hnd);
while ((dname = ReadDirName(dir_hnd,&dirpos))) {
if((strcmp(dname, ".") == 0) || (strcmp(dname, "..")==0))
continue;
+ if (!is_visible_file(conn, directory, dname, &st, False))
+ continue;
if(!IS_VETO_PATH(conn, dname)) {
all_veto_files = False;
break;
@@ -3449,10 +3460,11 @@ BOOL rmdir_internals(connection_struct *conn, char *directory)
SeekDir(dir_hnd,dirpos);
while ((dname = ReadDirName(dir_hnd,&dirpos))) {
pstring fullname;
- SMB_STRUCT_STAT st;
if((strcmp(dname, ".") == 0) || (strcmp(dname, "..")==0))
continue;
+ if (!is_visible_file(conn, directory, dname, &st, False))
+ continue;
/* Construct the full name. */
if(strlen(directory) + strlen(dname) + 1 >= sizeof(fullname)) {
@@ -3988,7 +4000,7 @@ directory = %s, newname = %s, last_component_dest = %s, is_8_3 = %d\n",
pstring destname;
if (check_name(directory,conn))
- dir_hnd = OpenDir(conn, directory, True);
+ dir_hnd = OpenDir(conn, directory);
if (dir_hnd) {
long offset = 0;
@@ -4015,6 +4027,9 @@ directory = %s, newname = %s, last_component_dest = %s, is_8_3 = %d\n",
}
}
+ if (!is_visible_file(conn, directory, dname, &sbuf1, False))
+ continue;
+
if(!mask_match(fname, mask, conn->case_sensitive))
continue;
@@ -4342,7 +4357,7 @@ int reply_copy(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
pstring destname;
if (check_name(directory,conn))
- dir_hnd = OpenDir(conn, directory, True);
+ dir_hnd = OpenDir(conn, directory);
if (dir_hnd) {
long offset = 0;
@@ -4355,6 +4370,9 @@ int reply_copy(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
pstring fname;
pstrcpy(fname,dname);
+ if (!is_visible_file(conn, directory, dname, &sbuf1, False))
+ continue;
+
if(!mask_match(fname, mask, conn->case_sensitive))
continue;