]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
mdssvc: Use create_conn_struct_chdir()
authorVolker Lendecke <vl@samba.org>
Mon, 16 Feb 2026 11:40:12 +0000 (12:40 +0100)
committerVolker Lendecke <vl@samba.org>
Sun, 1 Mar 2026 20:19:35 +0000 (20:19 +0000)
Simplify mdssvc by using create_conn_struct_chdir()'s destructor plus
the vfs_ChDir_shareroot call.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/rpc_server/mdssvc/mdssvc.c
source3/rpc_server/mdssvc/mdssvc.h

index 1e73850ca61523fdb5a044f0d54b9febe22cea18..fd7c7495248af5e85ff260fb8693b4b60bb90221 100644 (file)
@@ -1619,11 +1619,8 @@ static int mds_ctx_destructor_cb(struct mds_ctx *mds_ctx)
                talloc_free(mds_ctx->query_list);
        }
        TALLOC_FREE(mds_ctx->ino_path_map);
-
-       if (mds_ctx->conn != NULL) {
-               SMB_VFS_DISCONNECT(mds_ctx->conn);
-               TALLOC_FREE(mds_ctx->conn);
-       }
+       TALLOC_FREE(mds_ctx->wrap);
+       mds_ctx->conn = NULL;
 
        ZERO_STRUCTP(mds_ctx);
 
@@ -1649,7 +1646,6 @@ NTSTATUS mds_init_ctx(TALLOC_CTX *mem_ctx,
                loadparm_s3_global_substitution();
        struct mds_ctx *mds_ctx;
        int backend;
-       int ret;
        bool ok;
        smb_iconv_t iconv_hnd = (smb_iconv_t)-1;
        NTSTATUS status;
@@ -1738,26 +1734,18 @@ NTSTATUS mds_init_ctx(TALLOC_CTX *mem_ctx,
                goto error;
        }
 
-       status = create_conn_struct_cwd(mds_ctx,
-                                       msg_ctx,
-                                       session_info,
-                                       snum,
-                                       lp_path(talloc_tos(), lp_sub, snum),
-                                       &mds_ctx->conn);
+       status = create_conn_struct_chdir(mds_ctx,
+                                         msg_ctx,
+                                         snum,
+                                         lp_path(talloc_tos(), lp_sub, snum),
+                                         session_info,
+                                         &mds_ctx->wrap);
        if (!NT_STATUS_IS_OK(status)) {
                DBG_ERR("failed to create conn for vfs: %s\n",
                        nt_errstr(status));
                goto error;
        }
-
-       ret = vfs_ChDir_shareroot(mds_ctx->conn);
-       if (ret != 0) {
-               DBG_ERR("vfs_ChDir_shareroot [%s] failed: %s\n",
-                       mds_ctx->conn->connectpath,
-                       strerror(errno));
-               status = map_nt_error_from_unix(errno);
-               goto error;
-       }
+       mds_ctx->conn = conn_wrap_connection(mds_ctx->wrap);
 
        ok = mds_ctx->backend->connect(mds_ctx);
        if (!ok) {
index 6d4e684ae8d862baad50a3138074fc62164b28b7..c8ce6a7eac5f5d32d9c62467e0019becbcc37ef9 100644 (file)
@@ -128,6 +128,7 @@ struct mds_ctx {
        const char *sharename;
        const char *spath;
        size_t spath_len;
+       struct conn_wrap *wrap;
        struct connection_struct *conn;
        struct sl_query *query_list;     /* list of active queries */
        struct db_context *ino_path_map; /* dbwrap rbt for storing inode->path mappings */