Blame src/client/toks_client_connect.c

486fcd
/*********************************************************/
486fcd
/*  toksvc: a framework-native token broker service      */
486fcd
/*  Copyright (C) 2020  Z. Gilboa                        */
486fcd
/*  Released under GPLv2 and GPLv3; see COPYING.TOKSVC.  */
486fcd
/*********************************************************/
486fcd
486fcd
#include <psxtypes/psxtypes.h>
486fcd
#include <ntapi/ntapi.h>
486fcd
486fcd
#include <toksvc/toksvc.h>
486fcd
#include "toksvc_driver_impl.h"
486fcd
486fcd
int32_t toks_client_connect(struct toks_driver_ctx * dctx)
486fcd
{
486fcd
	int32_t			status;
486fcd
	void *			hsvclink;
486fcd
	void *			hservice;
486fcd
	nt_unicode_string	name;
486fcd
	nt_guid_str_utf16	guid;
486fcd
	nt_oa			oa;
486fcd
	nt_sqos			sqos = {
486fcd
					sizeof(sqos),
486fcd
					NT_SECURITY_ANONYMOUS,
486fcd
					NT_SECURITY_TRACKING_STATIC,
486fcd
					1};
486fcd
486fcd
	ntapi->tt_guid_to_string_utf16(
486fcd
		toks_get_driver_uuid(dctx),
486fcd
		&guid);
486fcd
486fcd
	name.strlen = sizeof(guid);
486fcd
	name.maxlen = 0;
486fcd
	name.buffer = &guid.lbrace;
486fcd
486fcd
	oa.len		= sizeof(oa);
486fcd
	oa.root_dir	= toks_get_driver_hsvcdir(dctx);
486fcd
	oa.obj_name	= &nam;;
486fcd
	oa.obj_attr	= NT_OBJ_INHERIT;
486fcd
	oa.sec_desc	= 0;
486fcd
	oa.sec_qos	= &sqo;;
486fcd
486fcd
	if ((status = ntapi->zw_open_symbolic_link_object(
486fcd
			&hsvclink,
486fcd
			NT_SYMBOLIC_LINK_QUERY,
486fcd
			&oa)))
486fcd
		return status;
486fcd
486fcd
	toks_set_driver_hsvclink(
486fcd
		dctx,hsvclink);
486fcd
486fcd
	if ((ntapi->ipc_connect_by_symlink(&hservice,hsvclink)))
486fcd
		return status;
486fcd
486fcd
	toks_set_driver_hservice(
486fcd
		dctx,hservice);
486fcd
486fcd
	return NT_STATUS_SUCCESS;
486fcd
}