summaryrefslogtreecommitdiff
path: root/source3/rpc_parse/parse_net.c
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2001-08-28 06:43:43 +0000
committerTim Potter <tpot@samba.org>2001-08-28 06:43:43 +0000
commitd5c9172adadb83283e437578be7bad4368ad9f20 (patch)
treef21c0e6d07b15375bced92c0e3a96cdf653642a4 /source3/rpc_parse/parse_net.c
parent49dff249fc3f9155037016dd131cbaa41e5306bc (diff)
downloadsamba-d5c9172adadb83283e437578be7bad4368ad9f20.tar.gz
samba-d5c9172adadb83283e437578be7bad4368ad9f20.tar.bz2
samba-d5c9172adadb83283e437578be7bad4368ad9f20.zip
Merge of sam sync code from TNG.
Reverse-engineered the sam replication protocol from staring at hex dumps for a while. It's pretty similar to the sam sync protocol with a couple of different delta header types. I wasn't able to figure out the format of the privilege stuff - needs more time and a whiteboard. (-: The impressive bit is that the sam sync stuff from tng basically just worked thanks mainly to Luke Leighton's efforts in this area. (This used to be commit 3a60cb44f22d5f3f8c78a56ed8f5ea4794cd7ab3)
Diffstat (limited to 'source3/rpc_parse/parse_net.c')
-rw-r--r--source3/rpc_parse/parse_net.c834
1 files changed, 834 insertions, 0 deletions
diff --git a/source3/rpc_parse/parse_net.c b/source3/rpc_parse/parse_net.c
index e8f0c02a52..37bf6755b7 100644
--- a/source3/rpc_parse/parse_net.c
+++ b/source3/rpc_parse/parse_net.c
@@ -1589,3 +1589,837 @@ BOOL net_io_r_sam_logoff(char *desc, NET_R_SAM_LOGOFF *r_l, prs_struct *ps, int
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,
+ uint32 database_id)
+{
+ DEBUG(5, ("init_q_sam_sync\n"));
+
+ init_unistr2(&q_s->uni_srv_name, srv_name, strlen(srv_name) + 1);
+ init_unistr2(&q_s->uni_cli_name, cli_name, strlen(cli_name) + 1);
+
+ if (cli_creds) {
+ memcpy(&q_s->cli_creds, cli_creds, sizeof(q_s->cli_creds));
+ 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 = 0;
+ q_s->max_size = 0xffff;
+
+ return True;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+BOOL net_io_q_sam_sync(char *desc, NET_Q_SAM_SYNC * q_s, prs_struct *ps,
+ int depth)
+{
+ prs_debug(ps, depth, desc, "net_io_q_sam_sync");
+ depth++;
+
+ smb_io_unistr2("", &(q_s->uni_srv_name), True, ps, depth);
+ smb_io_unistr2("", &(q_s->uni_cli_name), True, ps, depth);
+
+ smb_io_cred("", &(q_s->cli_creds), ps, depth);
+ smb_io_cred("", &(q_s->ret_creds), ps, depth);
+
+ prs_uint32("database_id ", ps, depth, &(q_s->database_id));
+ prs_uint32("restart_state", ps, depth, &(q_s->restart_state));
+ prs_uint32("sync_context ", ps, depth, &(q_s->sync_context));
+
+ prs_uint32("max_size", ps, depth, &(q_s->max_size));
+
+ return True;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+static BOOL net_io_sam_delta_hdr(char *desc, SAM_DELTA_HDR * delta,
+ prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "net_io_sam_delta_hdr");
+ depth++;
+
+ prs_uint16("type", ps, depth, &(delta->type));
+ prs_uint16("type2", ps, depth, &(delta->type2));
+ prs_uint32("target_rid", ps, depth, &(delta->target_rid));
+
+ prs_uint32("type3", ps, depth, &(delta->type3));
+
+ /* Not sure why we need this but it seems to be necessary to get
+ sam deltas working. */
+
+ if (delta->type != 0x16)
+ prs_uint32("ptr_delta", ps, depth, &(delta->ptr_delta));
+
+ return True;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+static BOOL net_io_sam_delta_hdr2(char *desc, SAM_DELTA_HDR *delta,
+ prs_struct *ps, int depth)
+{
+ uint32 unk;
+
+ prs_debug(ps, depth, desc, "net_io_sam_delta_stamp");
+ depth++;
+
+ prs_uint16("type", ps, depth, &(delta->type));
+ prs_uint16("type2", ps, depth, &(delta->type2));
+ prs_uint32("rid", ps, depth, &unk);
+
+
+ prs_uint32("unknown_ptr", ps, depth, &unk);
+
+ return True;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+static BOOL net_io_sam_delta_stamp(char *desc, SAM_DELTA_STAMP *info,
+ prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "net_io_sam_delta_stamp");
+ depth++;
+
+ prs_uint32("seqnum", ps, depth, &info->seqnum);
+ prs_uint32("dom_mod_count_ptr", ps, depth, &info->dom_mod_count_ptr);
+ if (info->dom_mod_count_ptr)
+ prs_uint64("dom_mod_count", ps, depth, &info->dom_mod_count);
+
+ return True;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+static BOOL net_io_sam_domain_info(char *desc, SAM_DOMAIN_INFO * info,
+ prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "net_io_sam_domain_info");
+ depth++;
+
+ smb_io_unihdr("hdr_dom_name", &(info->hdr_dom_name), ps, depth);
+ smb_io_unihdr("hdr_oem_info", &(info->hdr_oem_info), ps, depth);
+
+ prs_uint64("force_logoff", ps, depth, &info->force_logoff);
+ prs_uint16("min_pwd_len", ps, depth, &(info->min_pwd_len));
+ prs_uint16("pwd_history_len", ps, depth, &info->pwd_history_len);
+ prs_uint64("max_pwd_age", ps, depth, &info->max_pwd_age);
+ prs_uint64("min_pwd_age", ps, depth, &info->min_pwd_age);
+ prs_uint64("dom_mod_count", ps, depth, &info->dom_mod_count);
+ smb_io_time("creation_time", &info->creation_time, ps, depth);
+
+ smb_io_bufhdr2("hdr_sec_desc", &(info->hdr_sec_desc), ps, depth);
+ smb_io_unihdr("hdr_unknown", &(info->hdr_unknown), ps, depth);
+ ps->data_offset += 40;
+
+ smb_io_unistr2("uni_dom_name", &(info->uni_dom_name),
+ info->hdr_dom_name.buffer, ps, depth);
+ smb_io_unistr2("buf_oem_info", &(info->buf_oem_info),
+ info->hdr_oem_info.buffer, ps, depth);
+
+ smb_io_buffer4("buf_sec_desc", &(info->buf_sec_desc),
+ info->hdr_sec_desc.buffer, ps, depth);
+ smb_io_unistr2("buf_unknown", &(info->buf_unknown),
+ info->hdr_unknown.buffer, ps, depth);
+
+ return True;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+static BOOL net_io_sam_group_info(char *desc, SAM_GROUP_INFO * info,
+ prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "net_io_sam_group_info");
+ depth++;
+
+ smb_io_unihdr("hdr_grp_name", &(info->hdr_grp_name), ps, depth);
+ smb_io_gid("gid", &(info->gid), ps, depth);
+ smb_io_unihdr("hdr_grp_desc", &(info->hdr_grp_desc), ps, depth);
+ smb_io_bufhdr2("hdr_sec_desc", &(info->hdr_sec_desc), ps, depth);
+ ps->data_offset += 48;
+
+ smb_io_unistr2("uni_grp_name", &(info->uni_grp_name),
+ info->hdr_grp_name.buffer, ps, depth);
+ smb_io_unistr2("uni_grp_desc", &(info->uni_grp_desc),
+ info->hdr_grp_desc.buffer, ps, depth);
+ smb_io_buffer4("buf_sec_desc", &(info->buf_sec_desc),
+ info->hdr_sec_desc.buffer, ps, depth);
+
+ return True;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+static BOOL net_io_sam_passwd_info(char *desc, SAM_PWD * pwd,
+ prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "net_io_sam_passwd_info");
+ depth++;
+
+ prs_uint32("unk_0 ", ps, depth, &(pwd->unk_0));
+
+ smb_io_unihdr("hdr_lm_pwd", &(pwd->hdr_lm_pwd), ps, depth);
+ prs_uint8s(False, "buf_lm_pwd", ps, depth, pwd->buf_lm_pwd, 16);
+
+ smb_io_unihdr("hdr_nt_pwd", &(pwd->hdr_nt_pwd), ps, depth);
+ prs_uint8s(False, "buf_nt_pwd", ps, depth, pwd->buf_nt_pwd, 16);
+
+ smb_io_unihdr("", &(pwd->hdr_empty_lm), ps, depth);
+ smb_io_unihdr("", &(pwd->hdr_empty_nt), ps, depth);
+
+ 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_dir), home_dir);
+ copy_unistr2(&(info->uni_dir_drive), dir_drive);
+ copy_unistr2(&(info->uni_logon_script), log_scr);
+ copy_unistr2(&(info->uni_profile), prof_path);
+ copy_unistr2(&(info->uni_acct_desc), desc);
+ copy_unistr2(&(info->uni_workstations), wkstas);
+ copy_unistr2(&(info->uni_comment), unk_str);
+ copy_unistr2(&(info->uni_parameters), mung_dial);
+
+ return True;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+static BOOL net_io_sam_account_info(char *desc, uint8 sess_key[16],
+ SAM_ACCOUNT_INFO * info, prs_struct *ps,
+ int depth)
+{
+ BUFHDR2 hdr_priv_data;
+ uint32 i;
+
+ prs_debug(ps, depth, desc, "net_io_sam_account_info");
+ depth++;
+
+ smb_io_unihdr("hdr_acct_name", &(info->hdr_acct_name), ps, depth);
+ smb_io_unihdr("hdr_full_name", &(info->hdr_full_name), ps, depth);
+
+ prs_uint32("user_rid ", ps, depth, &(info->user_rid));
+ prs_uint32("group_rid", ps, depth, &(info->group_rid));
+
+ smb_io_unihdr("hdr_home_dir ", &(info->hdr_home_dir), ps, depth);
+ smb_io_unihdr("hdr_dir_drive", &(info->hdr_dir_drive), ps, depth);
+ smb_io_unihdr("hdr_logon_script", &(info->hdr_logon_script), ps,
+ depth);
+ smb_io_unihdr("hdr_acct_desc", &(info->hdr_acct_desc), ps, depth);
+ smb_io_unihdr("hdr_workstations", &(info->hdr_workstations), ps,
+ depth);
+
+ smb_io_time("logon_time", &(info->logon_time), ps, depth);
+ smb_io_time("logoff_time", &(info->logoff_time), ps, depth);
+
+ prs_uint32("logon_divs ", ps, depth, &(info->logon_divs));
+ prs_uint32("ptr_logon_hrs", ps, depth, &(info->ptr_logon_hrs));
+
+ prs_uint16("bad_pwd_count", ps, depth, &(info->bad_pwd_count));
+ prs_uint16("logon_count", ps, depth, &(info->logon_count));
+ smb_io_time("pwd_last_set_time", &(info->pwd_last_set_time), ps,
+ depth);
+ smb_io_time("acct_expiry_time", &(info->acct_expiry_time), ps, depth);
+
+ prs_uint32("acb_info", ps, depth, &(info->acb_info));
+ prs_uint8s(False, "nt_pwd", ps, depth, info->nt_pwd, 16);
+ prs_uint8s(False, "lm_pwd", ps, depth, info->lm_pwd, 16);
+ prs_uint8("lm_pwd_present", ps, depth, &(info->lm_pwd_present));
+ prs_uint8("nt_pwd_present", ps, depth, &(info->nt_pwd_present));
+ prs_uint8("pwd_expired", ps, depth, &(info->pwd_expired));
+
+ smb_io_unihdr("hdr_comment", &(info->hdr_comment), ps, depth);
+ smb_io_unihdr("hdr_parameters", &(info->hdr_parameters), ps, depth);
+ prs_uint16("country", ps, depth, &(info->country));
+ prs_uint16("codepage", ps, depth, &(info->codepage));
+
+ smb_io_bufhdr2("hdr_priv_data", &(hdr_priv_data), ps, depth);
+ smb_io_bufhdr2("hdr_sec_desc", &(info->hdr_sec_desc), ps, depth);
+ smb_io_unihdr("hdr_profile", &(info->hdr_profile), ps, depth);
+
+ for (i = 0; i < 3; i++)
+ {
+ smb_io_unihdr("hdr_reserved", &(info->hdr_reserved[i]), ps,
+ depth);
+ }
+
+ for (i = 0; i < 4; i++)
+ {
+ prs_uint32("dw_reserved", ps, depth, &(info->dw_reserved[i]));
+ }
+
+ smb_io_unistr2("uni_acct_name", &(info->uni_acct_name),
+ info->hdr_acct_name.buffer, ps, depth);
+ prs_align(ps);
+ smb_io_unistr2("uni_full_name", &(info->uni_full_name),
+ info->hdr_full_name.buffer, ps, depth);
+ prs_align(ps);
+ smb_io_unistr2("uni_home_dir ", &(info->uni_home_dir),
+ info->hdr_home_dir.buffer, ps, depth);
+ prs_align(ps);
+ smb_io_unistr2("uni_dir_drive", &(info->uni_dir_drive),
+ info->hdr_dir_drive.buffer, ps, depth);
+ prs_align(ps);
+ smb_io_unistr2("uni_logon_script", &(info->uni_logon_script),
+ info->hdr_logon_script.buffer, ps, depth);
+ prs_align(ps);
+ smb_io_unistr2("uni_acct_desc", &(info->uni_acct_desc),
+ info->hdr_acct_desc.buffer, ps, depth);
+ prs_align(ps);
+ smb_io_unistr2("uni_workstations", &(info->uni_workstations),
+ info->hdr_workstations.buffer, ps, depth);
+ prs_align(ps);
+
+ prs_uint32("unknown1", ps, depth, &(info->unknown1));
+ prs_uint32("unknown2", ps, depth, &(info->unknown2));
+
+ smb_io_buffer4("buf_logon_hrs", &(info->buf_logon_hrs),
+ info->ptr_logon_hrs, ps, depth);
+ prs_align(ps);
+ smb_io_unistr2("uni_comment", &(info->uni_comment),
+ info->hdr_comment.buffer, ps, depth);
+ prs_align(ps);
+ smb_io_unistr2("uni_parameters", &(info->uni_parameters),
+ info->hdr_parameters.buffer, ps, depth);
+ prs_align(ps);
+ if (hdr_priv_data.buffer != 0)
+ {
+ int old_offset = 0;
+ uint32 len = 0x44;
+ prs_uint32("pwd_len", ps, depth, &len);
+ old_offset = ps->data_offset;
+ if (len == 0x44)
+ {
+ if (ps->io)
+ {
+ /* reading */
+// FIXME prs_hash1(ps, ps->offset, sess_key);
+ }
+ net_io_sam_passwd_info("pass", &(info->pass), ps,
+ depth);
+ if (!ps->io)
+ {
+ /* writing */
+// FIXME TOO prs_hash1(ps, old_offset, sess_key);
+ }
+ }
+ ps->data_offset = old_offset + len;
+ }
+ smb_io_buffer4("buf_sec_desc", &(info->buf_sec_desc),
+ info->hdr_sec_desc.buffer, ps, depth);
+ prs_align(ps);
+ smb_io_unistr2("uni_profile", &(info->uni_profile),
+ info->hdr_profile.buffer, ps, depth);
+ prs_align(ps);
+
+ return True;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+static BOOL net_io_sam_group_mem_info(char *desc, SAM_GROUP_MEM_INFO * info,
+ prs_struct *ps, int depth)
+{
+ uint32 i;
+ fstring tmp;
+
+ prs_debug(ps, depth, desc, "net_io_sam_group_mem_info");
+ depth++;
+
+ prs_align(ps);
+ prs_uint32("ptr_rids ", ps, depth, &(info->ptr_rids));
+ prs_uint32("ptr_attribs", ps, depth, &(info->ptr_attribs));
+ prs_uint32("num_members", ps, depth, &(info->num_members));
+ ps->data_offset += 16;
+
+ if (info->ptr_rids != 0)
+ {
+ prs_uint32("num_members2", ps, depth, &(info->num_members2));
+ if (info->num_members2 != info->num_members)
+ {
+ /* RPC fault */
+ return False;
+ }
+
+ info->rids = talloc(ps->mem_ctx, sizeof(uint32) *
+ info->num_members2);
+
+ if (info->rids == NULL) {
+ DEBUG(0, ("out of memory allocating %d rids\n",
+ info->num_members2));
+ return False;
+ }
+
+ for (i = 0; i < info->num_members2; i++)
+ {
+ slprintf(tmp, sizeof(tmp) - 1, "rids[%02d]", i);
+ prs_uint32(tmp, ps, depth, &(info->rids[i]));
+ }
+ }
+
+ if (info->ptr_attribs != 0)
+ {
+ prs_uint32("num_members3", ps, depth, &(info->num_members3));
+ if (info->num_members3 != info->num_members)
+ {
+ /* RPC fault */
+ return False;
+ }
+
+ info->attribs = talloc(ps->mem_ctx, sizeof(uint32) *
+ info->num_members3);
+
+ if (info->attribs == NULL) {
+ DEBUG(0, ("out of memory allocating %d attribs\n",
+ info->num_members3));
+ return False;
+ }
+
+ for (i = 0; i < info->num_members3; i++)
+ {
+ slprintf(tmp, sizeof(tmp) - 1, "attribs[%02d]", i);
+ prs_uint32(tmp, ps, depth, &(info->attribs[i]));
+ }
+ }
+
+ return True;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+static BOOL net_io_sam_alias_info(char *desc, SAM_ALIAS_INFO * info,
+ prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "net_io_sam_alias_info");
+ depth++;
+
+ smb_io_unihdr("hdr_als_name", &(info->hdr_als_name), ps, depth);
+ prs_uint32("als_rid", ps, depth, &(info->als_rid));
+ smb_io_bufhdr2("hdr_sec_desc", &(info->hdr_sec_desc), ps, depth);
+ smb_io_unihdr("hdr_als_desc", &(info->hdr_als_desc), ps, depth);
+ ps->data_offset += 40;
+
+ smb_io_unistr2("uni_als_name", &(info->uni_als_name),
+ info->hdr_als_name.buffer, ps, depth);
+ smb_io_buffer4("buf_sec_desc", &(info->buf_sec_desc),
+ info->hdr_sec_desc.buffer, ps, depth);
+ smb_io_unistr2("uni_als_desc", &(info->uni_als_desc),
+ info->hdr_als_name.buffer, ps, depth);
+
+ return True;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+static BOOL net_io_sam_alias_mem_info(char *desc, SAM_ALIAS_MEM_INFO * info,
+ prs_struct *ps, int depth)
+{
+ uint32 i;
+ fstring tmp;
+
+ prs_debug(ps, depth, desc, "net_io_sam_alias_mem_info");
+ depth++;
+
+ prs_align(ps);
+ prs_uint32("num_members", ps, depth, &(info->num_members));
+ prs_uint32("ptr_members", ps, depth, &(info->ptr_members));
+ ps->data_offset += 16;
+
+ if (info->ptr_members != 0)
+ {
+ prs_uint32("num_sids", ps, depth, &(info->num_sids));
+ if (info->num_sids != info->num_members)
+ {
+ /* RPC fault */
+ return False;
+ }
+
+ info->ptr_sids = talloc(ps->mem_ctx, sizeof(uint32) *
+ info->num_sids);
+
+ if (info->ptr_sids == NULL) {
+ DEBUG(0, ("out of memory allocating %d ptr_sids\n",
+ info->num_sids));
+ return False;
+ }
+
+ for (i = 0; i < info->num_sids; i++)
+ {
+ slprintf(tmp, sizeof(tmp) - 1, "ptr_sids[%02d]", i);
+ prs_uint32(tmp, ps, depth, &(info->ptr_sids[i]));
+ }
+
+ info->sids = talloc(ps->mem_ctx, sizeof(DOM_SID2) *
+ info->num_sids);
+
+ if (info->sids == NULL) {
+ DEBUG(0, ("error allocating %d sids\n",
+ info->num_sids));
+ return False;
+ }
+
+ for (i = 0; i < info->num_sids; i++)
+ {
+ if (info->ptr_sids[i] != 0)
+ {
+ slprintf(tmp, sizeof(tmp) - 1, "sids[%02d]",
+ i);
+ smb_io_dom_sid2(tmp, &(info->sids[i]), ps,
+ depth);
+ }
+ }
+ }
+
+ return True;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+static BOOL net_io_sam_delta_ctr(char *desc, uint8 sess_key[16],
+ SAM_DELTA_CTR * delta, uint16 type,
+ prs_struct *ps, int depth)
+{
+ prs_debug(ps, depth, desc, "net_io_sam_delta_ctr");
+ depth++;
+
+ switch (type)
+ {
+ /* Seen in sam deltas */
+
+ case SAM_DELTA_SAM_STAMP:
+ {
+ net_io_sam_delta_stamp("", &delta->stamp,
+ ps, depth);
+ break;
+ }
+
+ case SAM_DELTA_DOMAIN_INFO:
+ {
+ net_io_sam_domain_info("", &delta->domain_info,
+ ps, depth);
+ break;
+ }
+ case SAM_DELTA_GROUP_INFO:
+ {
+ net_io_sam_group_info("", &delta->group_info,
+ ps, depth);
+ break;
+ }
+ case SAM_DELTA_ACCOUNT_INFO:
+ {
+ net_io_sam_account_info("", sess_key,
+ &delta->account_info,
+ ps, depth);
+ break;
+ }
+ case SAM_DELTA_GROUP_MEM:
+ {
+ net_io_sam_group_mem_info("", &delta->grp_mem_info,
+ ps, depth);
+ break;
+ }
+ case SAM_DELTA_ALIAS_INFO:
+ {
+ net_io_sam_alias_info("", &delta->alias_info,
+ ps, depth);
+ break;
+ }
+ case SAM_DELTA_ALIAS_MEM:
+ {
+ net_io_sam_alias_mem_info("", &delta->als_mem_info,
+ ps, depth);
+ break;
+ }
+ default:
+ {
+ DEBUG(0,
+ ("Replication error: Unknown delta type 0x%x\n",
+ type));
+ break;
+ }
+ }
+
+ return True;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+BOOL net_io_r_sam_sync(char *desc, uint8 sess_key[16],
+ NET_R_SAM_SYNC * r_s, prs_struct *ps, int depth)
+{
+ uint32 i;
+
+ prs_debug(ps, depth, desc, "net_io_r_sam_sync");
+ depth++;
+
+ smb_io_cred("srv_creds", &(r_s->srv_creds), ps, depth);
+ prs_uint32("sync_context", ps, depth, &(r_s->sync_context));
+
+ prs_uint32("ptr_deltas", ps, depth, &(r_s->ptr_deltas));
+ if (r_s->ptr_deltas != 0)
+ {
+ prs_uint32("num_deltas ", ps, depth, &(r_s->num_deltas));
+ prs_uint32("ptr_deltas2", ps, depth, &(r_s->ptr_deltas2));
+ if (r_s->ptr_deltas2 != 0)
+ {
+ prs_uint32("num_deltas2", ps, depth,
+ &(r_s->num_deltas2));
+
+ if (r_s->num_deltas2 != r_s->num_deltas)
+ {
+ /* RPC fault */
+ return False;
+ }
+
+ if (r_s->num_deltas2 > 0) {
+ r_s->hdr_deltas = (SAM_DELTA_HDR *)
+ talloc(ps->mem_ctx, r_s->num_deltas2 *
+ sizeof(SAM_DELTA_HDR));
+
+ if (r_s->hdr_deltas == NULL) {
+ DEBUG(0, ("error tallocating memory "
+ "for %d delta headers\n",
+ r_s->num_deltas2));
+ return False;
+ }
+ }
+
+ for (i = 0; i < r_s->num_deltas2; i++)
+ {
+ net_io_sam_delta_hdr("", &r_s->hdr_deltas[i],
+ ps, depth);
+ }
+
+ if (r_s->num_deltas2 > 0) {
+ r_s->deltas = (SAM_DELTA_CTR *)
+ talloc(ps->mem_ctx, r_s->num_deltas2 *
+ sizeof(SAM_DELTA_CTR));
+
+ if (r_s->deltas == NULL) {
+ DEBUG(0, ("error tallocating memory "
+ "for %d deltas\n",
+ r_s->num_deltas2));
+ return False;
+ }
+ }
+
+ for (i = 0; i < r_s->num_deltas2; i++)
+ {
+ net_io_sam_delta_ctr("", sess_key,
+ &r_s->deltas[i],
+ r_s->hdr_deltas[i].type3,
+ ps, depth);
+ }
+ }
+ }
+
+ prs_align(ps);
+ prs_uint32("status", ps, depth, &(r_s->status));
+
+ return True;
+}
+
+/*******************************************************************
+makes a NET_Q_SAM_DELTAS structure.
+********************************************************************/
+BOOL init_net_q_sam_deltas(NET_Q_SAM_DELTAS *q_s, const char *srv_name,
+ const char *cli_name, DOM_CRED *cli_creds,
+ uint32 database_id, UINT64_S dom_mod_count)
+{
+ DEBUG(5, ("init_net_q_sam_deltas\n"));
+
+ init_unistr2(&q_s->uni_srv_name, srv_name, strlen(srv_name) + 1);
+ init_unistr2(&q_s->uni_cli_name, cli_name, strlen(cli_name) + 1);
+
+ memcpy(&q_s->cli_creds, cli_creds, sizeof(q_s->cli_creds));
+ memset(&q_s->ret_creds, 0, sizeof(q_s->ret_creds));
+
+ q_s->database_id = database_id;
+ q_s->dom_mod_count.low = dom_mod_count.low;
+ q_s->dom_mod_count.high = dom_mod_count.high;
+ q_s->max_size = 0xffff;
+
+ return True;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+BOOL net_io_q_sam_deltas(char *desc, NET_Q_SAM_DELTAS *q_s, prs_struct *ps,
+ int depth)
+{
+ prs_debug(ps, depth, desc, "net_io_q_sam_deltas");
+ depth++;
+
+ smb_io_unistr2("", &q_s->uni_srv_name, True, ps, depth);
+ smb_io_unistr2("", &q_s->uni_cli_name, True, ps, depth);
+
+ smb_io_cred("", &q_s->cli_creds, ps, depth);
+ smb_io_cred("", &q_s->ret_creds, ps, depth);
+
+ prs_uint32("database_id ", ps, depth, &q_s->database_id);
+ prs_uint64("dom_mod_count", ps, depth, &q_s->dom_mod_count);
+ prs_uint32("max_size", ps, depth, &q_s->max_size);
+
+ return True;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+BOOL net_io_r_sam_deltas(char *desc, uint8 sess_key[16],
+ NET_R_SAM_DELTAS *r_s, prs_struct *ps, int depth)
+{
+ int i;
+
+ prs_debug(ps, depth, desc, "net_io_r_sam_deltas");
+ depth++;
+
+ smb_io_cred("srv_creds", &r_s->srv_creds, ps, depth);
+ prs_uint64("dom_mod_count", ps, depth, &r_s->dom_mod_count);
+
+ prs_uint32("ptr_deltas", ps, depth, &r_s->ptr_deltas);
+ prs_uint32("num_deltas", ps, depth, &r_s->num_deltas);
+ prs_uint32("ptr_deltas2", ps, depth, &r_s->num_deltas2);
+
+ if (r_s->num_deltas2 != 0)
+ {
+ prs_uint32("num_deltas2 ", ps, depth, &(r_s->num_deltas2));
+
+ if (r_s->ptr_deltas != 0)
+ {
+ if (r_s->num_deltas > 0) {
+ r_s->hdr_deltas = (SAM_DELTA_HDR *)
+ talloc(ps->mem_ctx, r_s->num_deltas *
+ sizeof(SAM_DELTA_HDR));
+ if (r_s->hdr_deltas == NULL) {
+ DEBUG(0, ("error tallocating memory "
+ "for %d delta headers\n",
+ r_s->num_deltas));
+ return False;
+ }
+ }
+
+ for (i = 0; i < r_s->num_deltas; i++)
+ {
+ net_io_sam_delta_hdr("", &r_s->hdr_deltas[i],
+ ps, depth);
+ }
+
+ if (r_s->num_deltas > 0) {
+ r_s->deltas = (SAM_DELTA_CTR *)
+ talloc(ps->mem_ctx, r_s->num_deltas *
+ sizeof(SAM_DELTA_CTR));
+
+ if (r_s->deltas == NULL) {
+ DEBUG(0, ("error tallocating memory "
+ "for %d deltas\n",
+ r_s->num_deltas));
+ return False;
+ }
+ }
+
+ for (i = 0; i < r_s->num_deltas; i++)
+ {
+ net_io_sam_delta_ctr("", sess_key,
+ &r_s->deltas[i],
+ r_s->hdr_deltas[i].type2,
+ ps, depth);
+ }
+ }
+ }
+
+ prs_align(ps);
+ prs_uint32("status", ps, depth, &(r_s->status));
+
+ return True;
+}