From: Ralph Boehme Date: Wed, 25 May 2022 15:37:22 +0000 (+0200) Subject: mdssvc: return all-zero policy handle if spotlight is disabled X-Git-Tag: tevent-0.13.0~174 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=23e6e50c0f82b997dea4a67069f65252045514c0;p=thirdparty%2Fsamba.git mdssvc: return all-zero policy handle if spotlight is disabled A Mac SMB server returns an all zero handle and an empty path if Spotlight is disabled on a share. We must return the exact same error return in order to trigger client-side searching. Bug: https://bugzilla.samba.org/show_bug.cgi?id=15086 pcap: https://www.samba.org/~slow/pcaps/mac-bigsur-smbserver-spotlight-disabled.pcapng.gz Signed-off-by: Ralph Boehme Reviewed-by: Noel Power Autobuild-User(master): Noel Power Autobuild-Date(master): Tue Jul 12 15:42:52 UTC 2022 on sn-devel-184 --- diff --git a/selftest/knownfail.d/samba3.rpc.mdssvc b/selftest/knownfail.d/samba3.rpc.mdssvc deleted file mode 100644 index 7a6ed0fe346..00000000000 --- a/selftest/knownfail.d/samba3.rpc.mdssvc +++ /dev/null @@ -1 +0,0 @@ -^samba3.rpc.mdssvc.rpccmd.open_spotlight_disabled\(fileserver\) diff --git a/source3/rpc_server/mdssvc/mdssvc.c b/source3/rpc_server/mdssvc/mdssvc.c index fafbd5e7841..01713722126 100644 --- a/source3/rpc_server/mdssvc/mdssvc.c +++ b/source3/rpc_server/mdssvc/mdssvc.c @@ -1591,6 +1591,10 @@ NTSTATUS mds_init_ctx(TALLOC_CTX *mem_ctx, smb_iconv_t iconv_hnd = (smb_iconv_t)-1; NTSTATUS status; + if (!lp_spotlight(snum)) { + return NT_STATUS_WRONG_VOLUME; + } + mds_ctx = talloc_zero(mem_ctx, struct mds_ctx); if (mds_ctx == NULL) { return NT_STATUS_NO_MEMORY; @@ -1603,9 +1607,6 @@ NTSTATUS mds_init_ctx(TALLOC_CTX *mem_ctx, } backend = lp_spotlight_backend(snum); - if (!lp_spotlight(snum)) { - backend = SPOTLIGHT_BACKEND_NOINDEX; - } switch (backend) { case SPOTLIGHT_BACKEND_NOINDEX: mds_ctx->backend = &mdsscv_backend_noindex; diff --git a/source3/rpc_server/mdssvc/srv_mdssvc_nt.c b/source3/rpc_server/mdssvc/srv_mdssvc_nt.c index 2d572a887d0..2fca15cb8a8 100644 --- a/source3/rpc_server/mdssvc/srv_mdssvc_nt.c +++ b/source3/rpc_server/mdssvc/srv_mdssvc_nt.c @@ -61,8 +61,8 @@ static NTSTATUS create_mdssvc_policy_handle(TALLOC_CTX *mem_ctx, path, &mds_ctx); if (!NT_STATUS_IS_OK(status)) { - DBG_WARNING("mds_init_ctx() path [%s] failed: %s\n", - path, nt_errstr(status)); + DBG_DEBUG("mds_init_ctx() path [%s] failed: %s\n", + path, nt_errstr(status)); return status; } @@ -109,6 +109,11 @@ void _mdssvc_open(struct pipes_struct *p, struct mdssvc_open *r) r->in.share_name, path, r->out.handle); + if (NT_STATUS_EQUAL(status, NT_STATUS_WRONG_VOLUME)) { + ZERO_STRUCTP(r->out.handle); + talloc_free(path); + return; + } if (!NT_STATUS_IS_OK(status)) { DBG_ERR("Couldn't create policy handle for %s\n", r->in.share_name);