parse_lsa.c

来自「samba-3.0.22.tar.gz 编译smb服务器的源码」· C语言 代码 · 共 2,414 行 · 第 1/5 页

C
2,414
字号
/*******************************************************************reads or writes a structure.********************************************************************/BOOL lsa_io_r_priv_get_dispname(const char *desc, LSA_R_PRIV_GET_DISPNAME *out, prs_struct *ps, int depth){	if (out == NULL)		return False;	prs_debug(ps, depth, desc, "lsa_io_r_priv_get_dispname");	depth++;	if (!prs_align(ps))		return False;	if (!prs_uint32("ptr_info", ps, depth, &out->ptr_info))		return False;	if (out->ptr_info){		if (!smb_io_unihdr("hdr_name", &out->hdr_desc, ps, depth))			return False;		if (!smb_io_unistr2("desc", &out->desc, out->hdr_desc.buffer, ps, depth))			return False;	}/*	if(!prs_align(ps))		return False;*/	if(!prs_uint16("lang_id", ps, depth, &out->lang_id))		return False;	if(!prs_align(ps))		return False;	if(!prs_ntstatus("status", ps, depth, &out->status))		return False;	return True;}/*  initialise a LSA_Q_ENUM_ACCOUNTS structure*/void init_lsa_q_enum_accounts(LSA_Q_ENUM_ACCOUNTS *trn, POLICY_HND *hnd, uint32 enum_context, uint32 pref_max_length){	memcpy(&trn->pol, hnd, sizeof(trn->pol));	trn->enum_context = enum_context;	trn->pref_max_length = pref_max_length;}/*******************************************************************reads or writes a structure.********************************************************************/BOOL lsa_io_q_enum_accounts(const char *desc, LSA_Q_ENUM_ACCOUNTS *in, prs_struct *ps, int depth){	if (in == NULL)		return False;	prs_debug(ps, depth, desc, "lsa_io_q_enum_accounts");	depth++;	if (!smb_io_pol_hnd("", &in->pol, ps, depth))		return False;	if(!prs_uint32("enum_context   ", ps, depth, &in->enum_context))		return False;	if(!prs_uint32("pref_max_length", ps, depth, &in->pref_max_length))		return False;	return True;}/******************************************************************* Inits an LSA_R_ENUM_PRIVS structure.********************************************************************/void init_lsa_r_enum_accounts(LSA_R_ENUM_ACCOUNTS *out, uint32 enum_context){	DEBUG(5, ("init_lsa_r_enum_accounts\n"));	out->enum_context=enum_context;	if (out->enum_context!=0) {		out->sids.num_entries=enum_context;		out->sids.ptr_sid_enum=1;		out->sids.num_entries2=enum_context;	} else {		out->sids.num_entries=0;		out->sids.ptr_sid_enum=0;		out->sids.num_entries2=0;	}}/*******************************************************************reads or writes a structure.********************************************************************/BOOL lsa_io_r_enum_accounts(const char *desc, LSA_R_ENUM_ACCOUNTS *out, prs_struct *ps, int depth){	if (out == NULL)		return False;	prs_debug(ps, depth, desc, "lsa_io_r_enum_accounts");	depth++;	if (!prs_align(ps))		return False;	if(!prs_uint32("enum_context", ps, depth, &out->enum_context))		return False;	if (!lsa_io_sid_enum("sids", &out->sids, ps, depth))		return False;	if (!prs_align(ps))		return False;	if(!prs_ntstatus("status", ps, depth, &out->status))		return False;	return True;}/******************************************************************* Reads or writes an LSA_Q_UNK_GET_CONNUSER structure.********************************************************************/BOOL lsa_io_q_unk_get_connuser(const char *desc, LSA_Q_UNK_GET_CONNUSER *in, prs_struct *ps, int depth){	prs_debug(ps, depth, desc, "lsa_io_q_unk_get_connuser");	depth++;	if(!prs_align(ps))		return False;   	if(!prs_uint32("ptr_srvname", ps, depth, &in->ptr_srvname))		return False;	if(!smb_io_unistr2("uni2_srvname", &in->uni2_srvname, in->ptr_srvname, ps, depth)) /* server name to be looked up */		return False;	if (!prs_align(ps))	  return False;	if(!prs_uint32("unk1", ps, depth, &in->unk1))		return False;	if(!prs_uint32("unk2", ps, depth, &in->unk2))		return False;	if(!prs_uint32("unk3", ps, depth, &in->unk3))		return False;	/* Don't bother to read or write at present... */	return True;}/******************************************************************* Reads or writes an LSA_R_UNK_GET_CONNUSER structure.********************************************************************/BOOL lsa_io_r_unk_get_connuser(const char *desc, LSA_R_UNK_GET_CONNUSER *out, prs_struct *ps, int depth){	prs_debug(ps, depth, desc, "lsa_io_r_unk_get_connuser");	depth++;	if(!prs_align(ps))		return False;   	if(!prs_uint32("ptr_user_name", ps, depth, &out->ptr_user_name))		return False;	if(!smb_io_unihdr("hdr_user_name", &out->hdr_user_name, ps, depth))		return False;	if(!smb_io_unistr2("uni2_user_name", &out->uni2_user_name, out->ptr_user_name, ps, depth))		return False;	if (!prs_align(ps))	  return False;		if(!prs_uint32("unk1", ps, depth, &out->unk1))		return False;	if(!prs_uint32("ptr_dom_name", ps, depth, &out->ptr_dom_name))		return False;	if(!smb_io_unihdr("hdr_dom_name", &out->hdr_dom_name, ps, depth))		return False;	if(!smb_io_unistr2("uni2_dom_name", &out->uni2_dom_name, out->ptr_dom_name, ps, depth))		return False;	if (!prs_align(ps))	  return False;		if(!prs_ntstatus("status", ps, depth, &out->status))		return False;	return True;}void init_lsa_q_create_account(LSA_Q_CREATEACCOUNT *trn, POLICY_HND *hnd, DOM_SID *sid, uint32 desired_access){	memcpy(&trn->pol, hnd, sizeof(trn->pol));	init_dom_sid2(&trn->sid, sid);	trn->access = desired_access;}/******************************************************************* Reads or writes an LSA_Q_CREATEACCOUNT structure.********************************************************************/BOOL lsa_io_q_create_account(const char *desc, LSA_Q_CREATEACCOUNT *out, prs_struct *ps, int depth){	prs_debug(ps, depth, desc, "lsa_io_q_create_account");	depth++;	if(!prs_align(ps))		return False; 	if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))		return False;	if(!smb_io_dom_sid2("sid", &out->sid, ps, depth)) /* domain SID */		return False; 	if(!prs_uint32("access", ps, depth, &out->access))		return False;  	return True;}/******************************************************************* Reads or writes an LSA_R_CREATEACCOUNT structure.********************************************************************/BOOL lsa_io_r_create_account(const char *desc, LSA_R_CREATEACCOUNT  *out, prs_struct *ps, int depth){	prs_debug(ps, depth, desc, "lsa_io_r_open_account");	depth++;	if(!prs_align(ps))		return False; 	if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))		return False;	if(!prs_ntstatus("status", ps, depth, &out->status))		return False;	return True;}void init_lsa_q_open_account(LSA_Q_OPENACCOUNT *trn, POLICY_HND *hnd, DOM_SID *sid, uint32 desired_access){	memcpy(&trn->pol, hnd, sizeof(trn->pol));	init_dom_sid2(&trn->sid, sid);	trn->access = desired_access;}/******************************************************************* Reads or writes an LSA_Q_OPENACCOUNT structure.********************************************************************/BOOL lsa_io_q_open_account(const char *desc, LSA_Q_OPENACCOUNT *out, prs_struct *ps, int depth){	prs_debug(ps, depth, desc, "lsa_io_q_open_account");	depth++;	if(!prs_align(ps))		return False; 	if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))		return False;	if(!smb_io_dom_sid2("sid", &out->sid, ps, depth)) /* domain SID */		return False; 	if(!prs_uint32("access", ps, depth, &out->access))		return False;  	return True;}/******************************************************************* Reads or writes an LSA_R_OPENACCOUNT structure.********************************************************************/BOOL lsa_io_r_open_account(const char *desc, LSA_R_OPENACCOUNT  *out, prs_struct *ps, int depth){	prs_debug(ps, depth, desc, "lsa_io_r_open_account");	depth++;	if(!prs_align(ps))		return False; 	if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))		return False;	if(!prs_ntstatus("status", ps, depth, &out->status))		return False;	return True;}void init_lsa_q_enum_privsaccount(LSA_Q_ENUMPRIVSACCOUNT *trn, POLICY_HND *hnd){	memcpy(&trn->pol, hnd, sizeof(trn->pol));}/******************************************************************* Reads or writes an LSA_Q_ENUMPRIVSACCOUNT structure.********************************************************************/BOOL lsa_io_q_enum_privsaccount(const char *desc, LSA_Q_ENUMPRIVSACCOUNT *out, prs_struct *ps, int depth){	prs_debug(ps, depth, desc, "lsa_io_q_enum_privsaccount");	depth++;	if(!prs_align(ps))		return False; 	if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))		return False;	return True;}/******************************************************************* Reads or writes an LUID structure.********************************************************************/static BOOL lsa_io_luid(const char *desc, LUID *out, prs_struct *ps, int depth){	prs_debug(ps, depth, desc, "lsa_io_luid");	depth++;	if(!prs_align(ps))		return False; 	if(!prs_uint32("low", ps, depth, &out->low))		return False;	if(!prs_uint32("high", ps, depth, &out->high))		return False;	return True;}/******************************************************************* Reads or writes an LUID_ATTR structure.********************************************************************/static BOOL lsa_io_luid_attr(const char *desc, LUID_ATTR *out, prs_struct *ps, int depth){	prs_debug(ps, depth, desc, "lsa_io_luid_attr");	depth++;	if(!prs_align(ps))		return False; 	if (!lsa_io_luid(desc, &out->luid, ps, depth))		return False;	if(!prs_uint32("attr", ps, depth, &out->attr))		return False;	return True;}/******************************************************************* Reads or writes an PRIVILEGE_SET structure.********************************************************************/static BOOL lsa_io_privilege_set(const char *desc, PRIVILEGE_SET *out, prs_struct *ps, int depth){	uint32 i;	prs_debug(ps, depth, desc, "lsa_io_privilege_set");	depth++;	if(!prs_align(ps))		return False; 	if(!prs_uint32("count", ps, depth, &out->count))		return False;	if(!prs_uint32("control", ps, depth, &out->control))		return False;	for (i=0; i<out->count; i++) {		if (!lsa_io_luid_attr(desc, &out->set[i], ps, depth))			return False;	}		return True;}NTSTATUS init_lsa_r_enum_privsaccount(TALLOC_CTX *mem_ctx, LSA_R_ENUMPRIVSACCOUNT *out, LUID_ATTR *set, uint32 count, uint32 control){	NTSTATUS ret = NT_STATUS_OK;	out->ptr = 1;	out->count = count;	if ( !NT_STATUS_IS_OK(ret = privilege_set_init_by_ctx(mem_ctx, &(out->set))) )		return ret;		out->set.count = count;		if (!NT_STATUS_IS_OK(ret = dup_luid_attr(out->set.mem_ctx, &(out->set.set), set, count)))		return ret;	DEBUG(10,("init_lsa_r_enum_privsaccount: %d privileges\n", out->count));	return ret;}/******************************************************************* Reads or writes an LSA_R_ENUMPRIVSACCOUNT structure.********************************************************************/BOOL lsa_io_r_enum_privsaccount(const char *desc, LSA_R_ENUMPRIVSACCOUNT *out, prs_struct *ps, int depth){	prs_debug(ps, depth, desc, "lsa_io_r_enum_privsaccount");	depth++;	if(!prs_align(ps))		return False; 	if(!prs_uint32("ptr", ps, depth, &out->ptr))		return False;	if (out->ptr!=0) {		if(!prs_uint32("count", ps, depth, &out->count))			return False;		/* malloc memory if unmarshalling here */		if (UNMARSHALLING(ps) && out->count != 0) {			if (!NT_STATUS_IS_OK(privilege_set_init_by_ctx(ps->mem_ctx, &(out->set))))				return False;			if (!(out->set.set = PRS_ALLOC_MEM(ps,LUID_ATTR,out->count)))				return False;		}				if(!lsa_io_privilege_set(desc, &out->set, ps, depth))			return False;	}	if(!prs_ntstatus("status", ps, depth, &out->status))		return False;	return True;}/******************************************************************* Reads or writes an  LSA_Q_GETSYSTEMACCOUNTstructure.********************************************************************/BOOL lsa_io_q_getsystemaccount(const char *desc, LSA_Q_GETSYSTEMACCOUNT  *out, prs_struct *ps, int depth){	prs_debug(ps, depth, desc, "lsa_io_q_getsystemaccount");	depth++;	if(!prs_align(ps))		return False; 	if(!smb_io_pol_hnd("pol", &out->pol, ps, depth))		return False;	return True;}/******************************************************************* Reads or writes an  LSA_R_GETSYSTEMACCOUNTstructure.********************************************************************/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?