1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

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>
This commit is contained in:
Ralph Boehme 2019-04-17 11:00:52 +02:00 committed by Jeremy Allison
parent e5a4114bb5
commit c742ab7a4c
10 changed files with 116 additions and 10 deletions

View File

@ -7,6 +7,13 @@
<para>
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.
@ -15,5 +22,5 @@
</itemizedlist>
</para>
</description>
<value type="default">tracker</value>
<value type="default">noindex</value>
</samba:parameter>

View File

@ -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)) {

View File

@ -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,
};

View File

@ -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}
};

View File

@ -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 = ""
};

View File

@ -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;

View File

@ -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,
};

View File

@ -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_ */

View File

@ -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
'''

View File

@ -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'))