The branch, master has been updated
       via  4b0af9b Make it clear we're using the open file pathname.
       via  1607ebf Allow SMB2_FIND to actually use the open fd handle if we 
support fdopendir. Fallback to pathname opendir if not.
       via  61c1f31 Correctly plumb in VFS_FDOPENDIR.
      from  d0406ab s3-waf: make ads support detection a little more robust.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 4b0af9be9a887b78a71eda26d418546330889ed1
Author: Jeremy Allison <[email protected]>
Date:   Wed Feb 9 15:06:40 2011 -0800

    Make it clear we're using the open file pathname.
    
    Autobuild-User: Jeremy Allison <[email protected]>
    Autobuild-Date: Thu Feb 10 01:06:29 CET 2011 on sn-devel-104

commit 1607ebfe8632fa13c5ffb466b8c9f416d7ab20aa
Author: Jeremy Allison <[email protected]>
Date:   Wed Feb 9 15:05:58 2011 -0800

    Allow SMB2_FIND to actually use the open fd handle if we support fdopendir. 
Fallback to pathname opendir if not.

commit 61c1f312d2665197d34245537a8f5b641bda1243
Author: Jeremy Allison <[email protected]>
Date:   Wed Feb 9 15:00:56 2011 -0800

    Correctly plumb in VFS_FDOPENDIR.

-----------------------------------------------------------------------

Summary of changes:
 source3/include/proto.h       |    4 ++-
 source3/include/vfs_macros.h  |    4 +-
 source3/modules/vfs_default.c |    1 +
 source3/smbd/close.c          |    3 +-
 source3/smbd/dir.c            |   54 ++++++++++++++++++++++++++++++++--------
 source3/smbd/filename.c       |    2 +-
 source3/smbd/reply.c          |    7 +++--
 source3/smbd/smb2_find.c      |   11 ++++----
 source3/smbd/trans2.c         |    1 +
 9 files changed, 62 insertions(+), 25 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/proto.h b/source3/include/proto.h
index 0cca013..969d12f 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -4547,7 +4547,8 @@ void dptr_closecnum(connection_struct *conn);
 void dptr_idlecnum(connection_struct *conn);
 void dptr_closepath(struct smbd_server_connection *sconn,
                    char *path,uint16 spid);
-NTSTATUS dptr_create(connection_struct *conn, const char *path, bool 
old_handle, bool expect_close,uint16 spid,
+NTSTATUS dptr_create(connection_struct *conn, files_struct *fsp,
+               const char *path, bool old_handle, bool expect_close,uint16 
spid,
                const char *wcard, bool wcard_has_wild, uint32 attr, struct 
dptr_struct **dptr_ret);
 void dptr_CloseDir(files_struct *fsp);
 void dptr_SeekDir(struct dptr_struct *dptr, long offset);
@@ -4580,6 +4581,7 @@ bool get_dir_entry(TALLOC_CTX *ctx,
                bool ask_sharemode);
 bool is_visible_file(connection_struct *conn, const char *dir_path, const char 
*name, SMB_STRUCT_STAT *pst, bool use_veto);
 struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx, connection_struct *conn,
+                       files_struct *fsp,
                        const char *name, const char *mask, uint32 attr);
 const char *ReadDirName(struct smb_Dir *dirp, long *poffset,
                        SMB_STRUCT_STAT *sbuf, char **talloced);
diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h
index c0fbe38..7c26529 100644
--- a/source3/include/vfs_macros.h
+++ b/source3/include/vfs_macros.h
@@ -74,8 +74,8 @@
 #define SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr) \
        smb_vfs_call_opendir((handle)->next, (fname), (mask), (attr))
 
-#define SMB_VFS_FDOPENDIR(conn, fsp, mask, attr) \
-       smb_vfs_call_fdopendir((conn)->vfs_handles, (fsp), (mask), (attr))
+#define SMB_VFS_FDOPENDIR(fsp, mask, attr) \
+       smb_vfs_call_fdopendir((fsp)->conn->vfs_handles, (fsp), (mask), (attr))
 #define SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask, attr) \
        smb_vfs_call_fdopendir((handle)->next, (fsp), (mask), (attr))
 
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index eb5a2a4..5448db8 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -1647,6 +1647,7 @@ static struct vfs_fn_pointers vfs_default_fns = {
        /* Directory operations */
 
        .opendir = vfswrap_opendir,
+       .fdopendir = vfswrap_fdopendir,
        .readdir = vfswrap_readdir,
        .seekdir = vfswrap_seekdir,
        .telldir = vfswrap_telldir,
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index d5a824f..60cf8ed 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -699,7 +699,7 @@ static bool recursive_rmdir(TALLOC_CTX *ctx,
 
        SMB_ASSERT(!is_ntfs_stream_smb_fname(smb_dname));
 
-       dir_hnd = OpenDir(talloc_tos(), conn, smb_dname->base_name, NULL, 0);
+       dir_hnd = OpenDir(talloc_tos(), conn, NULL, smb_dname->base_name, NULL, 
0);
        if(dir_hnd == NULL)
                return False;
 
@@ -817,6 +817,7 @@ static NTSTATUS rmdir_internals(TALLOC_CTX *ctx, 
files_struct *fsp)
                char *talloced = NULL;
                long dirpos = 0;
                struct smb_Dir *dir_hnd = OpenDir(talloc_tos(), conn,
+                                                 NULL,
                                                  smb_dname->base_name, NULL,
                                                  0);
 
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index f81206e..edc1ffe 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -190,7 +190,7 @@ static struct dptr_struct *dptr_get(struct 
smbd_server_connection *sconn,
                                        dptr_idleoldest(sconn);
                                DEBUG(4,("dptr_get: Reopening dptr key 
%d\n",key));
                                if (!(dptr->dir_hnd = OpenDir(
-                                             NULL, dptr->conn, dptr->path,
+                                             NULL, dptr->conn, NULL, 
dptr->path,
                                              dptr->wcard, dptr->attr))) {
                                        DEBUG(4,("dptr_get: Failed to open %s 
(%s)\n",dptr->path,
                                                strerror(errno)));
@@ -413,7 +413,8 @@ static void dptr_close_oldest(struct smbd_server_connection 
*sconn,
  wcard must not be zero.
 ****************************************************************************/
 
-NTSTATUS dptr_create(connection_struct *conn, const char *path, bool 
old_handle, bool expect_close,uint16 spid,
+NTSTATUS dptr_create(connection_struct *conn, files_struct *fsp,
+               const char *path, bool old_handle, bool expect_close,uint16 
spid,
                const char *wcard, bool wcard_has_wild, uint32 attr, struct 
dptr_struct **dptr_ret)
 {
        struct smbd_server_connection *sconn = conn->sconn;
@@ -421,6 +422,10 @@ NTSTATUS dptr_create(connection_struct *conn, const char 
*path, bool old_handle,
        struct smb_Dir *dir_hnd;
        NTSTATUS status;
 
+       if (fsp && fsp->is_directory && fsp->fh->fd != -1) {
+               path = fsp->fsp_name->base_name;
+       }
+
        DEBUG(5,("dptr_create dir=%s\n", path));
 
        if (sconn == NULL) {
@@ -432,12 +437,14 @@ NTSTATUS dptr_create(connection_struct *conn, const char 
*path, bool old_handle,
                return NT_STATUS_INVALID_PARAMETER;
        }
 
-       status = check_name(conn,path);
-       if (!NT_STATUS_IS_OK(status)) {
-               return status;
+       if (!fsp) {
+               status = check_name(conn,path);
+               if (!NT_STATUS_IS_OK(status)) {
+                       return status;
+               }
        }
 
-       dir_hnd = OpenDir(NULL, conn, path, wcard, attr);
+       dir_hnd = OpenDir(NULL, conn, fsp, path, wcard, attr);
        if (!dir_hnd) {
                return map_nt_error_from_unix(errno);
        }
@@ -1305,7 +1312,10 @@ static int smb_Dir_destructor(struct smb_Dir *dirp)
 ********************************************************************/
 
 struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx, connection_struct *conn,
-                       const char *name, const char *mask, uint32 attr)
+                       files_struct *fsp,
+                       const char *name,
+                       const char *mask,
+                       uint32 attr)
 {
        struct smb_Dir *dirp = TALLOC_ZERO_P(mem_ctx, struct smb_Dir);
        struct smbd_server_connection *sconn = conn->sconn;
@@ -1317,7 +1327,11 @@ struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx, 
connection_struct *conn,
        dirp->conn = conn;
        dirp->name_cache_size = lp_directory_name_cache_size(SNUM(conn));
 
-       dirp->dir_path = talloc_strdup(dirp, name);
+       if (fsp) {
+               dirp->dir_path = talloc_strdup(dirp, fsp->fsp_name->base_name);
+       } else {
+               dirp->dir_path = talloc_strdup(dirp, name);
+       }
        if (!dirp->dir_path) {
                errno = ENOMEM;
                goto fail;
@@ -1328,7 +1342,25 @@ struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx, 
connection_struct *conn,
        }
        talloc_set_destructor(dirp, smb_Dir_destructor);
 
-       dirp->dir = SMB_VFS_OPENDIR(conn, dirp->dir_path, mask, attr);
+       if (fsp && fsp->is_directory && fsp->fh->fd != -1) {
+               dirp->dir = SMB_VFS_FDOPENDIR(fsp, mask, attr);
+               if (dirp->dir == NULL) {
+                       DEBUG(10,("OpenDir: SMB_VFS_FDOPENDIR on %s returned "
+                               "NULL (%s)\n",
+                               dirp->dir_path,
+                               strerror(errno)));
+                       if (errno != ENOSYS) {
+                               return NULL;
+                       }
+               }
+       }
+
+       if (dirp->dir == NULL) {
+               /* FDOPENDIR didn't work - or fsp == NULL. Use
+                  OPENDIR instead. */
+               dirp->dir = SMB_VFS_OPENDIR(conn, dirp->dir_path, mask, attr);
+       }
+
        if (!dirp->dir) {
                DEBUG(5,("OpenDir: Can't open %s. %s\n", dirp->dir_path,
                         strerror(errno) ));
@@ -1536,8 +1568,8 @@ NTSTATUS can_delete_directory(struct connection_struct 
*conn,
        const char *dname = NULL;
        char *talloced = NULL;
        SMB_STRUCT_STAT st;
-       struct smb_Dir *dir_hnd = OpenDir(talloc_tos(), conn, dirname,
-                                         NULL, 0);
+       struct smb_Dir *dir_hnd = OpenDir(talloc_tos(), conn, NULL,
+                                       dirname, NULL, 0);
 
        if (!dir_hnd) {
                return map_nt_error_from_unix(errno);
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index 0387721..8e6de84 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -1074,7 +1074,7 @@ static int get_real_filename_full_scan(connection_struct 
*conn,
        }
 
        /* open the directory */
-       if (!(cur_dir = OpenDir(talloc_tos(), conn, path, NULL, 0))) {
+       if (!(cur_dir = OpenDir(talloc_tos(), conn, NULL, path, NULL, 0))) {
                DEBUG(3,("scan dir didn't open dir [%s]\n",path));
                TALLOC_FREE(unmangled_name);
                return -1;
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index e64627b..120b8bc 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -1460,6 +1460,7 @@ void reply_search(struct smb_request *req)
                SCVAL(status,0,(dirtype & 0x1F));
 
                nt_status = dptr_create(conn,
+                                       NULL, /* fsp */
                                        directory,
                                        True,
                                        expect_close,
@@ -2646,7 +2647,7 @@ NTSTATUS unlink_internals(connection_struct *conn, struct 
smb_request *req,
                        goto out;
                }
 
-               dir_hnd = OpenDir(talloc_tos(), conn, fname_dir, fname_mask,
+               dir_hnd = OpenDir(talloc_tos(), conn, NULL, fname_dir, 
fname_mask,
                                  dirtype);
                if (dir_hnd == NULL) {
                        status = map_nt_error_from_unix(errno);
@@ -6379,7 +6380,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
                goto out;
        }
 
-       dir_hnd = OpenDir(talloc_tos(), conn, fname_src_dir, fname_src_mask,
+       dir_hnd = OpenDir(talloc_tos(), conn, NULL, fname_src_dir, 
fname_src_mask,
                          attrs);
        if (dir_hnd == NULL) {
                status = map_nt_error_from_unix(errno);
@@ -7066,7 +7067,7 @@ void reply_copy(struct smb_request *req)
                        goto out;
                }
 
-               dir_hnd = OpenDir(ctx, conn, fname_src_dir, fname_src_mask, 0);
+               dir_hnd = OpenDir(ctx, conn, NULL, fname_src_dir, 
fname_src_mask, 0);
                if (dir_hnd == NULL) {
                        status = map_nt_error_from_unix(errno);
                        reply_nterror(req, status);
diff --git a/source3/smbd/smb2_find.c b/source3/smbd/smb2_find.c
index b10446c..1ee493b 100644
--- a/source3/smbd/smb2_find.c
+++ b/source3/smbd/smb2_find.c
@@ -227,7 +227,6 @@ static struct tevent_req *smbd_smb2_find_send(TALLOC_CTX 
*mem_ctx,
        int off = 0;
        uint32_t num = 0;
        uint32_t dirtype = aHIDDEN | aSYSTEM | aDIR;
-       const char *directory;
        bool dont_descend = false;
        bool ask_sharemode = true;
 
@@ -266,8 +265,6 @@ static struct tevent_req *smbd_smb2_find_send(TALLOC_CTX 
*mem_ctx,
                return tevent_req_post(req, ev);
        }
 
-       directory = fsp->fsp_name->base_name;
-
        if (strcmp(in_file_name, "") == 0) {
                tevent_req_nterror(req, NT_STATUS_OBJECT_NAME_INVALID);
                return tevent_req_post(req, ev);
@@ -331,7 +328,8 @@ static struct tevent_req *smbd_smb2_find_send(TALLOC_CTX 
*mem_ctx,
                wcard_has_wild = ms_has_wild(in_file_name);
 
                status = dptr_create(conn,
-                                    directory,
+                                    fsp,
+                                    fsp->fsp_name->base_name,
                                     false, /* old_handle */
                                     false, /* expect_close */
                                     0, /* spid */
@@ -381,9 +379,10 @@ static struct tevent_req *smbd_smb2_find_send(TALLOC_CTX 
*mem_ctx,
 
        DEBUG(8,("smbd_smb2_find_send: dirpath=<%s> dontdescend=<%s>, "
                "in_output_buffer_length = %u\n",
-               directory, lp_dontdescend(SNUM(conn)),
+               fsp->fsp_name->base_name, lp_dontdescend(SNUM(conn)),
                (unsigned int)in_output_buffer_length ));
-       if (in_list(directory,lp_dontdescend(SNUM(conn)),conn->case_sensitive)) 
{
+       if (in_list(fsp->fsp_name->base_name,lp_dontdescend(SNUM(conn)),
+                       conn->case_sensitive)) {
                dont_descend = true;
        }
 
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 2ce1fd7..ed8e9f5 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -2417,6 +2417,7 @@ total_data=%u (should be %u)\n", (unsigned 
int)total_data, (unsigned int)IVAL(pd
                needed as lanman2 assumes these are being saved between calls */
 
        ntstatus = dptr_create(conn,
+                               NULL, /* fsp */
                                directory,
                                False,
                                True,


-- 
Samba Shared Repository

Reply via email to