summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalph Boehme <slow@samba.org>2019-04-17 11:00:52 +0200
committerJeremy Allison <jra@samba.org>2019-08-08 20:24:32 +0000
commitc742ab7a4c78db4101499d15ada1a6635d5cc35b (patch)
tree92bc369b1a0a1970abb2daccee2ea1a0973be444
parente5a4114bb563b1ebf8ce7cad2a335bf24dbbdd32 (diff)
downloadsamba-c742ab7a4c78db4101499d15ada1a6635d5cc35b.tar.gz
s3:mdssvc: add noindex backend
Add a new default backend that, while allowing mdsvc RPC and search queries from clients, always returns no results. Shares using this backend will behave the same way as shares on a macOS SMB server where indexing is disabled. This change will later also allow us to compile the Spotlight RPC service by default which is a big step in the direction of adding tests to CI. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
-rw-r--r--docs-xml/smbdotconf/misc/spotlight_backend.xml9
-rw-r--r--lib/param/loadparm.c2
-rw-r--r--lib/param/loadparm.h1
-rw-r--r--lib/param/param_table.c1
-rw-r--r--source3/param/loadparm.c2
-rw-r--r--source3/rpc_server/mdssvc/mdssvc.c15
-rw-r--r--source3/rpc_server/mdssvc/mdssvc_noindex.c57
-rw-r--r--source3/rpc_server/mdssvc/mdssvc_noindex.h26
-rw-r--r--source3/rpc_server/wscript_build1
-rw-r--r--source3/wscript12
10 files changed, 116 insertions, 10 deletions
diff --git a/docs-xml/smbdotconf/misc/spotlight_backend.xml b/docs-xml/smbdotconf/misc/spotlight_backend.xml
index 3175d543f5e..6d224b81e5f 100644
--- a/docs-xml/smbdotconf/misc/spotlight_backend.xml
+++ b/docs-xml/smbdotconf/misc/spotlight_backend.xml
@@ -8,6 +8,13 @@
Spotlight search backend. Available backends:
<itemizedlist>
+ <listitem><para><constant>noindex</constant> -
+ a backend that returns no results.
+ </para></listitem>
+
+ </itemizedlist>
+
+ <itemizedlist>
<listitem><para><constant>tracker</constant> -
Gnome Tracker.
</para></listitem>
@@ -15,5 +22,5 @@
</itemizedlist>
</para>
</description>
-<value type="default">tracker</value>
+<value type="default">noindex</value>
</samba:parameter>
diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c
index 78510a338b9..13e8b677e30 100644
--- a/lib/param/loadparm.c
+++ b/lib/param/loadparm.c
@@ -3025,7 +3025,7 @@ struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx)
lpcfg_do_global_parameter(lp_ctx, "debug encryption", "no");
- lpcfg_do_global_parameter(lp_ctx, "spotlight backend", "tracker");
+ lpcfg_do_global_parameter(lp_ctx, "spotlight backend", "noindex");
for (i = 0; parm_table[i].label; i++) {
if (!(lp_ctx->flags[i] & FLAG_CMDLINE)) {
diff --git a/lib/param/loadparm.h b/lib/param/loadparm.h
index b57290da230..5c5b1cd7cd4 100644
--- a/lib/param/loadparm.h
+++ b/lib/param/loadparm.h
@@ -250,6 +250,7 @@ enum mangled_names_options {MANGLED_NAMES_NO, MANGLED_NAMES_YES, MANGLED_NAMES_I
/* Spotlight backend options */
enum spotlight_backend_options {
+ SPOTLIGHT_BACKEND_NOINDEX,
SPOTLIGHT_BACKEND_TRACKER,
};
diff --git a/lib/param/param_table.c b/lib/param/param_table.c
index 8b1d1e31f60..82dc5cd6cda 100644
--- a/lib/param/param_table.c
+++ b/lib/param/param_table.c
@@ -352,6 +352,7 @@ static const struct enum_list enum_ntlm_auth[] = {
};
static const struct enum_list enum_spotlight_backend[] = {
+ {SPOTLIGHT_BACKEND_NOINDEX, "noindex"},
{SPOTLIGHT_BACKEND_TRACKER, "tracker"},
{-1, NULL}
};
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 31819b3930c..0daac0e44cb 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -247,7 +247,7 @@ static const struct loadparm_service _sDefault =
.param_opt = NULL,
.smbd_search_ask_sharemode = true,
.smbd_getinfo_ask_sharemode = true,
- .spotlight_backend = SPOTLIGHT_BACKEND_TRACKER,
+ .spotlight_backend = SPOTLIGHT_BACKEND_NOINDEX,
.dummy = ""
};
diff --git a/source3/rpc_server/mdssvc/mdssvc.c b/source3/rpc_server/mdssvc/mdssvc.c
index 49c1abbd435..48461eab46f 100644
--- a/source3/rpc_server/mdssvc/mdssvc.c
+++ b/source3/rpc_server/mdssvc/mdssvc.c
@@ -27,6 +27,7 @@
#include "lib/dbwrap/dbwrap_rbt.h"
#include "libcli/security/dom_sid.h"
#include "mdssvc.h"
+#include "mdssvc_noindex.h"
#ifdef HAVE_SPOTLIGHT_BACKEND_TRACKER
#include "mdssvc_tracker.h"
#endif
@@ -1414,6 +1415,13 @@ static struct mdssvc_ctx *mdssvc_init(struct tevent_context *ev)
mdssvc_ctx->ev_ctx = ev;
+ ok = mdsscv_backend_noindex.init(mdssvc_ctx);
+ if (!ok) {
+ DBG_ERR("backend init failed\n");
+ TALLOC_FREE(mdssvc_ctx);
+ return NULL;
+ }
+
#ifdef HAVE_SPOTLIGHT_BACKEND_TRACKER
ok = mdsscv_backend_tracker.init(mdssvc_ctx);
if (!ok) {
@@ -1445,6 +1453,10 @@ bool mds_shutdown(void)
return false;
}
+ ok = mdsscv_backend_noindex.shutdown(mdssvc_ctx);
+ if (!ok) {
+ goto fail;
+ }
#ifdef HAVE_SPOTLIGHT_BACKEND_TRACKER
ok = mdsscv_backend_tracker.shutdown(mdssvc_ctx);
if (!ok) {
@@ -1510,6 +1522,9 @@ struct mds_ctx *mds_init_ctx(TALLOC_CTX *mem_ctx,
backend = lp_spotlight_backend(snum);
switch (backend) {
+ case SPOTLIGHT_BACKEND_NOINDEX:
+ mds_ctx->backend = &mdsscv_backend_noindex;
+ break;
#ifdef HAVE_SPOTLIGHT_BACKEND_TRACKER
case SPOTLIGHT_BACKEND_TRACKER:
mds_ctx->backend = &mdsscv_backend_tracker;
diff --git a/source3/rpc_server/mdssvc/mdssvc_noindex.c b/source3/rpc_server/mdssvc/mdssvc_noindex.c
new file mode 100644
index 00000000000..ff466af61d0
--- /dev/null
+++ b/source3/rpc_server/mdssvc/mdssvc_noindex.c
@@ -0,0 +1,57 @@
+/*
+ Unix SMB/CIFS implementation.
+ Main metadata server / Spotlight routines / noindex backend
+
+ Copyright (C) Ralph Boehme 2019
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+#include "mdssvc.h"
+
+static bool mdssvc_noindex_init(struct mdssvc_ctx *mdssvc_ctx)
+{
+ return true;
+}
+
+static bool mdssvc_noindex_shutdown(struct mdssvc_ctx *mdssvc_ctx)
+{
+ return true;
+}
+
+static bool mds_noindex_connect(struct mds_ctx *mds_ctx)
+{
+ return true;
+}
+
+static bool mds_noindex_search_start(struct sl_query *slq)
+{
+ slq->state = SLQ_STATE_DONE;
+ return true;
+}
+
+static bool mds_noindex_search_cont(struct sl_query *slq)
+{
+ slq->state = SLQ_STATE_DONE;
+ return true;
+}
+
+struct mdssvc_backend mdsscv_backend_noindex = {
+ .init = mdssvc_noindex_init,
+ .shutdown = mdssvc_noindex_shutdown,
+ .connect = mds_noindex_connect,
+ .search_start = mds_noindex_search_start,
+ .search_cont = mds_noindex_search_cont,
+};
diff --git a/source3/rpc_server/mdssvc/mdssvc_noindex.h b/source3/rpc_server/mdssvc/mdssvc_noindex.h
new file mode 100644
index 00000000000..750ee44b226
--- /dev/null
+++ b/source3/rpc_server/mdssvc/mdssvc_noindex.h
@@ -0,0 +1,26 @@
+/*
+ Unix SMB/CIFS implementation.
+ Main metadata server / Spotlight routines / noindex backend
+
+ Copyright (C) Ralph Boehme 2019
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _MDSSVC_NOINDEX_H_
+#define _MDSSVC_NOINDEX_H_
+
+extern struct mdssvc_backend mdsscv_backend_noindex;
+
+#endif /* _MDSSVC_VOID_H_ */
diff --git a/source3/rpc_server/wscript_build b/source3/rpc_server/wscript_build
index 1e6ca43ea16..429c51b55cd 100644
--- a/source3/rpc_server/wscript_build
+++ b/source3/rpc_server/wscript_build
@@ -146,6 +146,7 @@ bld.SAMBA3_SUBSYSTEM('mdssvc',
rpc_mdssvc_sources = '''
mdssvc/mdssvc.c
+ mdssvc/mdssvc_noindex.c
mdssvc/srv_mdssvc_nt.c
../../librpc/gen_ndr/srv_mdssvc.c
'''
diff --git a/source3/wscript b/source3/wscript
index 8386dea8993..59aa4350ef0 100644
--- a/source3/wscript
+++ b/source3/wscript
@@ -1677,7 +1677,7 @@ main() {
conf.env.with_spotlight = False
if Options.options.with_spotlight:
- backends = []
+ backends = ['noindex']
if conf.CONFIG_SET('HAVE_TRACKER') and conf.CONFIG_SET('HAVE_GLIB'):
conf.env.spotlight_backend_tracker = True
backends.append('tracker')
@@ -1692,12 +1692,10 @@ main() {
conf.fatal("Missing support for Unicode normalisation. "
"Try installing icu-dev or libicu-devel.")
- if not conf.env.with_spotlight:
- if not conf.CONFIG_SET('HAVE_TRACKER'):
- Logs.warn('Missing libtracker-sparql development files for Spotlight backend "tracker"')
- if not conf.CONFIG_SET('HAVE_GLIB'):
- Logs.warn('Missing glib-2.0 development files for Spotlight backend "tracker"')
- conf.fatal("Spotlight support requested, but dependencies missing")
+ if not conf.CONFIG_SET('HAVE_TRACKER'):
+ Logs.warn('Missing libtracker-sparql development files for Spotlight backend "tracker"')
+ if not conf.CONFIG_SET('HAVE_GLIB'):
+ Logs.warn('Missing glib-2.0 development files for Spotlight backend "tracker"')
Logs.info("Building with Spotlight support, available backends: %s" % ', '.join(backends))
default_static_modules.extend(TO_LIST('rpc_mdssvc_module'))