The branch, master has been updated
       via  f5a2379 In vfs modules, don't use 'conn->origpath' when we really 
mean 'conn->cwd'.
       via  b6636af Move cached cwd onto conn struct.
       via  a8676e6 Remove ancient "optimization" global LastDir.
      from  893b213 Avoid overriding default ccache for ads operations.

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


- Log -----------------------------------------------------------------
commit f5a23797949334b3b37a40b8308e0db7ddff9bda
Author: Jeremy Allison <[email protected]>
Date:   Wed Sep 12 11:42:57 2012 -0700

    In vfs modules, don't use 'conn->origpath' when we really mean 'conn->cwd'.
    
    This allows VFS modules to work even when we've changed directory
    under the connect path in order to do root-safe calls.
    
    Autobuild-User(master): Jeremy Allison <[email protected]>
    Autobuild-Date(master): Wed Sep 12 23:45:23 CEST 2012 on sn-devel-104

commit b6636affaf4d475487e49ed8d5a31b94b82ae6d0
Author: Jeremy Allison <[email protected]>
Date:   Wed Sep 12 11:39:37 2012 -0700

    Move cached cwd onto conn struct.
    
    This enables us to make VFS modules safe for use in root called
    code when we've changed directory under conn->connectpath.

commit a8676e69a636648d8a309e8e000dcd62d38bfa06
Author: Jeremy Allison <[email protected]>
Date:   Wed Sep 12 11:21:01 2012 -0700

    Remove ancient "optimization" global LastDir.

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

Summary of changes:
 source3/include/vfs.h                      |    2 ++
 source3/modules/vfs_netatalk.c             |   14 +++++++-------
 source3/modules/vfs_preopen.c              |    2 +-
 source3/modules/vfs_smb_traffic_analyzer.c |    2 +-
 source3/modules/vfs_streams_depot.c        |    2 +-
 source3/smbd/globals.c                     |    1 -
 source3/smbd/globals.h                     |    1 -
 source3/smbd/service.c                     |    6 ++++++
 source3/smbd/vfs.c                         |   23 +++++++++--------------
 9 files changed, 27 insertions(+), 26 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index 8e48803..c83e7ed 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -145,6 +145,7 @@
 /* Leave at 29 - not yet released. Add durable handle functions - metze/obnox 
*/
 /* Leave at 29 - not yet released. Added sys_acl_blob_get_file and 
sys_acl_blob_get_fd */
 /* Bump to version 30 - Samba 4.0.0 will ship with interface version 30 */
+/* Leave at 30 - not yet released. Added conn->cwd to save vfs_GetWd() calls. 
*/
 #define SMB_VFS_INTERFACE_VERSION 30
 
 /*
@@ -315,6 +316,7 @@ typedef struct connection_struct {
        enum timestamp_set_resolution ts_res;
        char *connectpath;
        char *origpath;
+       char *cwd; /* Working directory. */
 
        struct vfs_handle_struct *vfs_handles;          /* for the new plugins 
*/
 
diff --git a/source3/modules/vfs_netatalk.c b/source3/modules/vfs_netatalk.c
index a457355..ff16ae3 100644
--- a/source3/modules/vfs_netatalk.c
+++ b/source3/modules/vfs_netatalk.c
@@ -229,7 +229,7 @@ static int atalk_rmdir(struct vfs_handle_struct *handle, 
const char *path)
        TALLOC_CTX *ctx = 0;
        char *dpath;
 
-       if (!handle->conn->origpath || !path) goto exit_rmdir;
+       if (!handle->conn->cwd || !path) goto exit_rmdir;
 
        /* due to there is no way to change bDeleteVetoFiles variable
         * from this module, gotta use talloc stuff..
@@ -241,7 +241,7 @@ static int atalk_rmdir(struct vfs_handle_struct *handle, 
const char *path)
                goto exit_rmdir;
 
        if (!(dpath = talloc_asprintf(ctx, "%s/%s%s", 
-         handle->conn->origpath, path, add ? "/"APPLEDOUBLE : "")))
+         handle->conn->cwd, path, add ? "/"APPLEDOUBLE : "")))
                goto exit_rmdir;
 
        atalk_rrmdir(ctx, dpath);
@@ -272,7 +272,7 @@ static int atalk_rename(struct vfs_handle_struct *handle,
                return ret;
        }
 
-       if (atalk_build_paths(talloc_tos(), handle->conn->origpath, oldname,
+       if (atalk_build_paths(talloc_tos(), handle->conn->cwd, oldname,
                              &adbl_path, &orig_path, &adbl_info,
                              &orig_info) != 0)
                goto exit_rename;
@@ -333,7 +333,7 @@ static int atalk_unlink(struct vfs_handle_struct *handle,
                }
        }
 
-       if (atalk_build_paths(talloc_tos(), handle->conn->origpath, path,
+       if (atalk_build_paths(talloc_tos(), handle->conn->cwd, path,
                              &adbl_path, &orig_path,
                              &adbl_info, &orig_info) != 0)
                goto exit_unlink;
@@ -368,7 +368,7 @@ static int atalk_chmod(struct vfs_handle_struct *handle, 
const char *path, mode_
        if (!(ctx = talloc_init("chmod_file")))
                return ret;
 
-       if (atalk_build_paths(ctx, handle->conn->origpath, path, &adbl_path,
+       if (atalk_build_paths(ctx, handle->conn->cwd, path, &adbl_path,
                              &orig_path, &adbl_info, &orig_info) != 0)
                goto exit_chmod;
 
@@ -400,7 +400,7 @@ static int atalk_chown(struct vfs_handle_struct *handle, 
const char *path, uid_t
        if (!(ctx = talloc_init("chown_file")))
                return ret;
 
-       if (atalk_build_paths(ctx, handle->conn->origpath, path,
+       if (atalk_build_paths(ctx, handle->conn->cwd, path,
                              &adbl_path, &orig_path,
                              &adbl_info, &orig_info) != 0)
                goto exit_chown;
@@ -435,7 +435,7 @@ static int atalk_lchown(struct vfs_handle_struct *handle, 
const char *path, uid_
        if (!(ctx = talloc_init("lchown_file")))
                return ret;
 
-       if (atalk_build_paths(ctx, handle->conn->origpath, path,
+       if (atalk_build_paths(ctx, handle->conn->cwd, path,
                              &adbl_path, &orig_path,
                              &adbl_info, &orig_info) != 0)
                goto exit_lchown;
diff --git a/source3/modules/vfs_preopen.c b/source3/modules/vfs_preopen.c
index 3540d34..108ca29 100644
--- a/source3/modules/vfs_preopen.c
+++ b/source3/modules/vfs_preopen.c
@@ -405,7 +405,7 @@ static int preopen_open(vfs_handle_struct *handle,
 
        TALLOC_FREE(state->template_fname);
        state->template_fname = talloc_asprintf(
-               state, "%s/%s", fsp->conn->connectpath, smb_fname->base_name);
+               state, "%s/%s", fsp->conn->cwd, smb_fname->base_name);
 
        if (state->template_fname == NULL) {
                return res;
diff --git a/source3/modules/vfs_smb_traffic_analyzer.c 
b/source3/modules/vfs_smb_traffic_analyzer.c
index c728e7d..9151bfb 100644
--- a/source3/modules/vfs_smb_traffic_analyzer.c
+++ b/source3/modules/vfs_smb_traffic_analyzer.c
@@ -491,7 +491,7 @@ static void 
smb_traffic_analyzer_send_data(vfs_handle_struct *handle,
                        username,
                        handle->conn->session_info->info->domain_name,
                        Write ? 'W' : 'R',
-                       handle->conn->connectpath,
+                       handle->conn->cwd,
                        s_data->filename,
                        tm->tm_year+1900,
                        tm->tm_mon+1,
diff --git a/source3/modules/vfs_streams_depot.c 
b/source3/modules/vfs_streams_depot.c
index a3ce8c1..c0d5945 100644
--- a/source3/modules/vfs_streams_depot.c
+++ b/source3/modules/vfs_streams_depot.c
@@ -129,7 +129,7 @@ static char *stream_dir(vfs_handle_struct *handle,
        check_valid = lp_parm_bool(SNUM(handle->conn),
                      "streams_depot", "check_valid", true);
 
-       tmp = talloc_asprintf(talloc_tos(), "%s/.streams", 
handle->conn->connectpath);
+       tmp = talloc_asprintf(talloc_tos(), "%s/.streams", handle->conn->cwd);
 
        if (tmp == NULL) {
                errno = ENOMEM;
diff --git a/source3/smbd/globals.c b/source3/smbd/globals.c
index 80f6a66..874f35d 100644
--- a/source3/smbd/globals.c
+++ b/source3/smbd/globals.c
@@ -85,7 +85,6 @@ int conn_ctx_stack_ndx = 0;
 
 struct vfs_init_function_entry *backends = NULL;
 char *sparse_buf = NULL;
-char *LastDir = NULL;
 
 struct smbd_parent_context *am_parent = NULL;
 struct memcache *smbd_memcache_ctx = NULL;
diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h
index 566f04d..1cefe51 100644
--- a/source3/smbd/globals.h
+++ b/source3/smbd/globals.h
@@ -101,7 +101,6 @@ extern int conn_ctx_stack_ndx;
 struct vfs_init_function_entry;
 extern struct vfs_init_function_entry *backends;
 extern char *sparse_buf;
-extern char *LastDir;
 
 struct smbd_parent_context;
 extern struct smbd_parent_context *am_parent;
diff --git a/source3/smbd/service.c b/source3/smbd/service.c
index 0cd48f8..b2d3d4d 100644
--- a/source3/smbd/service.c
+++ b/source3/smbd/service.c
@@ -164,6 +164,12 @@ bool set_conn_connectpath(connection_struct *conn, const 
char *connectpath)
 
        talloc_free(conn->connectpath);
        conn->connectpath = destname;
+       /* Ensure conn->cwd is initialized - start as conn->connectpath. */
+       TALLOC_FREE(conn->cwd);
+       conn->cwd = talloc_strdup(conn, conn->connectpath);
+       if (!conn->cwd) {
+               return false;
+       }
        return true;
 }
 
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index 763ef37..7d19440 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -799,26 +799,21 @@ const char *vfs_readdirname(connection_struct *conn, void 
*p,
 
 int vfs_ChDir(connection_struct *conn, const char *path)
 {
-       int res;
+       int ret;
 
-       if (!LastDir) {
-               LastDir = SMB_STRDUP("");
+       if (strcsequal(path,".")) {
+               return 0;
        }
 
-       if (strcsequal(path,"."))
-               return(0);
-
-       if (*path == '/' && strcsequal(LastDir,path))
-               return(0);
-
        DEBUG(4,("vfs_ChDir to %s\n",path));
 
-       res = SMB_VFS_CHDIR(conn,path);
-       if (!res) {
-               SAFE_FREE(LastDir);
-               LastDir = SMB_STRDUP(path);
+       ret = SMB_VFS_CHDIR(conn,path);
+       if (ret == 0) {
+               TALLOC_FREE(conn->cwd);
+               conn->cwd = vfs_GetWd(conn, conn);
+               DEBUG(4,("vfs_ChDir got %s\n",conn->cwd));
        }
-       return(res);
+       return ret;
 }
 
 /*******************************************************************


-- 
Samba Shared Repository

Reply via email to