parse_lsa.c

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

C
2,414
字号
				return False;			}			if ((trn->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, trn->num_entries)) == NULL) {				return False;			}		}		for (i = 0; i < trn->num_entries2; i++) {			fstring t;			slprintf(t, sizeof(t) - 1, "name[%d] ", i);			if(!lsa_io_trans_name(t, &trn->name[i], ps, depth)) /* translated name */				return False;		}		for (i = 0; i < trn->num_entries2; i++) {			fstring t;			slprintf(t, sizeof(t) - 1, "name[%d] ", i);			if(!smb_io_unistr2(t, &trn->uni_name[i], trn->name[i].hdr_name.buffer, ps, depth))				return False;			if(!prs_align(ps))				return False;		}	}	return True;}/******************************************************************* Reads or writes a structure.********************************************************************/BOOL lsa_io_r_lookup_sids(const char *desc, LSA_R_LOOKUP_SIDS *r_s, 			  prs_struct *ps, int depth){	prs_debug(ps, depth, desc, "lsa_io_r_lookup_sids");	depth++;	if(!prs_align(ps))		return False;		if(!prs_uint32("ptr_dom_ref", ps, depth, &r_s->ptr_dom_ref))		return False;	if (r_s->ptr_dom_ref != 0)		if(!lsa_io_dom_r_ref ("dom_ref", r_s->dom_ref, ps, depth)) /* domain reference info */			return False;	if(!lsa_io_trans_names("names  ", r_s->names, ps, depth)) /* translated names */		return False;	if(!prs_align(ps))		return False;	if(!prs_uint32("mapped_count", ps, depth, &r_s->mapped_count))		return False;	if(!prs_ntstatus("status      ", ps, depth, &r_s->status))		return False;	return True;}/*******************************************************************makes a structure.********************************************************************/void init_q_lookup_names(TALLOC_CTX *mem_ctx, LSA_Q_LOOKUP_NAMES *q_l, 			 POLICY_HND *hnd, int num_names, const char **names){	unsigned int i;	DEBUG(5, ("init_q_lookup_names\n"));	ZERO_STRUCTP(q_l);	q_l->pol = *hnd;	q_l->num_entries = num_names;	q_l->num_entries2 = num_names;	q_l->lookup_level = 1;	if ((q_l->uni_name = TALLOC_ZERO_ARRAY(mem_ctx, UNISTR2, num_names)) == NULL) {		DEBUG(3, ("init_q_lookup_names(): out of memory\n"));		return;	}	if ((q_l->hdr_name = TALLOC_ZERO_ARRAY(mem_ctx, UNIHDR, num_names)) == NULL) {		DEBUG(3, ("init_q_lookup_names(): out of memory\n"));		return;	}	for (i = 0; i < num_names; i++) {		init_unistr2(&q_l->uni_name[i], names[i], UNI_FLAGS_NONE);		init_uni_hdr(&q_l->hdr_name[i], &q_l->uni_name[i]);	}}/*******************************************************************reads or writes a structure.********************************************************************/BOOL lsa_io_q_lookup_names(const char *desc, LSA_Q_LOOKUP_NAMES *q_r, 			   prs_struct *ps, int depth){	unsigned int i;	prs_debug(ps, depth, desc, "lsa_io_q_lookup_names");	depth++;	if(!prs_align(ps))		return False;	if(!smb_io_pol_hnd("", &q_r->pol, ps, depth)) /* policy handle */		return False;	if(!prs_align(ps))		return False;	if(!prs_uint32("num_entries    ", ps, depth, &q_r->num_entries))		return False;	if(!prs_uint32("num_entries2   ", ps, depth, &q_r->num_entries2))		return False;	if (UNMARSHALLING(ps)) {		if (q_r->num_entries) {			if ((q_r->hdr_name = PRS_ALLOC_MEM(ps, UNIHDR, q_r->num_entries)) == NULL)				return False;			if ((q_r->uni_name = PRS_ALLOC_MEM(ps, UNISTR2, q_r->num_entries)) == NULL)				return False;		}	}	for (i = 0; i < q_r->num_entries; i++) {		if(!prs_align(ps))			return False;		if(!smb_io_unihdr("hdr_name", &q_r->hdr_name[i], ps, depth)) /* pointer names */			return False;	}	for (i = 0; i < q_r->num_entries; i++) {		if(!prs_align(ps))			return False;		if(!smb_io_unistr2("dom_name", &q_r->uni_name[i], q_r->hdr_name[i].buffer, ps, depth)) /* names to be looked up */			return False;	}	if(!prs_align(ps))		return False;	if(!prs_uint32("num_trans_entries ", ps, depth, &q_r->num_trans_entries))		return False;	if(!prs_uint32("ptr_trans_sids ", ps, depth, &q_r->ptr_trans_sids))		return False;	if(!prs_uint32("lookup_level   ", ps, depth, &q_r->lookup_level))		return False;	if(!prs_uint32("mapped_count   ", ps, depth, &q_r->mapped_count))		return False;	return True;}/*******************************************************************reads or writes a structure.********************************************************************/BOOL lsa_io_r_lookup_names(const char *desc, LSA_R_LOOKUP_NAMES *out, prs_struct *ps, int depth){	unsigned int i;	prs_debug(ps, depth, desc, "lsa_io_r_lookup_names");	depth++;	if(!prs_align(ps))		return False;	if(!prs_uint32("ptr_dom_ref", ps, depth, &out->ptr_dom_ref))		return False;	if (out->ptr_dom_ref != 0)		if(!lsa_io_dom_r_ref("", out->dom_ref, ps, depth))			return False;	if(!prs_uint32("num_entries", ps, depth, &out->num_entries))		return False;	if(!prs_uint32("ptr_entries", ps, depth, &out->ptr_entries))		return False;	if (out->ptr_entries != 0) {		if(!prs_uint32("num_entries2", ps, depth, &out->num_entries2))			return False;		if (out->num_entries2 != out->num_entries) {			/* RPC fault */			return False;		}		if (UNMARSHALLING(ps)) {			if ((out->dom_rid = PRS_ALLOC_MEM(ps, DOM_RID2, out->num_entries2))			    == NULL) {				DEBUG(3, ("lsa_io_r_lookup_names(): out of memory\n"));				return False;			}		}		for (i = 0; i < out->num_entries2; i++)			if(!smb_io_dom_rid2("", &out->dom_rid[i], ps, depth)) /* domain RIDs being looked up */				return False;	}	if(!prs_uint32("mapped_count", ps, depth, &out->mapped_count))		return False;	if(!prs_ntstatus("status      ", ps, depth, &out->status))		return False;	return True;}/******************************************************************* Inits an LSA_Q_CLOSE structure.********************************************************************/void init_lsa_q_close(LSA_Q_CLOSE *in, POLICY_HND *hnd){	DEBUG(5, ("init_lsa_q_close\n"));	memcpy(&in->pol, hnd, sizeof(in->pol));}/******************************************************************* Reads or writes an LSA_Q_CLOSE structure.********************************************************************/BOOL lsa_io_q_close(const char *desc, LSA_Q_CLOSE *in, prs_struct *ps, int depth){	prs_debug(ps, depth, desc, "lsa_io_q_close");	depth++;	if(!smb_io_pol_hnd("", &in->pol, ps, depth))		return False;	return True;}/******************************************************************* Reads or writes an LSA_R_CLOSE structure.********************************************************************/BOOL lsa_io_r_close(const char *desc,  LSA_R_CLOSE *out, prs_struct *ps, int depth){	prs_debug(ps, depth, desc, "lsa_io_r_close");	depth++;	if(!smb_io_pol_hnd("", &out->pol, ps, depth))		return False;	if(!prs_ntstatus("status", ps, depth, &out->status))		return False;	return True;}/******************************************************************* Reads or writes an LSA_Q_OPEN_SECRET structure.********************************************************************/BOOL lsa_io_q_open_secret(const char *desc, LSA_Q_OPEN_SECRET *in, prs_struct *ps, int depth){	prs_debug(ps, depth, desc, "lsa_io_q_open_secret");	depth++;	if(!prs_align(ps))		return False;	if(!smb_io_pol_hnd("", &in->handle, ps, depth))		return False;	if(!prs_unistr4 ("secretname", ps, depth, &in->secretname))		return False;	if(!prs_align(ps))		return False;	if(!prs_uint32("access", ps, depth, &in->access))		return False;	return True;}/******************************************************************* Reads or writes an LSA_R_OPEN_SECRET structure.********************************************************************/BOOL lsa_io_r_open_secret(const char *desc, LSA_R_OPEN_SECRET *out, prs_struct *ps, int depth){	prs_debug(ps, depth, desc, "lsa_io_r_open_secret");	depth++;	if(!prs_align(ps))		return False;   	if(!smb_io_pol_hnd("", &out->handle, ps, depth))		return False;	if(!prs_ntstatus("status", ps, depth, &out->status))		return False;	return True;}/******************************************************************* Inits an LSA_Q_ENUM_PRIVS structure.********************************************************************/void init_q_enum_privs(LSA_Q_ENUM_PRIVS *in, POLICY_HND *hnd, uint32 enum_context, uint32 pref_max_length){	DEBUG(5, ("init_q_enum_privs\n"));	memcpy(&in->pol, hnd, sizeof(in->pol));	in->enum_context = enum_context;	in->pref_max_length = pref_max_length;}/*******************************************************************reads or writes a structure.********************************************************************/BOOL lsa_io_q_enum_privs(const char *desc, LSA_Q_ENUM_PRIVS *in, prs_struct *ps, int depth){	if (in == NULL)		return False;	prs_debug(ps, depth, desc, "lsa_io_q_enum_privs");	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;}/*******************************************************************reads or writes a structure.********************************************************************/static BOOL lsa_io_priv_entries(const char *desc, LSA_PRIV_ENTRY *entries, uint32 count, prs_struct *ps, int depth){	uint32 i;	if (entries == NULL)		return False;	prs_debug(ps, depth, desc, "lsa_io_priv_entries");	depth++;	if(!prs_align(ps))		return False;	for (i = 0; i < count; i++) {		if (!smb_io_unihdr("", &entries[i].hdr_name, ps, depth))			return False;		if(!prs_uint32("luid_low ", ps, depth, &entries[i].luid_low))			return False;		if(!prs_uint32("luid_high", ps, depth, &entries[i].luid_high))			return False;	}	for (i = 0; i < count; i++)		if (!smb_io_unistr2("", &entries[i].name, entries[i].hdr_name.buffer, ps, depth))			return False;	return True;}/******************************************************************* Inits an LSA_R_ENUM_PRIVS structure.********************************************************************/void init_lsa_r_enum_privs(LSA_R_ENUM_PRIVS *out, uint32 enum_context,			  uint32 count, LSA_PRIV_ENTRY *entries){	DEBUG(5, ("init_lsa_r_enum_privs\n"));	out->enum_context=enum_context;	out->count=count;		if (entries!=NULL) {		out->ptr=1;		out->count1=count;		out->privs=entries;	} else {		out->ptr=0;		out->count1=0;		out->privs=NULL;	}		}/*******************************************************************reads or writes a structure.********************************************************************/BOOL lsa_io_r_enum_privs(const char *desc, LSA_R_ENUM_PRIVS *out, prs_struct *ps, int depth){	if (out == NULL)		return False;	prs_debug(ps, depth, desc, "lsa_io_r_enum_privs");	depth++;	if(!prs_align(ps))		return False;	if(!prs_uint32("enum_context", ps, depth, &out->enum_context))		return False;	if(!prs_uint32("count", ps, depth, &out->count))		return False;	if(!prs_uint32("ptr", ps, depth, &out->ptr))		return False;	if (out->ptr) {		if(!prs_uint32("count1", ps, depth, &out->count1))			return False;		if (UNMARSHALLING(ps))			if (!(out->privs = PRS_ALLOC_MEM(ps, LSA_PRIV_ENTRY, out->count1)))				return False;		if (!lsa_io_priv_entries("", out->privs, out->count1, 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_priv_get_dispname(LSA_Q_PRIV_GET_DISPNAME *trn, POLICY_HND *hnd, const char *name, uint16 lang_id, uint16 lang_id_sys){	memcpy(&trn->pol, hnd, sizeof(trn->pol));	init_unistr2(&trn->name, name, UNI_FLAGS_NONE);	init_uni_hdr(&trn->hdr_name, &trn->name);	trn->lang_id = lang_id;	trn->lang_id_sys = lang_id_sys;}/*******************************************************************reads or writes a structure.********************************************************************/BOOL lsa_io_q_priv_get_dispname(const char *desc, LSA_Q_PRIV_GET_DISPNAME *in, prs_struct *ps, int depth){	if (in == NULL)		return False;	prs_debug(ps, depth, desc, "lsa_io_q_priv_get_dispname");	depth++;	if(!prs_align(ps))		return False;	if (!smb_io_pol_hnd("", &in->pol, ps, depth))		return False;	if (!smb_io_unihdr("hdr_name", &in->hdr_name, ps, depth))		return False;	if (!smb_io_unistr2("name", &in->name, in->hdr_name.buffer, ps, depth))		return False;	if(!prs_uint16("lang_id    ", ps, depth, &in->lang_id))		return False;	if(!prs_uint16("lang_id_sys", ps, depth, &in->lang_id_sys))		return False;	return True;}

⌨️ 快捷键说明

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