mdssvc: chdir() to the conn of the RPC request
authorRalph Boehme <slow@samba.org>
Tue, 15 Jun 2021 12:14:52 +0000 (14:14 +0200)
committerRalph Boehme <slow@samba.org>
Wed, 16 Jun 2021 05:08:29 +0000 (05:08 +0000)
In preperation of calling VFS functions.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14740

Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/rpc_server/mdssvc/mdssvc.c

index 5b864eeb8f1e52887c4c3b41fdf75f5c3226b65e..84c60c17961ffbcea1fae7211b544fef14a56aa8 100644 (file)
@@ -1674,11 +1674,15 @@ bool mds_dispatch(struct mds_ctx *mds_ctx,
                  struct mdssvc_blob *response_blob)
 {
        bool ok;
+       int ret;
        ssize_t len;
        DALLOC_CTX *query = NULL;
        DALLOC_CTX *reply = NULL;
        char *rpccmd;
        const struct slrpc_cmd *slcmd;
+       const struct smb_filename conn_basedir = {
+               .base_name = mds_ctx->conn->connectpath,
+       };
 
        if (CHECK_DEBUGLVL(10)) {
                const struct sl_query *slq;
@@ -1730,6 +1734,14 @@ bool mds_dispatch(struct mds_ctx *mds_ctx,
                goto cleanup;
        }
 
+       ret = vfs_ChDir(mds_ctx->conn, &conn_basedir);
+       if (ret != 0) {
+               DBG_ERR("vfs_ChDir [%s] failed: %s\n",
+                       conn_basedir.base_name, strerror(errno));
+               ok = false;
+               goto cleanup;
+       }
+
        ok = slcmd->function(mds_ctx, query, reply);
        if (ok) {
                DBG_DEBUG("%s", dalloc_dump(reply, 0));