1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

s3:mdssvc: new option "spotlight backend"

Currently there's only the tracker backend, but subsequent commits will add
other backends.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Ralph Boehme 2019-05-06 15:03:02 +02:00 committed by Jeremy Allison
parent 66b8d86d71
commit 1b897df4f7
10 changed files with 84 additions and 22 deletions

View File

@ -0,0 +1,19 @@
<samba:parameter name="spotlight backend"
context="S"
type="enum"
enumlist="enum_spotlight_backend"
xmlns:samba="http://www.samba.org/samba/DTD/samba-doc">
<description>
<para>
Spotlight search backend. Available backends:
<itemizedlist>
<listitem><para><constant>tracker</constant> -
Gnome Tracker.
</para></listitem>
</itemizedlist>
</para>
</description>
<value type="default">tracker</value>
</samba:parameter>

View File

@ -3025,6 +3025,8 @@ 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");
for (i = 0; parm_table[i].label; i++) {
if (!(lp_ctx->flags[i] & FLAG_CMDLINE)) {
lp_ctx->flags[i] |= FLAG_DEFAULT;

View File

@ -248,6 +248,11 @@ enum inheritowner_options {
/* mangled names options */
enum mangled_names_options {MANGLED_NAMES_NO, MANGLED_NAMES_YES, MANGLED_NAMES_ILLEGAL};
/* Spotlight backend options */
enum spotlight_backend_options {
SPOTLIGHT_BACKEND_TRACKER,
};
/*
* Default passwd chat script.
*/

View File

@ -351,6 +351,11 @@ static const struct enum_list enum_ntlm_auth[] = {
{-1, NULL}
};
static const struct enum_list enum_spotlight_backend[] = {
{SPOTLIGHT_BACKEND_TRACKER, "tracker"},
{-1, NULL}
};
/* Note: We do not initialise the defaults union - it is not allowed in ANSI C
*
* NOTE: Handling of duplicated (synonym) parameters:

View File

@ -247,6 +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,
.dummy = ""
};

View File

@ -27,7 +27,9 @@
#include "lib/dbwrap/dbwrap_rbt.h"
#include "libcli/security/dom_sid.h"
#include "mdssvc.h"
#ifdef HAVE_SPOTLIGHT_BACKEND_TRACKER
#include "mdssvc_tracker.h"
#endif
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_RPC_SRV
@ -1046,7 +1048,7 @@ static bool slrpc_open_query(struct mds_ctx *mds_ctx,
DLIST_ADD(mds_ctx->query_list, slq);
ok = mds_ctx->mdssvc_ctx->backend->search_start(slq);
ok = mds_ctx->backend->search_start(slq);
if (!ok) {
DBG_ERR("backend search_start failed\n");
goto error;
@ -1142,7 +1144,7 @@ static bool slrpc_fetch_query_results(struct mds_ctx *mds_ctx,
}
if (slq->state == SLQ_STATE_FULL) {
slq->state = SLQ_STATE_RESULTS;
slq->mds_ctx->mdssvc_ctx->backend->search_cont(slq);
slq->mds_ctx->backend->search_cont(slq);
}
break;
@ -1534,14 +1536,14 @@ static struct mdssvc_ctx *mdssvc_init(struct tevent_context *ev)
mdssvc_ctx->ev_ctx = ev;
mdssvc_ctx->backend = &mdsscv_backend_tracker;
#ifdef HAVE_SPOTLIGHT_BACKEND_TRACKER
ok = mdsscv_backend_tracker.init(mdssvc_ctx);
if (!ok) {
DBG_ERR("backend init failed\n");
TALLOC_FREE(mdssvc_ctx);
return NULL;
}
#endif
return mdssvc_ctx;
}
@ -1565,10 +1567,12 @@ bool mds_shutdown(void)
return false;
}
#ifdef HAVE_SPOTLIGHT_BACKEND_TRACKER
ok = mdsscv_backend_tracker.shutdown(mdssvc_ctx);
if (!ok) {
goto fail;
}
#endif
ok = true;
fail:
@ -1612,6 +1616,7 @@ struct mds_ctx *mds_init_ctx(TALLOC_CTX *mem_ctx,
const char *path)
{
struct mds_ctx *mds_ctx;
int backend;
bool ok;
mds_ctx = talloc_zero(mem_ctx, struct mds_ctx);
@ -1625,6 +1630,19 @@ struct mds_ctx *mds_init_ctx(TALLOC_CTX *mem_ctx,
goto error;
}
backend = lp_spotlight_backend(snum);
switch (backend) {
#ifdef HAVE_SPOTLIGHT_BACKEND_TRACKER
case SPOTLIGHT_BACKEND_TRACKER:
mds_ctx->backend = &mdsscv_backend_tracker;
break;
#endif
default:
DBG_ERR("Unknown backend %d\n", backend);
TALLOC_FREE(mdssvc_ctx);
return NULL;
}
mds_ctx->sharename = talloc_strdup(mds_ctx, sharename);
if (mds_ctx->sharename == NULL) {
goto error;
@ -1650,7 +1668,7 @@ struct mds_ctx *mds_init_ctx(TALLOC_CTX *mem_ctx,
goto error;
}
ok = mds_ctx->mdssvc_ctx->backend->connect(mds_ctx);
ok = mds_ctx->backend->connect(mds_ctx);
if (!ok) {
DBG_ERR("backend connect failed\n");
goto error;

View File

@ -111,12 +111,12 @@ struct sl_inode_path_map {
/* Per process state */
struct mdssvc_ctx {
struct tevent_context *ev_ctx;
struct mdssvc_backend *backend;
void *backend_private;
};
/* Per tree connect state */
struct mds_ctx {
struct mdssvc_backend *backend;
struct mdssvc_ctx *mdssvc_ctx;
void *backend_private;
struct auth_session_info *pipe_session_info;

View File

@ -142,22 +142,26 @@ rpc_mdssvc_sources = '''
mdssvc/mdssvc.c
mdssvc/dalloc.c
mdssvc/marshalling.c
mdssvc/sparql_mapping.c
mdssvc/sparql_parser.y
mdssvc/sparql_lexer.l
mdssvc/srv_mdssvc_nt.c
../../librpc/gen_ndr/srv_mdssvc.c
'''
rpc_mdssvc_deps = 'samba-util '
if bld.CONFIG_SET('HAVE_TRACKER'):
rpc_mdssvc_sources += ' mdssvc/mdssvc_tracker.c'
if bld.env.spotlight_backend_tracker:
rpc_mdssvc_sources += '''
mdssvc/mdssvc_tracker.c
mdssvc/sparql_mapping.c
mdssvc/sparql_parser.y
mdssvc/sparql_lexer.l
'''
rpc_mdssvc_deps += 'tevent-glib-glue ' + bld.env['libtracker']
bld.SAMBA3_MODULE('rpc_mdssvc_module',
subsystem='rpc',
allow_undefined_symbols=True,
source=rpc_mdssvc_sources,
init_function='',
deps='samba-util tevent-glib-glue ' + bld.env['libtracker'],
deps=rpc_mdssvc_deps,
internal_module=bld.SAMBA3_IS_STATIC_MODULE('rpc_mdssvc_module'),
enabled=bld.SAMBA3_IS_ENABLED_MODULE('rpc_mdssvc_module'))

View File

@ -1677,18 +1677,26 @@ main() {
conf.env.with_spotlight = False
if Options.options.with_spotlight:
if not conf.env['BISON']:
conf.fatal("Spotlight support requested but bison missing")
if not conf.env['FLEX']:
conf.fatal("Spotlight support requested but flex missing")
backends = []
if conf.CONFIG_SET('HAVE_TRACKER') and conf.CONFIG_SET('HAVE_GLIB'):
conf.env.spotlight_backend_tracker = True
backends.append('tracker')
conf.DEFINE('HAVE_SPOTLIGHT_BACKEND_TRACKER', '1')
if not conf.CONFIG_SET('HAVE_TRACKER'):
conf.fatal('Missing Gnome Tracker development files')
if conf.env.spotlight_backend_tracker:
if not conf.env['BISON']:
conf.fatal("Spotlight support requested but bison missing")
if not conf.env['FLEX']:
conf.fatal("Spotlight support requested but flex missing")
if not conf.CONFIG_SET('HAVE_GLIB'):
conf.fatal('Missing glib-2.0 development files')
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")
Logs.info("building with Spotlight support")
Logs.info("Building with Spotlight support, available backends: %s" % ', '.join(backends))
default_static_modules.extend(TO_LIST('rpc_mdssvc_module'))
conf.DEFINE('WITH_SPOTLIGHT', '1')
conf.env.with_spotlight = True

View File

@ -1325,7 +1325,7 @@ bld.SAMBA3_BINARY('spotlight2sparql',
rpc_server/mdssvc/sparql_lexer.l
rpc_server/mdssvc/sparql_mapping.c''',
deps='samba3-util talloc ' + bld.env['libtracker'],
enabled=bld.env.with_spotlight,
enabled=bld.env.spotlight_backend_tracker,
install=False)
bld.SAMBA3_BINARY('tevent_glib_glue_test',