Пример #1
0
static NTSTATUS open_internal_samr_pipe(TALLOC_CTX *mem_ctx,
					struct rpc_pipe_client **samr_pipe)
{
	struct rpc_pipe_client *cli = NULL;
	struct auth_serversupplied_info *session_info = NULL;
	NTSTATUS status;

	if (session_info == NULL) {
		status = make_session_info_system(mem_ctx, &session_info);
		if (!NT_STATUS_IS_OK(status)) {
			DEBUG(0, ("open_samr_pipe: Could not create auth_serversupplied_info: %s\n",
				  nt_errstr(status)));
			return status;
		}
	}

	/* create a samr connection */
	status = rpc_pipe_open_interface(mem_ctx,
					&ndr_table_samr.syntax_id,
					session_info,
					NULL,
					winbind_messaging_context(),
					&cli);
	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(0, ("open_samr_pipe: Could not connect to samr_pipe: %s\n",
			  nt_errstr(status)));
		return status;
	}

	if (samr_pipe) {
		*samr_pipe = cli;
	}

	return NT_STATUS_OK;
}
Пример #2
0
static enum winbindd_result dual_dsgetdcname(struct winbindd_domain *domain,
					     struct winbindd_cli_state *state)
{
	NTSTATUS result;
	struct netr_DsRGetDCNameInfo *info = NULL;
	uint32_t ds_flags = 0;
	struct GUID guid, *guid_ptr = NULL;
	const char *guid_str = NULL;

	state->request.data.dsgetdcname.domain_name
		[sizeof(state->request.data.dsgetdcname.domain_name)-1] = '\0';
	state->request.data.dsgetdcname.site_name
		[sizeof(state->request.data.dsgetdcname.site_name)-1] = '\0';
	state->request.data.dsgetdcname.domain_guid
		[sizeof(state->request.data.dsgetdcname.domain_guid)-1] = '\0';

	DEBUG(3, ("[%5lu]: dsgetdcname for %s\n", (unsigned long)state->pid,
		  state->request.data.dsgetdcname.domain_name));

	ds_flags = get_dsgetdc_flags(state->request.flags);

	result = GUID_from_string(state->request.data.dsgetdcname.domain_guid,
				  &guid);
	if (NT_STATUS_IS_OK(result) && !GUID_all_zero(&guid)) {
		guid_ptr = &guid;
	}

	result = dsgetdcname(state->mem_ctx,
			     winbind_messaging_context(),
			     state->request.data.dsgetdcname.domain_name,
			     guid_ptr,
			     state->request.data.dsgetdcname.site_name,
			     ds_flags,
			     &info);

	if (!NT_STATUS_IS_OK(result)) {
		return WINBINDD_ERROR;
	}

	guid_str = GUID_string(state->mem_ctx, &info->domain_guid);
	if (!guid_str) {
		return WINBINDD_ERROR;
	}

	fstrcpy(state->response.data.dsgetdcname.dc_unc, info->dc_unc);
	fstrcpy(state->response.data.dsgetdcname.dc_address, info->dc_address);
	state->response.data.dsgetdcname.dc_address_type = info->dc_address_type;
	fstrcpy(state->response.data.dsgetdcname.domain_guid, guid_str);
	fstrcpy(state->response.data.dsgetdcname.domain_name, info->domain_name);
	fstrcpy(state->response.data.dsgetdcname.forest_name, info->forest_name);
	state->response.data.dsgetdcname.dc_flags = info->dc_flags;
	fstrcpy(state->response.data.dsgetdcname.dc_site_name, info->dc_site_name);
	fstrcpy(state->response.data.dsgetdcname.client_site_name, info->client_site_name);

	return WINBINDD_OK;
}
Пример #3
0
static void terminate(bool is_parent)
{
	if (is_parent) {
		/* When parent goes away we should
		 * remove the socket file. Not so
		 * when children terminate.
		 */ 
		char *path = NULL;

		if (asprintf(&path, "%s/%s",
			get_winbind_pipe_dir(), WINBINDD_SOCKET_NAME) > 0) {
			unlink(path);
			SAFE_FREE(path);
		}
	}

	idmap_close();

	trustdom_cache_shutdown();

	gencache_stabilize();

#if 0
	if (interactive) {
		TALLOC_CTX *mem_ctx = talloc_init("end_description");
		char *description = talloc_describe_all(mem_ctx);

		DEBUG(3, ("tallocs left:\n%s\n", description));
		talloc_destroy(mem_ctx);
	}
#endif

	if (is_parent) {
		struct messaging_context *msg = winbind_messaging_context();
		struct server_id self = messaging_server_id(msg);
		serverid_deregister(self);
		pidfile_unlink(lp_piddir(), "winbindd");
	}

	exit(0);
}