* This ends up being called for every tcon, because the client does a
* RPC bind for every tcon, so this is acually a per tcon context.
**/
-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,
- const char *path)
+NTSTATUS 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,
+ const char *path,
+ struct mds_ctx **_mds_ctx)
{
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
mds_ctx = talloc_zero(mem_ctx, struct mds_ctx);
if (mds_ctx == NULL) {
- return NULL;
+ return NT_STATUS_NO_MEMORY;
}
talloc_set_destructor(mds_ctx, mds_ctx_destructor_cb);
mds_ctx->mdssvc_ctx = mdssvc_init(ev);
if (mds_ctx->mdssvc_ctx == NULL) {
- goto error;
+ return NT_STATUS_NO_MEMORY;
}
backend = lp_spotlight_backend(snum);
default:
DBG_ERR("Unknown backend %d\n", backend);
TALLOC_FREE(mdssvc_ctx);
+ status = NT_STATUS_INTERNAL_ERROR;
goto error;
}
"UTF8-NFC",
false);
if (iconv_hnd == (smb_iconv_t)-1) {
+ status = NT_STATUS_INTERNAL_ERROR;
goto error;
}
mds_ctx->ic_nfc_to_nfd = iconv_hnd;
"UTF8-NFD",
false);
if (iconv_hnd == (smb_iconv_t)-1) {
+ status = NT_STATUS_INTERNAL_ERROR;
goto error;
}
mds_ctx->ic_nfd_to_nfc = iconv_hnd;
mds_ctx->sharename = talloc_strdup(mds_ctx, sharename);
if (mds_ctx->sharename == NULL) {
+ status = NT_STATUS_NO_MEMORY;
goto error;
}
mds_ctx->spath = talloc_strdup(mds_ctx, path);
if (mds_ctx->spath == NULL) {
+ status = NT_STATUS_NO_MEMORY;
goto error;
}
mds_ctx->pipe_session_info = session_info;
if (session_info->security_token->num_sids < 1) {
+ status = NT_STATUS_BAD_LOGON_SESSION_STATE;
goto error;
}
sid_copy(&mds_ctx->sid, &session_info->security_token->sids[0]);
mds_ctx->ino_path_map = db_open_rbt(mds_ctx);
if (mds_ctx->ino_path_map == NULL) {
DEBUG(1,("open inode map db failed\n"));
+ status = NT_STATUS_INTERNAL_ERROR;
goto error;
}
if (ret != 0) {
DBG_ERR("vfs_ChDir [%s] failed: %s\n",
conn_basedir.base_name, strerror(errno));
+ status = map_nt_error_from_unix(errno);
goto error;
}
ok = mds_ctx->backend->connect(mds_ctx);
if (!ok) {
DBG_ERR("backend connect failed\n");
+ status = NT_STATUS_CONNECTION_RESET;
goto error;
}
- return mds_ctx;
+ *_mds_ctx = mds_ctx;
+ return NT_STATUS_OK;
error:
if (mds_ctx->ic_nfc_to_nfd != NULL) {
}
TALLOC_FREE(mds_ctx);
- return NULL;
+ return status;
}
/**
*/
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,
- const char *path);
+NTSTATUS 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,
+ const char *path,
+ struct mds_ctx **_mds_ctx);
extern bool mds_dispatch(struct mds_ctx *query_ctx,
struct mdssvc_blob *request_blob,
struct mdssvc_blob *response_blob);
struct auth_session_info *session_info =
dcesrv_call_session_info(dce_call);
struct mds_ctx *mds_ctx;
+ NTSTATUS status;
ZERO_STRUCTP(handle);
- mds_ctx = mds_init_ctx(mem_ctx,
- messaging_tevent_context(p->msg_ctx),
- p->msg_ctx,
- session_info,
- snum,
- sharename,
- path);
- if (mds_ctx == NULL) {
- DEBUG(1, ("error in mds_init_ctx for: %s\n", path));
- return NT_STATUS_UNSUCCESSFUL;
+ status = mds_init_ctx(mem_ctx,
+ messaging_tevent_context(p->msg_ctx),
+ p->msg_ctx,
+ session_info,
+ snum,
+ sharename,
+ path,
+ &mds_ctx);
+ if (!NT_STATUS_IS_OK(status)) {
+ DBG_WARNING("mds_init_ctx() path [%s] failed: %s\n",
+ path, nt_errstr(status));
+ return status;
}
if (!create_policy_hnd(p, handle, 0, mds_ctx)) {