The Samba-Bugzilla – Attachment 16659 Details for
Bug 14740
Spotlight RPC service doesn't work with vfs_glusterfs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for 4.14 backported from master
bug14740-v414.patch (text/plain), 21.19 KB, created by
Ralph Böhme
on 2021-06-16 10:10:49 UTC
(
hide
)
Description:
Patch for 4.14 backported from master
Filename:
MIME Type:
Creator:
Ralph Böhme
Created:
2021-06-16 10:10:49 UTC
Size:
21.19 KB
patch
obsolete
>From 4bb4750efa08a291a95c9708bbe14ba5304e1ca9 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Thu, 21 Jan 2021 15:04:57 +0100 >Subject: [PATCH 1/9] smbd: add synthetic_pathref() > >Similar to synthetic_smb_fname(), but also opens a pathref fsp. > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit d9f95b8cefe2d1c8020592434481025aa1045e2f) >--- > source3/smbd/files.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ > source3/smbd/proto.h | 9 ++++++++ > 2 files changed, 61 insertions(+) > >diff --git a/source3/smbd/files.c b/source3/smbd/files.c >index 371af875d4b..b70ce9f70e6 100644 >--- a/source3/smbd/files.c >+++ b/source3/smbd/files.c >@@ -618,6 +618,58 @@ NTSTATUS move_smb_fname_fsp_link(struct smb_filename *smb_fname_dst, > return NT_STATUS_OK; > } > >+/** >+ * Create an smb_fname and open smb_fname->fsp pathref >+ **/ >+NTSTATUS synthetic_pathref(TALLOC_CTX *mem_ctx, >+ struct files_struct *dirfsp, >+ const char *base_name, >+ const char *stream_name, >+ const SMB_STRUCT_STAT *psbuf, >+ NTTIME twrp, >+ uint32_t flags, >+ struct smb_filename **_smb_fname) >+{ >+ struct smb_filename *smb_fname = NULL; >+ NTSTATUS status; >+ int ret; >+ >+ smb_fname = synthetic_smb_fname(mem_ctx, >+ base_name, >+ stream_name, >+ psbuf, >+ twrp, >+ flags); >+ if (smb_fname == NULL) { >+ return NT_STATUS_NO_MEMORY; >+ } >+ >+ if (!VALID_STAT(smb_fname->st)) { >+ ret = vfs_stat(dirfsp->conn, smb_fname); >+ if (ret != 0) { >+ DBG_ERR("stat [%s] failed: %s", >+ smb_fname_str_dbg(smb_fname), >+ strerror(errno)); >+ TALLOC_FREE(smb_fname); >+ return map_nt_error_from_unix(errno); >+ } >+ } >+ >+ status = openat_pathref_fsp(dirfsp, smb_fname); >+ if (NT_STATUS_EQUAL(status, NT_STATUS_STOPPED_ON_SYMLINK)) { >+ status = NT_STATUS_OBJECT_NAME_NOT_FOUND; >+ } >+ if (!NT_STATUS_IS_OK(status)) { >+ DBG_ERR("opening [%s] failed\n", >+ smb_fname_str_dbg(smb_fname)); >+ TALLOC_FREE(smb_fname); >+ return status; >+ } >+ >+ *_smb_fname = smb_fname; >+ return NT_STATUS_OK; >+} >+ > /**************************************************************************** > Close all open files for a connection. > ****************************************************************************/ >diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h >index 2e181a94e91..a65c786c24d 100644 >--- a/source3/smbd/proto.h >+++ b/source3/smbd/proto.h >@@ -468,6 +468,15 @@ void smb_fname_fsp_unlink(struct smb_filename *smb_fname); > NTSTATUS move_smb_fname_fsp_link(struct smb_filename *smb_fname_dst, > struct smb_filename *smb_fname_src); > >+NTSTATUS synthetic_pathref(TALLOC_CTX *mem_ctx, >+ struct files_struct *dirfsp, >+ const char *base_name, >+ const char *stream_name, >+ const SMB_STRUCT_STAT *psbuf, >+ NTTIME twrp, >+ uint32_t flags, >+ struct smb_filename **_smb_fname); >+ > /* The following definitions come from smbd/ipc.c */ > > NTSTATUS nt_status_np_pipe(NTSTATUS status); >-- >2.31.1 > > >From 9dc6990a45c8e9513d7f2505617d98d4fb6d8823 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Mon, 10 May 2021 11:04:38 +0200 >Subject: [PATCH 2/9] mdssvc: use a helper variable in mds_add_result() > >No change in behaviour. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=14740 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit e2486d76b611f07b85b26c54fe14da7b76bd01c2) >--- > source3/rpc_server/mdssvc/mdssvc.c | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) > >diff --git a/source3/rpc_server/mdssvc/mdssvc.c b/source3/rpc_server/mdssvc/mdssvc.c >index 0df29dc9b1e..1b0badc4851 100644 >--- a/source3/rpc_server/mdssvc/mdssvc.c >+++ b/source3/rpc_server/mdssvc/mdssvc.c >@@ -554,17 +554,19 @@ bool mds_add_result(struct sl_query *slq, const char *path) > > ino64 = sb.st_ex_ino; > if (slq->cnids) { >+ bool found; >+ > /* > * Check whether the found element is in the requested > * set of IDs. Note that we're faking CNIDs by using > * filesystem inode numbers here > */ >- ok = bsearch(&ino64, >- slq->cnids, >- slq->cnids_num, >- sizeof(uint64_t), >- cnid_comp_fn); >- if (!ok) { >+ found = bsearch(&ino64, >+ slq->cnids, >+ slq->cnids_num, >+ sizeof(uint64_t), >+ cnid_comp_fn); >+ if (!found) { > return false; > } > } >-- >2.31.1 > > >From 1404095e550c75fb703315c8c31e3f9397728b8e Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Mon, 10 May 2021 11:07:27 +0200 >Subject: [PATCH 3/9] mdssvc: don't fail mds_add_result() if result is not > found in CNID set > >Just skip adding the result to the pending results set, don't return an >error. Returning an error triggers an error at the MDSSVC RPC error which is NOT >what we want here. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=14740 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit 8847f46f75ac5c1a753a0e7da88c522be25ef681) >--- > source3/rpc_server/mdssvc/mdssvc.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/source3/rpc_server/mdssvc/mdssvc.c b/source3/rpc_server/mdssvc/mdssvc.c >index 1b0badc4851..60934fb63cc 100644 >--- a/source3/rpc_server/mdssvc/mdssvc.c >+++ b/source3/rpc_server/mdssvc/mdssvc.c >@@ -567,7 +567,7 @@ bool mds_add_result(struct sl_query *slq, const char *path) > sizeof(uint64_t), > cnid_comp_fn); > if (!found) { >- return false; >+ return true; > } > } > >-- >2.31.1 > > >From 83d6200aa60427d4ff7d624483d23f42f6a11ca1 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Mon, 10 May 2021 12:08:17 +0200 >Subject: [PATCH 4/9] mdssvc: pass messaging context to mds_init_ctx() > >This is needed in a subsequent commit. Note that I prefer to do the event >context unwrapping in the caller and pass both the event and messaging context >explicitly to mds_init_ctx(). > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=14740 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit 1ef2828e1025e4c89292df1dfa6161c4453b3afe) >--- > source3/rpc_server/mdssvc/mdssvc.c | 1 + > source3/rpc_server/mdssvc/mdssvc.h | 1 + > source3/rpc_server/mdssvc/srv_mdssvc_nt.c | 1 + > 3 files changed, 3 insertions(+) > >diff --git a/source3/rpc_server/mdssvc/mdssvc.c b/source3/rpc_server/mdssvc/mdssvc.c >index 60934fb63cc..a568ed35125 100644 >--- a/source3/rpc_server/mdssvc/mdssvc.c >+++ b/source3/rpc_server/mdssvc/mdssvc.c >@@ -1525,6 +1525,7 @@ static int mds_ctx_destructor_cb(struct mds_ctx *mds_ctx) > **/ > struct mds_ctx *mds_init_ctx(TALLOC_CTX *mem_ctx, > struct tevent_context *ev, >+ struct messaging_context *msg_ctx, > struct auth_session_info *session_info, > int snum, > const char *sharename, >diff --git a/source3/rpc_server/mdssvc/mdssvc.h b/source3/rpc_server/mdssvc/mdssvc.h >index 7d9a902a80b..d37f6846711 100644 >--- a/source3/rpc_server/mdssvc/mdssvc.h >+++ b/source3/rpc_server/mdssvc/mdssvc.h >@@ -150,6 +150,7 @@ extern bool mds_init(struct messaging_context *msg_ctx); > extern bool mds_shutdown(void); > struct mds_ctx *mds_init_ctx(TALLOC_CTX *mem_ctx, > struct tevent_context *ev, >+ struct messaging_context *msg_ctx, > struct auth_session_info *session_info, > int snum, > const char *sharename, >diff --git a/source3/rpc_server/mdssvc/srv_mdssvc_nt.c b/source3/rpc_server/mdssvc/srv_mdssvc_nt.c >index 56ebe68c7e9..b8eed8b6ff9 100644 >--- a/source3/rpc_server/mdssvc/srv_mdssvc_nt.c >+++ b/source3/rpc_server/mdssvc/srv_mdssvc_nt.c >@@ -96,6 +96,7 @@ static NTSTATUS create_mdssvc_policy_handle(TALLOC_CTX *mem_ctx, > > mds_ctx = mds_init_ctx(mem_ctx, > messaging_tevent_context(p->msg_ctx), >+ p->msg_ctx, > p->session_info, > snum, > sharename, >-- >2.31.1 > > >From 6f2706f1250e66567d13f6db65915e3421c9a517 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Tue, 15 Jun 2021 11:17:57 +0200 >Subject: [PATCH 5/9] smbd: pass tevent context to create_conn_struct_as_root() > >The next commit will add another caller of create_conn_struct_as_root() that is >going to pass a long-lived tevent context. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=14740 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit 16c39b81d6f2c7d75cfe72bbbe2f6a5bde42c7b0) >--- > source3/smbd/msdfs.c | 16 ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) > >diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c >index dc07727f007..f07cf75775b 100644 >--- a/source3/smbd/msdfs.c >+++ b/source3/smbd/msdfs.c >@@ -242,6 +242,7 @@ static NTSTATUS parse_dfs_path(connection_struct *conn, > *********************************************************/ > > static NTSTATUS create_conn_struct_as_root(TALLOC_CTX *ctx, >+ struct tevent_context *ev, > struct messaging_context *msg, > connection_struct **pconn, > int snum, >@@ -260,12 +261,7 @@ static NTSTATUS create_conn_struct_as_root(TALLOC_CTX *ctx, > return NT_STATUS_NO_MEMORY; > } > >- sconn->ev_ctx = samba_tevent_context_init(sconn); >- if (sconn->ev_ctx == NULL) { >- TALLOC_FREE(sconn); >- return NT_STATUS_NO_MEMORY; >- } >- >+ sconn->ev_ctx = ev; > sconn->msg_ctx = msg; > > conn = conn_new(sconn); >@@ -401,6 +397,7 @@ NTSTATUS create_conn_struct_tos(struct messaging_context *msg, > struct conn_struct_tos **_c) > { > struct conn_struct_tos *c = NULL; >+ struct tevent_context *ev = NULL; > NTSTATUS status; > > *_c = NULL; >@@ -410,8 +407,15 @@ NTSTATUS create_conn_struct_tos(struct messaging_context *msg, > return NT_STATUS_NO_MEMORY; > } > >+ ev = samba_tevent_context_init(c); >+ if (ev == NULL) { >+ TALLOC_FREE(c); >+ return NT_STATUS_NO_MEMORY; >+ } >+ > become_root(); > status = create_conn_struct_as_root(c, >+ ev, > msg, > &c->conn, > snum, >-- >2.31.1 > > >From e7fc90001605a72af662b91ca88db6a6006624ea Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Fri, 28 May 2021 09:25:22 +0200 >Subject: [PATCH 6/9] smbd: add create_conn_struct_cwd() > >Compared to create_conn_struct_tos_cwd() this takes a TALLOC_CTX and >tevent_context as additional arguments and the resulting connection_struct is >stable across the lifetime of mem_ctx and ev. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=14740 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit 9a2d6bcfd5797dd4db764921548c8dca6dd0eb21) >--- > source3/smbd/msdfs.c | 38 ++++++++++++++++++++++++++++++++++++++ > source3/smbd/proto.h | 8 ++++++++ > 2 files changed, 46 insertions(+) > >diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c >index f07cf75775b..3a1dd11d9eb 100644 >--- a/source3/smbd/msdfs.c >+++ b/source3/smbd/msdfs.c >@@ -495,6 +495,44 @@ NTSTATUS create_conn_struct_tos_cwd(struct messaging_context *msg, > return NT_STATUS_OK; > } > >+/******************************************************** >+ Fake up a connection struct for the VFS layer. >+ This takes an TALLOC_CTX and tevent_context from the >+ caller and the resulting connection_struct is stable >+ across the lifetime of mem_ctx and ev. >+ >+ Note: this performs a vfs connect and changes cwd. >+ >+ See also the comment for create_conn_struct_tos() above! >+*********************************************************/ >+ >+NTSTATUS create_conn_struct_cwd(TALLOC_CTX *mem_ctx, >+ struct tevent_context *ev, >+ struct messaging_context *msg, >+ const struct auth_session_info *session_info, >+ int snum, >+ const char *path, >+ struct connection_struct **c) >+{ >+ NTSTATUS status; >+ >+ become_root(); >+ status = create_conn_struct_as_root(mem_ctx, >+ ev, >+ msg, >+ c, >+ snum, >+ path, >+ session_info); >+ unbecome_root(); >+ if (!NT_STATUS_IS_OK(status)) { >+ TALLOC_FREE(c); >+ return status; >+ } >+ >+ return NT_STATUS_OK; >+} >+ > static void shuffle_strlist(char **list, int count) > { > int i; >diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h >index a65c786c24d..90543a59feb 100644 >--- a/source3/smbd/proto.h >+++ b/source3/smbd/proto.h >@@ -579,6 +579,14 @@ NTSTATUS dfs_redirect(TALLOC_CTX *ctx, > char **pp_name_out); > struct connection_struct; > struct smb_filename; >+ >+NTSTATUS create_conn_struct_cwd(TALLOC_CTX *mem_ctx, >+ struct tevent_context *ev, >+ struct messaging_context *msg, >+ const struct auth_session_info *session_info, >+ int snum, >+ const char *path, >+ struct connection_struct **c); > struct conn_struct_tos { > struct connection_struct *conn; > struct smb_filename *oldcwd_fname; >-- >2.31.1 > > >From 249c73ae64f1efc001aacdce3238461fd793ab63 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Mon, 10 May 2021 12:10:08 +0200 >Subject: [PATCH 7/9] mdssvc: maintain a connection struct in the mds_ctx > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=14740 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit 8b681cfb5d9b1ece03f7e7b9d3a08ae6c461d679) >--- > source3/rpc_server/mdssvc/mdssvc.c | 30 ++++++++++++++++++++++++++++++ > source3/rpc_server/mdssvc/mdssvc.h | 1 + > 2 files changed, 31 insertions(+) > >diff --git a/source3/rpc_server/mdssvc/mdssvc.c b/source3/rpc_server/mdssvc/mdssvc.c >index a568ed35125..5b864eeb8f1 100644 >--- a/source3/rpc_server/mdssvc/mdssvc.c >+++ b/source3/rpc_server/mdssvc/mdssvc.c >@@ -19,6 +19,7 @@ > */ > > #include "includes.h" >+#include "smbd/proto.h" > #include "librpc/gen_ndr/auth.h" > #include "dbwrap/dbwrap.h" > #include "lib/util/dlinklist.h" >@@ -1531,10 +1532,15 @@ struct mds_ctx *mds_init_ctx(TALLOC_CTX *mem_ctx, > const char *sharename, > const char *path) > { >+ const struct loadparm_substitution *lp_sub = >+ loadparm_s3_global_substitution(); >+ struct smb_filename conn_basedir; > struct mds_ctx *mds_ctx; > int backend; >+ int ret; > bool ok; > smb_iconv_t iconv_hnd = (smb_iconv_t)-1; >+ NTSTATUS status; > > mds_ctx = talloc_zero(mem_ctx, struct mds_ctx); > if (mds_ctx == NULL) { >@@ -1616,6 +1622,30 @@ struct mds_ctx *mds_init_ctx(TALLOC_CTX *mem_ctx, > goto error; > } > >+ status = create_conn_struct_cwd(mds_ctx, >+ ev, >+ msg_ctx, >+ session_info, >+ snum, >+ lp_path(talloc_tos(), lp_sub, snum), >+ &mds_ctx->conn); >+ if (!NT_STATUS_IS_OK(status)) { >+ DBG_ERR("failed to create conn for vfs: %s\n", >+ nt_errstr(status)); >+ goto error; >+ } >+ >+ conn_basedir = (struct smb_filename) { >+ .base_name = mds_ctx->conn->connectpath, >+ }; >+ >+ 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)); >+ goto error; >+ } >+ > ok = mds_ctx->backend->connect(mds_ctx); > if (!ok) { > DBG_ERR("backend connect failed\n"); >diff --git a/source3/rpc_server/mdssvc/mdssvc.h b/source3/rpc_server/mdssvc/mdssvc.h >index d37f6846711..392482767dd 100644 >--- a/source3/rpc_server/mdssvc/mdssvc.h >+++ b/source3/rpc_server/mdssvc/mdssvc.h >@@ -126,6 +126,7 @@ struct mds_ctx { > int snum; > const char *sharename; > const char *spath; >+ 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 */ > }; >-- >2.31.1 > > >From bd7e6295bc465d096cefee2a5cecaa841a99ae87 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Tue, 15 Jun 2021 14:14:52 +0200 >Subject: [PATCH 8/9] mdssvc: chdir() to the conn of the RPC request > >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> >(cherry picked from commit 6de3a88494b5932d0fd10f5c8c8ec57916aeefc5) >--- > source3/rpc_server/mdssvc/mdssvc.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > >diff --git a/source3/rpc_server/mdssvc/mdssvc.c b/source3/rpc_server/mdssvc/mdssvc.c >index 5b864eeb8f1..84c60c17961 100644 >--- a/source3/rpc_server/mdssvc/mdssvc.c >+++ b/source3/rpc_server/mdssvc/mdssvc.c >@@ -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)); >-- >2.31.1 > > >From e5575efc18ad5d5c5438345ebe3966ca5fe7ffcb Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Mon, 10 May 2021 12:34:32 +0200 >Subject: [PATCH 9/9] mdssvc: avoid direct filesystem access, use the VFS >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This ensures mdssvc uses the same FileIDs as the fileserver as well as Spotlight >can be used working on a virtual filesystem like GlusterFS. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=14740 >RN: Spotlight RPC service doesn't work with vfs_glusterfs > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> > >Autobuild-User(master): Ralph Böhme <slow@samba.org> >Autobuild-Date(master): Wed Jun 16 05:59:13 UTC 2021 on sn-devel-184 > >(backported from commit 620b99144359f45aa69c13731db8d793cfbba197) >[slow@samba.org: smbd_check_access_rights_fsp() doesn't take dirfsp arg] >--- > source3/rpc_server/mdssvc/mdssvc.c | 73 ++++++++++++++++++++++++++---- > 1 file changed, 64 insertions(+), 9 deletions(-) > >diff --git a/source3/rpc_server/mdssvc/mdssvc.c b/source3/rpc_server/mdssvc/mdssvc.c >index 84c60c17961..715de272d32 100644 >--- a/source3/rpc_server/mdssvc/mdssvc.c >+++ b/source3/rpc_server/mdssvc/mdssvc.c >@@ -27,6 +27,7 @@ > #include "lib/util/time_basic.h" > #include "lib/dbwrap/dbwrap_rbt.h" > #include "libcli/security/dom_sid.h" >+#include "libcli/security/security.h" > #include "mdssvc.h" > #include "mdssvc_noindex.h" > #ifdef HAVE_SPOTLIGHT_BACKEND_TRACKER >@@ -514,9 +515,12 @@ static bool inode_map_add(struct sl_query *slq, uint64_t ino, const char *path) > > bool mds_add_result(struct sl_query *slq, const char *path) > { >+ struct smb_filename *smb_fname = NULL; > struct stat_ex sb; >+ uint32_t attr; > uint64_t ino64; > int result; >+ NTSTATUS status; > bool ok; > > /* >@@ -540,20 +544,50 @@ bool mds_add_result(struct sl_query *slq, const char *path) > * any function exit below must ensure we switch back > */ > >- result = sys_stat(path, &sb, false); >- if (result != 0) { >+ status = synthetic_pathref(talloc_tos(), >+ slq->mds_ctx->conn->cwd_fsp, >+ path, >+ NULL, >+ NULL, >+ 0, >+ 0, >+ &smb_fname); >+ if (!NT_STATUS_IS_OK(status)) { >+ DBG_DEBUG("synthetic_pathref [%s]: %s\n", >+ smb_fname_str_dbg(smb_fname), >+ nt_errstr(status)); > unbecome_authenticated_pipe_user(); > return true; > } >- result = access(path, R_OK); >- if (result != 0) { >+ >+ status = smbd_check_access_rights_fsp(smb_fname->fsp, >+ false, >+ FILE_READ_DATA); >+ if (!NT_STATUS_IS_OK(status)) { > unbecome_authenticated_pipe_user(); >+ TALLOC_FREE(smb_fname); > return true; > } > >+ /* This is needed to fetch the itime from the DOS attribute blob */ >+ status = SMB_VFS_FGET_DOS_ATTRIBUTES(slq->mds_ctx->conn, >+ smb_fname->fsp, >+ &attr); >+ if (!NT_STATUS_IS_OK(status)) { >+ /* Ignore the error, likely no DOS attr xattr */ >+ DBG_DEBUG("SMB_VFS_FGET_DOS_ATTRIBUTES [%s]: %s\n", >+ smb_fname_str_dbg(smb_fname), >+ nt_errstr(status)); >+ } >+ > unbecome_authenticated_pipe_user(); > >- ino64 = sb.st_ex_ino; >+ smb_fname->st = smb_fname->fsp->fsp_name->st; >+ sb = smb_fname->st; >+ /* Done with smb_fname now. */ >+ TALLOC_FREE(smb_fname); >+ ino64 = SMB_VFS_FS_FILE_ID(slq->mds_ctx->conn, &sb); >+ > if (slq->cnids) { > bool found; > >@@ -1234,7 +1268,7 @@ static bool slrpc_fetch_attributes(struct mds_ctx *mds_ctx, > sl_array_t *fm_array; > sl_nil_t nil; > char *path = NULL; >- struct stat_ex sb = {0}; >+ struct smb_filename *smb_fname = NULL; > struct stat_ex *sp = NULL; > struct sl_inode_path_map *elem = NULL; > void *p; >@@ -1303,11 +1337,29 @@ static bool slrpc_fetch_attributes(struct mds_ctx *mds_ctx, > elem = talloc_get_type_abort(p, struct sl_inode_path_map); > path = elem->path; > >- result = sys_stat(path, &sb, false); >+ status = synthetic_pathref(talloc_tos(), >+ mds_ctx->conn->cwd_fsp, >+ path, >+ NULL, >+ NULL, >+ 0, >+ 0, >+ &smb_fname); >+ if (!NT_STATUS_IS_OK(status)) { >+ /* This is not an error, the user may lack permissions */ >+ DBG_DEBUG("synthetic_pathref [%s]: %s\n", >+ smb_fname_str_dbg(smb_fname), >+ nt_errstr(status)); >+ return true; >+ } >+ >+ result = SMB_VFS_FSTAT(smb_fname->fsp, &smb_fname->st); > if (result != 0) { >- goto error; >+ TALLOC_FREE(smb_fname); >+ return true; > } >- sp = &sb; >+ >+ sp = &smb_fname->st; > } > > ok = add_filemeta(mds_ctx, reqinfo, fm_array, path, sp); >@@ -1337,9 +1389,12 @@ static bool slrpc_fetch_attributes(struct mds_ctx *mds_ctx, > goto error; > } > >+ TALLOC_FREE(smb_fname); > return true; > > error: >+ >+ TALLOC_FREE(smb_fname); > sl_result = UINT64_MAX; > result = dalloc_add_copy(array, &sl_result, uint64_t); > if (result != 0) { >-- >2.31.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
jra
:
review+
Actions:
View
Attachments on
bug 14740
:
16657
|
16658
| 16659 |
16660