parse_net.c

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

C
2,161
字号
	if(!smb_io_sam_info("", &q_l->sam_id, ps, depth))		return False;	if(!prs_align_uint16(ps))		return False;		if(!prs_uint16("validation_level", ps, depth, &q_l->validation_level))		return False;	return True;}/******************************************************************* Reads or writes a structure.********************************************************************/BOOL net_io_r_sam_logon(const char *desc, NET_R_SAM_LOGON *r_l, prs_struct *ps, int depth){	if (r_l == NULL)		return False;	prs_debug(ps, depth, desc, "net_io_r_sam_logon");	depth++;	if(!prs_uint32("buffer_creds", ps, depth, &r_l->buffer_creds)) /* undocumented buffer pointer */		return False;	if (&r_l->buffer_creds) {		if(!smb_io_cred("", &r_l->srv_creds, ps, depth)) /* server credentials.  server time stamp appears to be ignored. */			return False;	}	if(!prs_uint16("switch_value", ps, depth, &r_l->switch_value))		return False;	if(!prs_align(ps))		return False;#if 1 /* W2k always needs this - even for bad passwd. JRA */	if(!net_io_user_info3("", r_l->user, ps, depth, r_l->switch_value, False))		return False;#else	if (r_l->switch_value != 0) {		if(!net_io_user_info3("", r_l->user, ps, depth, r_l->switch_value, False))			return False;	}#endif	if(!prs_uint32("auth_resp   ", ps, depth, &r_l->auth_resp)) /* 1 - Authoritative response; 0 - Non-Auth? */		return False;	if(!prs_ntstatus("status      ", ps, depth, &r_l->status))		return False;	if(!prs_align(ps))		return False;	return True;}/******************************************************************* Reads or writes a structure.********************************************************************/BOOL net_io_q_sam_logoff(const char *desc,  NET_Q_SAM_LOGOFF *q_l, prs_struct *ps, int depth){	if (q_l == NULL)		return False;	prs_debug(ps, depth, desc, "net_io_q_sam_logoff");	depth++;	if(!prs_align(ps))		return False;		if(!smb_io_sam_info("", &q_l->sam_id, ps, depth))           /* domain SID */		return False;	return True;}/******************************************************************* Reads or writes a structure.********************************************************************/BOOL net_io_r_sam_logoff(const char *desc, NET_R_SAM_LOGOFF *r_l, prs_struct *ps, int depth){	if (r_l == NULL)		return False;	prs_debug(ps, depth, desc, "net_io_r_sam_logoff");	depth++;	if(!prs_align(ps))		return False;		if(!prs_uint32("buffer_creds", ps, depth, &r_l->buffer_creds)) /* undocumented buffer pointer */		return False;	if(!smb_io_cred("", &r_l->srv_creds, ps, depth)) /* server credentials.  server time stamp appears to be ignored. */		return False;	if(!prs_ntstatus("status      ", ps, depth, &r_l->status))		return False;	return True;}/*******************************************************************makes a NET_Q_SAM_SYNC structure.********************************************************************/BOOL init_net_q_sam_sync(NET_Q_SAM_SYNC * q_s, const char *srv_name,                         const char *cli_name, DOM_CRED *cli_creds,                          DOM_CRED *ret_creds, uint32 database_id, 			 uint32 next_rid){	DEBUG(5, ("init_q_sam_sync\n"));	init_unistr2(&q_s->uni_srv_name, srv_name, UNI_STR_TERMINATE);	init_unistr2(&q_s->uni_cli_name, cli_name, UNI_STR_TERMINATE);        if (cli_creds)                memcpy(&q_s->cli_creds, cli_creds, sizeof(q_s->cli_creds));	if (cli_creds)                memcpy(&q_s->ret_creds, ret_creds, sizeof(q_s->ret_creds));	else		memset(&q_s->ret_creds, 0, sizeof(q_s->ret_creds));	q_s->database_id = database_id;	q_s->restart_state = 0;	q_s->sync_context = next_rid;	q_s->max_size = 0xffff;	return True;}/*******************************************************************reads or writes a structure.********************************************************************/BOOL net_io_q_sam_sync(const char *desc, NET_Q_SAM_SYNC * q_s, prs_struct *ps,		       int depth){	prs_debug(ps, depth, desc, "net_io_q_sam_sync");	depth++;	if (!smb_io_unistr2("", &q_s->uni_srv_name, True, ps, depth))                return False;	if (!smb_io_unistr2("", &q_s->uni_cli_name, True, ps, depth))                return False;	if (!smb_io_cred("", &q_s->cli_creds, ps, depth))                return False;	if (!smb_io_cred("", &q_s->ret_creds, ps, depth))                return False;	if (!prs_uint32("database_id  ", ps, depth, &q_s->database_id))                return False;	if (!prs_uint32("restart_state", ps, depth, &q_s->restart_state))                return False;	if (!prs_uint32("sync_context ", ps, depth, &q_s->sync_context))                return False;	if (!prs_uint32("max_size", ps, depth, &q_s->max_size))                return False;	return True;}/*******************************************************************reads or writes a structure.********************************************************************/static BOOL net_io_sam_delta_hdr(const char *desc, SAM_DELTA_HDR * delta,				 prs_struct *ps, int depth){	prs_debug(ps, depth, desc, "net_io_sam_delta_hdr");	depth++;	if (!prs_uint16("type", ps, depth, &delta->type))                return False;	if (!prs_uint16("type2", ps, depth, &delta->type2))                return False;	if (!prs_uint32("target_rid", ps, depth, &delta->target_rid))                return False;	if (!prs_uint32("type3", ps, depth, &delta->type3))                return False;        /* Not sure why we need this but it seems to be necessary to get           sam deltas working. */        if (delta->type != 0x16) {                if (!prs_uint32("ptr_delta", ps, depth, &delta->ptr_delta))                        return False;        }	return True;}/*******************************************************************reads or writes a structure.********************************************************************/static BOOL net_io_sam_delta_mod_count(const char *desc, SAM_DELTA_MOD_COUNT *info,                                   prs_struct *ps, int depth){	prs_debug(ps, depth, desc, "net_io_sam_delta_stamp");	depth++;        if (!prs_uint32("seqnum", ps, depth, &info->seqnum))                return False;        if (!prs_uint32("dom_mod_count_ptr", ps, depth,                         &info->dom_mod_count_ptr))                return False;        if (info->dom_mod_count_ptr) {                if (!prs_uint64("dom_mod_count", ps, depth,                                &info->dom_mod_count))                        return False;        }        return True;}/*******************************************************************reads or writes a structure.********************************************************************/static BOOL net_io_sam_domain_info(const char *desc, SAM_DOMAIN_INFO * info,				   prs_struct *ps, int depth){	prs_debug(ps, depth, desc, "net_io_sam_domain_info");	depth++;	if (!smb_io_unihdr("hdr_dom_name", &info->hdr_dom_name, ps, depth))                return False;	if (!smb_io_unihdr("hdr_oem_info", &info->hdr_oem_info, ps, depth))                return False;        if (!prs_uint64("force_logoff", ps, depth, &info->force_logoff))                return False;	if (!prs_uint16("min_pwd_len", ps, depth, &info->min_pwd_len))                return False;	if (!prs_uint16("pwd_history_len", ps, depth, &info->pwd_history_len))                return False;	if (!prs_uint64("max_pwd_age", ps, depth, &info->max_pwd_age))                return False;	if (!prs_uint64("min_pwd_age", ps, depth, &info->min_pwd_age))                return False;	if (!prs_uint64("dom_mod_count", ps, depth, &info->dom_mod_count))                return False;	if (!smb_io_time("creation_time", &info->creation_time, ps, depth))                return False;	if (!prs_uint32("security_information", ps, depth, &info->security_information))		return False;	if (!smb_io_bufhdr4("hdr_sec_desc", &info->hdr_sec_desc, ps, depth))		return False;	if (!smb_io_lockout_string_hdr("hdr_account_lockout_string", &info->hdr_account_lockout, ps, depth))		return False;	if (!smb_io_unihdr("hdr_unknown2", &info->hdr_unknown2, ps, depth))		return False;	if (!smb_io_unihdr("hdr_unknown3", &info->hdr_unknown3, ps, depth))		return False;	if (!smb_io_unihdr("hdr_unknown4", &info->hdr_unknown4, ps, depth))		return False;	if (!prs_uint32("logon_chgpass", ps, depth, &info->logon_chgpass))		return False;	if (!prs_uint32("unknown6", ps, depth, &info->unknown6))		return False;	if (!prs_uint32("unknown7", ps, depth, &info->unknown7))		return False;	if (!prs_uint32("unknown8", ps, depth, &info->unknown8))		return False;	if (!smb_io_unistr2("uni_dom_name", &info->uni_dom_name,                            info->hdr_dom_name.buffer, ps, depth))                return False;	if (!smb_io_unistr2("buf_oem_info", &info->buf_oem_info,                            info->hdr_oem_info.buffer, ps, depth))                return False;	if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth))                return False;	if (!smb_io_account_lockout_str("account_lockout", &info->account_lockout, 					info->hdr_account_lockout.buffer, ps, depth))		return False;	if (!smb_io_unistr2("buf_unknown2", &info->buf_unknown2, 			    info->hdr_unknown2.buffer, ps, depth))		return False;	if (!smb_io_unistr2("buf_unknown3", &info->buf_unknown3, 			    info->hdr_unknown3.buffer, ps, depth))		return False;	if (!smb_io_unistr2("buf_unknown4", &info->buf_unknown4, 			    info->hdr_unknown4.buffer, ps, depth))		return False;	return True;}/*******************************************************************reads or writes a structure.********************************************************************/static BOOL net_io_sam_group_info(const char *desc, SAM_GROUP_INFO * info,				  prs_struct *ps, int depth){	prs_debug(ps, depth, desc, "net_io_sam_group_info");	depth++;	if (!smb_io_unihdr("hdr_grp_name", &info->hdr_grp_name, ps, depth))                return False;	if (!smb_io_gid("gid", &info->gid, ps, depth))                return False;	if (!smb_io_unihdr("hdr_grp_desc", &info->hdr_grp_desc, ps, depth))                return False;	if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth))                return False;        if (ps->data_offset + 48 > ps->buffer_size)                return False;	ps->data_offset += 48;	if (!smb_io_unistr2("uni_grp_name", &info->uni_grp_name,                            info->hdr_grp_name.buffer, ps, depth))                return False;	if (!smb_io_unistr2("uni_grp_desc", &info->uni_grp_desc,                            info->hdr_grp_desc.buffer, ps, depth))                return False;	if (!smb_io_rpc_blob("buf_sec_desc", &info->buf_sec_desc, ps, depth))                return False;	return True;}/*******************************************************************reads or writes a structure.********************************************************************/static BOOL net_io_sam_passwd_info(const char *desc, SAM_PWD * pwd,				   prs_struct *ps, int depth){	prs_debug(ps, depth, desc, "net_io_sam_passwd_info");	depth++;	if (!prs_uint32("unk_0 ", ps, depth, &pwd->unk_0))                return False;	if (!smb_io_unihdr("hdr_lm_pwd", &pwd->hdr_lm_pwd, ps, depth))                return False;	if (!prs_uint8s(False, "buf_lm_pwd", ps, depth, pwd->buf_lm_pwd, 16))                return False;	if (!smb_io_unihdr("hdr_nt_pwd", &pwd->hdr_nt_pwd, ps, depth))                return False;	if (!prs_uint8s(False, "buf_nt_pwd", ps, depth, pwd->buf_nt_pwd, 16))                return False;	if (!smb_io_unihdr("", &pwd->hdr_empty_lm, ps, depth))                return False;	if (!smb_io_unihdr("", &pwd->hdr_empty_nt, ps, depth))                return False;	return True;}/*******************************************************************makes a SAM_ACCOUNT_INFO structure.********************************************************************/BOOL make_sam_account_info(SAM_ACCOUNT_INFO * info,			   const UNISTR2 *user_name,			   const UNISTR2 *full_name,			   uint32 user_rid, uint32 group_rid,			   const UNISTR2 *home_dir,			   const UNISTR2 *dir_drive,			   const UNISTR2 *log_scr,			   const UNISTR2 *desc,			   uint32 acb_info,			   const UNISTR2 *prof_path,			   const UNISTR2 *wkstas,			   const UNISTR2 *unk_str, const UNISTR2 *mung_dial){	int len_user_name = user_name != NULL ? user_name->uni_str_len : 0;	int len_full_name = full_name != NULL ? full_name->uni_str_len : 0;	int len_home_dir = home_dir != NULL ? home_dir->uni_str_len : 0;	int len_dir_drive = dir_drive != NULL ? dir_drive->uni_str_len : 0;	int len_logon_script = log_scr != NULL ? log_scr->uni_str_len : 0;	int len_profile_path = prof_path != NULL ? prof_path->uni_str_len : 0;	int len_description = desc != NULL ? desc->uni_str_len : 0;	int len_workstations = wkstas != NULL ? wkstas->uni_str_len : 0;	int len_unknown_str = unk_str != NULL ? unk_str->uni_str_len : 0;	int len_munged_dial = mung_dial != NULL ? mung_dial->uni_str_len : 0;	DEBUG(5, ("make_sam_account_info\n"));	make_uni_hdr(&info->hdr_acct_name, len_user_name);	make_uni_hdr(&info->hdr_full_name, len_full_name);	make_uni_hdr(&info->hdr_home_dir, len_home_dir);	make_uni_hdr(&info->hdr_dir_drive, len_dir_drive);	make_uni_hdr(&info->hdr_logon_script, len_logon_script);	make_uni_hdr(&info->hdr_profile, len_profile_path);	make_uni_hdr(&info->hdr_acct_desc, len_description);	make_uni_hdr(&info->hdr_workstations, len_workstations);	make_uni_hdr(&info->hdr_comment, len_unknown_str);	make_uni_hdr(&info->hdr_parameters, len_munged_dial);	/* not present */	make_bufhdr2(&info->hdr_sec_desc, 0, 0, 0);	info->user_rid = user_rid;	info->group_rid = group_rid;	init_nt_time(&info->logon_time);	init_nt_time(&info->logoff_time);	init_nt_time(&info->pwd_last_set_time);	init_nt_time(&info->acct_expiry_time);	info->logon_divs = 0xA8;	info->ptr_logon_hrs = 0;	/* Don't care right now */	info->bad_pwd_count = 0;	info->logon_count = 0;	info->acb_info = acb_info;	info->nt_pwd_present = 0;	info->lm_pwd_present = 0;	info->pwd_expired = 0;	info->country = 0;	info->codepage = 0;	info->unknown1 = 0x4EC;	info->unknown2 = 0;	copy_unistr2(&info->uni_acct_name, user_name);	copy_unistr2(&info->uni_full_name, full_name);	copy_unistr2(&info->uni_home_di

⌨️ 快捷键说明

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