예제 #1
0
파일: libnet.c 프로젝트: DavidMulder/samba
struct libnet_context *libnet_context_init(struct tevent_context *ev,
					   struct loadparm_context *lp_ctx)
{
	struct libnet_context *ctx;

	/* We require an event context here */
	if (!ev) {
		return NULL;
	}

	/* create brand new libnet context */
	ctx = talloc_zero(ev, struct libnet_context);
	if (!ctx) {
		return NULL;
	}

	ctx->event_ctx = ev;
	ctx->lp_ctx = lp_ctx;

	/* make sure dcerpc is initialized */
	dcerpc_init();

	/* name resolution methods */
	ctx->resolve_ctx = lpcfg_resolve_context(lp_ctx);

	/* default buffer size for various operations requiring specifying a buffer */
	ctx->samr.buf_size = 128;

	return ctx;
}
예제 #2
0
int main(int argc, char **argv)
{
	lp_ctx = loadparm_init(NULL);
	lp_load_default(lp_ctx);
	setup_logging(argv[0], DEBUG_STDERR);

	dcerpc_init(lp_ctx);

	ev_ctx = tevent_context_init(lp_ctx);
	gtk_init(&argc, &argv);
	mainwin = create_mainwindow();
	gtk_widget_show_all(mainwin);

	return gtk_event_loop();
}
/**
 * Initialize the Zenoss async event context. Will ensure that all
 * necessary Samba library initializtion takes place and that a root
 * event context for our local implementation is created.
 */
struct event_context* async_create_context(struct reactor_functions *funcs)
{
    // load all Samba parameters
    lp_load();

    // initialize the Samba DCERPC libraries
    dcerpc_init();
    dcerpc_table_init();
    dcom_proxy_IUnknown_init();
    dcom_proxy_IWbemLevel1Login_init();
    dcom_proxy_IWbemServices_init();
    dcom_proxy_IEnumWbemClassObject_init();
    dcom_proxy_IRemUnknown_init();
    dcom_proxy_IWbemFetchSmartEnum_init();
    dcom_proxy_IWbemWCOSmartEnum_init();

    // and finally create our top-level event context
    return zenoss_event_context_init(NULL, funcs);
}
예제 #4
0
파일: rpc.c 프로젝트: DavidMulder/samba
/**
 * open a rpc connection to the chosen binding string
 */
_PUBLIC_ NTSTATUS torture_rpc_connection_with_binding(struct torture_context *tctx,
						      struct dcerpc_binding *binding,
						      struct dcerpc_pipe **p,
						      const struct ndr_interface_table *table)
{
	NTSTATUS status;

	dcerpc_init();

	status = dcerpc_pipe_connect_b(tctx,
				     p, binding, table,
				     popt_get_cmdline_credentials(),
					tctx->ev, tctx->lp_ctx);

	if (NT_STATUS_IS_ERR(status)) {
		torture_warning(tctx, "Failed to connect to remote server: %s %s\n",
			   dcerpc_binding_string(tctx, binding), nt_errstr(status));
	}

	return status;
}
예제 #5
0
파일: rpc.c 프로젝트: 0x24bin/winexe-1
_PUBLIC_ WERROR reg_open_remote(struct registry_context **ctx,
				struct auth_session_info *session_info,
				struct cli_credentials *credentials,
				struct loadparm_context *lp_ctx,
				const char *location, struct tevent_context *ev)
{
	NTSTATUS status;
	struct dcerpc_pipe *p;
	struct rpc_registry_context *rctx;

	dcerpc_init(lp_ctx);

	rctx = talloc(NULL, struct rpc_registry_context);

	/* Default to local smbd if no connection is specified */
	if (!location) {
		location = talloc_strdup(rctx, "ncalrpc:");
	}

	status = dcerpc_pipe_connect(rctx /* TALLOC_CTX */,
				     &p, location,
					 &ndr_table_winreg,
				     credentials, ev, lp_ctx);
	rctx->pipe = p;

	if(NT_STATUS_IS_ERR(status)) {
		DEBUG(1, ("Unable to open '%s': %s\n", location,
			nt_errstr(status)));
		talloc_free(rctx);
		*ctx = NULL;
		return ntstatus_to_werror(status);
	}

	*ctx = (struct registry_context *)rctx;
	(*ctx)->ops = &reg_backend_rpc;

	return WERR_OK;
}