/*
- * Unix SMB/Netbios implementation.
- * Version 1.9.
+ * Unix SMB/CIFS implementation.
* RPC Pipe client / server routines
* Copyright (C) Andrew Tridgell 1992-1997,
* Copyright (C) Luke Kenneth Casson Leighton 1996-1997,
#include "includes.h"
-extern int DEBUGLEVEL;
-
/*******************************************************************
Reads or writes a structure.
********************************************************************/
info->tc_status = tc_status;
if (trusted_dc_name != NULL)
- init_unistr2(&(info->uni_trusted_dc_name), trusted_dc_name, len_dc_name+1);
+ init_unistr2(&info->uni_trusted_dc_name, trusted_dc_name, len_dc_name+1);
else
- init_unistr2(&(info->uni_trusted_dc_name), "", 1);
+ init_unistr2(&info->uni_trusted_dc_name, "", 1);
}
/*******************************************************************
return True;
}
+/*******************************************************************
+ Inits an NET_Q_LOGON_CTRL2 structure.
+********************************************************************/
+
+void init_net_q_logon_ctrl2(NET_Q_LOGON_CTRL2 *q_l, char *srv_name,
+ uint32 query_level)
+{
+ DEBUG(5,("init_q_logon_ctrl2\n"));
+
+ q_l->function_code = 0x01;
+ q_l->query_level = query_level;
+ q_l->switch_value = 0x01;
+
+ init_unistr2(&q_l->uni_server_name, srv_name, strlen(srv_name) + 1);
+}
+
/*******************************************************************
Inits an NET_R_LOGON_CTRL2 structure.
********************************************************************/
-void init_r_logon_ctrl2(NET_R_LOGON_CTRL2 *r_l, uint32 query_level,
- uint32 flags, uint32 pdc_status, uint32 logon_attempts,
- uint32 tc_status, char *trusted_domain_name)
+void init_net_r_logon_ctrl2(NET_R_LOGON_CTRL2 *r_l, uint32 query_level,
+ uint32 flags, uint32 pdc_status,
+ uint32 logon_attempts, uint32 tc_status,
+ char *trusted_domain_name)
{
- DEBUG(5,("make_r_logon_ctrl2\n"));
+ DEBUG(5,("init_r_logon_ctrl2\n"));
r_l->switch_value = query_level; /* should only be 0x1 */
case 1:
r_l->ptr = 1; /* undocumented pointer */
init_netinfo_1(&r_l->logon.info1, flags, pdc_status);
- r_l->status = 0;
+ r_l->status = NT_STATUS_OK;
break;
case 2:
r_l->ptr = 1; /* undocumented pointer */
init_netinfo_2(&r_l->logon.info2, flags, pdc_status,
tc_status, trusted_domain_name);
- r_l->status = 0;
+ r_l->status = NT_STATUS_OK;
break;
case 3:
r_l->ptr = 1; /* undocumented pointer */
- init_netinfo_3(&(r_l->logon.info3), flags, logon_attempts);
- r_l->status = 0;
+ init_netinfo_3(&r_l->logon.info3, flags, logon_attempts);
+ r_l->status = NT_STATUS_OK;
break;
default:
DEBUG(2,("init_r_logon_ctrl2: unsupported switch value %d\n",
}
}
- if(!prs_uint32("status ", ps, depth, &r_l->status))
+ if(!prs_ntstatus("status ", ps, depth, &r_l->status))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Reads or writes an NET_Q_LOGON_CTRL structure.
+********************************************************************/
+
+BOOL net_io_q_logon_ctrl(char *desc, NET_Q_LOGON_CTRL *q_l, prs_struct *ps,
+ int depth)
+{
+ prs_debug(ps, depth, desc, "net_io_q_logon_ctrl");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr ", ps, depth, &q_l->ptr))
+ return False;
+
+ if(!smb_io_unistr2 ("", &q_l->uni_server_name, q_l->ptr, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("function_code", ps, depth, &q_l->function_code))
+ return False;
+ if(!prs_uint32("query_level ", ps, depth, &q_l->query_level))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+ Inits an NET_Q_LOGON_CTRL structure.
+********************************************************************/
+
+void init_net_q_logon_ctrl(NET_Q_LOGON_CTRL *q_l, char *srv_name,
+ uint32 query_level)
+{
+ DEBUG(5,("init_q_logon_ctrl\n"));
+
+ q_l->function_code = 0x01; /* ??? */
+ q_l->query_level = query_level;
+
+ init_unistr2(&q_l->uni_server_name, srv_name, strlen(srv_name) + 1);
+}
+
+/*******************************************************************
+ Inits an NET_R_LOGON_CTRL structure.
+********************************************************************/
+
+void init_net_r_logon_ctrl(NET_R_LOGON_CTRL *r_l, uint32 query_level,
+ uint32 flags, uint32 pdc_status)
+{
+ DEBUG(5,("init_r_logon_ctrl\n"));
+
+ r_l->switch_value = query_level; /* should only be 0x1 */
+
+ switch (query_level) {
+ case 1:
+ r_l->ptr = 1; /* undocumented pointer */
+ init_netinfo_1(&r_l->logon.info1, flags, pdc_status);
+ r_l->status = NT_STATUS_OK;
+ break;
+ default:
+ DEBUG(2,("init_r_logon_ctrl: unsupported switch value %d\n",
+ r_l->switch_value));
+ r_l->ptr = 0; /* undocumented pointer */
+
+ /* take a guess at an error code... */
+ r_l->status = NT_STATUS_INVALID_INFO_CLASS;
+ break;
+ }
+}
+
+/*******************************************************************
+ Reads or writes an NET_R_LOGON_CTRL structure.
+********************************************************************/
+
+BOOL net_io_r_logon_ctrl(char *desc, NET_R_LOGON_CTRL *r_l, prs_struct *ps,
+ int depth)
+{
+ prs_debug(ps, depth, desc, "net_io_r_logon_ctrl");
+ depth++;
+
+ if(!prs_uint32("switch_value ", ps, depth, &r_l->switch_value))
+ return False;
+ if(!prs_uint32("ptr ", ps, depth, &r_l->ptr))
+ return False;
+
+ if (r_l->ptr != 0) {
+ switch (r_l->switch_value) {
+ case 1:
+ if(!net_io_netinfo_1("", &r_l->logon.info1, ps, depth))
+ return False;
+ break;
+ default:
+ DEBUG(2,("net_io_r_logon_ctrl: unsupported switch value %d\n",
+ r_l->switch_value));
+ break;
+ }
+ }
+
+ if(!prs_ntstatus("status ", ps, depth, &r_l->status))
return False;
return True;
{
int i = 0;
- DEBUG(5,("make_r_trust_dom\n"));
+ DEBUG(5,("init_r_trust_dom\n"));
for (i = 0; i < MAX_TRUST_DOMS; i++) {
r_t->uni_trust_dom_name[i].uni_str_len = 0;
r_t->uni_trust_dom_name[i].undoc = 0x1;
}
- r_t->status = 0;
+ r_t->status = NT_STATUS_OK;
}
/*******************************************************************
return False;
}
- if(!prs_uint32("status", ps, depth, &r_t->status))
+ if(!prs_ntstatus("status", ps, depth, &r_t->status))
return False;
#endif
return True;
char *logon_srv, char *logon_clnt,
DOM_CHAL *clnt_chal)
{
- DEBUG(5,("make_q_req_chal: %d\n", __LINE__));
+ DEBUG(5,("init_q_req_chal: %d\n", __LINE__));
q_c->undoc_buffer = 1; /* don't know what this buffer is */
memcpy(q_c->clnt_chal.data, clnt_chal->data, sizeof(clnt_chal->data));
- DEBUG(5,("make_q_req_chal: %d\n", __LINE__));
+ DEBUG(5,("init_q_req_chal: %d\n", __LINE__));
}
/*******************************************************************
if(!smb_io_chal("", &r_c->srv_chal, ps, depth)) /* server challenge */
return False;
- if(!prs_uint32("status", ps, depth, &r_c->status))
+ if(!prs_ntstatus("status", ps, depth, &r_c->status))
return False;
return True;
if(!smb_io_chal("", &r_a->srv_chal, ps, depth)) /* server challenge */
return False;
- if(!prs_uint32("status", ps, depth, &r_a->status))
+ if(!prs_ntstatus("status", ps, depth, &r_a->status))
return False;
return True;
if(!net_io_neg_flags("", &r_a->srv_flgs, ps, depth))
return False;
- if(!prs_uint32("status", ps, depth, &r_a->status))
+ if(!prs_ntstatus("status", ps, depth, &r_a->status))
return False;
return True;
Inits a NET_Q_SRV_PWSET.
********************************************************************/
-void init_q_srv_pwset(NET_Q_SRV_PWSET *q_s, char *logon_srv, char *acct_name,
- uint16 sec_chan, char *comp_name, DOM_CRED *cred, char nt_cypher[16])
+void init_q_srv_pwset(NET_Q_SRV_PWSET *q_s, char *logon_srv, char *sess_key, char *acct_name,
+ uint16 sec_chan, char *comp_name, DOM_CRED *cred, uchar hashed_mach_pwd[16])
{
- DEBUG(5,("make_q_srv_pwset\n"));
+ unsigned char nt_cypher[16];
+
+ DEBUG(5,("init_q_srv_pwset\n"));
+
+ /* Process the new password. */
+ cred_hash3( nt_cypher, hashed_mach_pwd, sess_key, 1);
init_clnt_info(&q_s->clnt_id, logon_srv, acct_name, sec_chan, comp_name, cred);
if(!smb_io_cred("", &r_s->srv_cred, ps, depth)) /* server challenge */
return False;
- if(!prs_uint32("status", ps, depth, &r_s->status))
+ if(!prs_ntstatus("status", ps, depth, &r_s->status))
return False;
return True;
unsigned char lm_owf[16];
unsigned char nt_owf[16];
- DEBUG(5,("make_id_info1: %d\n", __LINE__));
+ DEBUG(5,("init_id_info1: %d\n", __LINE__));
id->ptr_id_info1 = 1;
memcpy(key, sess_key, 8);
memcpy(lm_owf, lm_cypher, 16);
- SamOEMhash(lm_owf, key, False);
+ SamOEMhash(lm_owf, key, 16);
memcpy(nt_owf, nt_cypher, 16);
- SamOEMhash(nt_owf, key, False);
+ SamOEMhash(nt_owf, key, 16);
#ifdef DEBUG_PASSWORD
DEBUG(100,("encrypt of lm owf password:"));
hashes to anyone who has compromised the secure channel. JRA.
********************************************************************/
-void init_id_info2(NET_ID_INFO_2 *id, char *domain_name,
- uint32 param_ctrl, uint32 log_id_low, uint32 log_id_high,
- char *user_name, char *wksta_name,
- unsigned char lm_challenge[8],
- unsigned char *lm_chal_resp,
- unsigned char *nt_chal_resp)
+void init_id_info2(NET_ID_INFO_2 * id, const char *domain_name,
+ uint32 param_ctrl,
+ uint32 log_id_low, uint32 log_id_high,
+ const char *user_name, const char *wksta_name,
+ const uchar lm_challenge[8],
+ const uchar * lm_chal_resp, int lm_chal_resp_len,
+ const uchar * nt_chal_resp, int nt_chal_resp_len)
{
int len_domain_name = strlen(domain_name);
int len_user_name = strlen(user_name );
int len_wksta_name = strlen(wksta_name );
- int nt_chal_resp_len = ((nt_chal_resp != NULL) ? 24 : 0);
- int lm_chal_resp_len = ((lm_chal_resp != NULL) ? 24 : 0);
unsigned char lm_owf[24];
- unsigned char nt_owf[24];
+ unsigned char nt_owf[128];
DEBUG(5,("init_id_info2: %d\n", __LINE__));
if (nt_chal_resp) {
/* oops. can only send what-ever-it-is direct */
- memcpy(nt_owf, nt_chal_resp, 24);
+ memcpy(nt_owf, nt_chal_resp, MIN(sizeof(nt_owf), nt_chal_resp_len));
nt_chal_resp = nt_owf;
}
if (lm_chal_resp) {
/* oops. can only send what-ever-it-is direct */
- memcpy(lm_owf, lm_chal_resp, 24);
+ memcpy(lm_owf, lm_chal_resp, MIN(sizeof(lm_owf), lm_chal_resp_len));
lm_chal_resp = lm_owf;
}
memcpy(id->lm_chal, lm_challenge, sizeof(id->lm_chal));
- init_str_hdr(&id->hdr_nt_chal_resp, 24, nt_chal_resp_len, (nt_chal_resp != NULL) ? 1 : 0);
- init_str_hdr(&id->hdr_lm_chal_resp, 24, lm_chal_resp_len, (lm_chal_resp != NULL) ? 1 : 0);
+ init_str_hdr(&id->hdr_nt_chal_resp, nt_chal_resp_len, nt_chal_resp_len, (nt_chal_resp != NULL) ? 1 : 0);
+ init_str_hdr(&id->hdr_lm_chal_resp, lm_chal_resp_len, lm_chal_resp_len, (lm_chal_resp != NULL) ? 1 : 0);
init_unistr2(&id->uni_domain_name, domain_name, len_domain_name);
init_unistr2(&id->uni_user_name, user_name, len_user_name);
init_unistr2(&id->uni_wksta_name, wksta_name, len_wksta_name);
- init_string2(&id->nt_chal_resp, (char *)nt_chal_resp, nt_chal_resp_len);
- init_string2(&id->lm_chal_resp, (char *)lm_chal_resp, lm_chal_resp_len);
+ init_string2(&id->nt_chal_resp, (const char *)nt_chal_resp, nt_chal_resp_len, nt_chal_resp_len);
+ init_string2(&id->lm_chal_resp, (const char *)lm_chal_resp, lm_chal_resp_len, lm_chal_resp_len);
+
}
/*******************************************************************
{
DEBUG(5,("init_sam_info: %d\n", __LINE__));
- init_clnt_info2(&(sam->client), logon_srv, comp_name, clnt_cred);
+ init_clnt_info2(&sam->client, logon_srv, comp_name, clnt_cred);
if (rtn_cred != NULL) {
sam->ptr_rtn_cred = 1;
}
/*************************************************************************
- Init
+ Inits a NET_USER_INFO_3 structure.
+
+ This is a network logon reply packet, and contains much information about
+ the user. This information is passed as a (very long) paramater list
+ to avoid having to link in the PASSDB code to every program that deals
+ with this file.
*************************************************************************/
-void init_net_user_info3(TALLOC_CTX *ctx, NET_USER_INFO_3 *usr, SAM_ACCOUNT *sampw,
+void init_net_user_info3(TALLOC_CTX *ctx, NET_USER_INFO_3 *usr,
+ uint32 user_rid,
+ uint32 group_rid,
+
+ const char* user_name,
+ const char* full_name,
+ const char* home_dir,
+ const char* dir_drive,
+ const char* logon_script,
+ const char* profile_path,
+
+ time_t unix_logon_time,
+ time_t unix_logoff_time,
+ time_t unix_kickoff_time,
+ time_t unix_pass_last_set_time,
+ time_t unix_pass_can_change_time,
+ time_t unix_pass_must_change_time,
+
uint16 logon_count, uint16 bad_pw_count,
uint32 num_groups, DOM_GID *gids,
- uint32 user_flgs, char *sess_key,
+ uint32 user_flgs, uchar *sess_key,
char *logon_srv, char *logon_dom,
DOM_SID *dom_sid, char *other_sids)
{
int len_user_name, len_full_name, len_home_dir,
len_dir_drive, len_logon_script, len_profile_path;
- char* user_name = pdb_get_username(sampw);
- char* full_name = pdb_get_fullname(sampw);
- char* home_dir = pdb_get_homedir(sampw);
- char* dir_drive = pdb_get_dirdrive(sampw);
- char* logon_script = pdb_get_logon_script(sampw);
- char* profile_path = pdb_get_profile_path(sampw);
-
int len_logon_srv = strlen(logon_srv);
int len_logon_dom = strlen(logon_dom);
/* Create NTTIME structs */
- unix_to_nt_time (&logon_time, pdb_get_logon_time(sampw));
- unix_to_nt_time (&logoff_time, pdb_get_logoff_time(sampw));
- unix_to_nt_time (&kickoff_time, pdb_get_kickoff_time(sampw));
- unix_to_nt_time (&pass_last_set_time, pdb_get_pass_last_set_time(sampw));
- unix_to_nt_time (&pass_can_change_time, pdb_get_pass_can_change_time(sampw));
- unix_to_nt_time (&pass_must_change_time,pdb_get_pass_must_change_time(sampw));
+ unix_to_nt_time (&logon_time, unix_logon_time);
+ unix_to_nt_time (&logoff_time, unix_logoff_time);
+ unix_to_nt_time (&kickoff_time, unix_kickoff_time);
+ unix_to_nt_time (&pass_last_set_time, unix_pass_last_set_time);
+ unix_to_nt_time (&pass_can_change_time, unix_pass_can_change_time);
+ unix_to_nt_time (&pass_must_change_time, unix_pass_must_change_time);
usr->logon_time = logon_time;
usr->logoff_time = logoff_time;
usr->logon_count = logon_count;
usr->bad_pw_count = bad_pw_count;
- usr->user_id = pdb_get_user_rid(sampw);
- usr->group_id = pdb_get_group_rid(sampw);
+ usr->user_rid = user_rid;
+ usr->group_rid = group_rid;
usr->num_groups = num_groups;
+
usr->buffer_groups = 1; /* indicates fill in groups, below, even if there are none */
usr->user_flgs = user_flgs;
usr->num_groups2 = num_groups;
- if (num_groups > 0) {
- usr->gids = (DOM_GID *)talloc_zero(ctx,sizeof(DOM_GID) * num_groups);
- if (usr->gids == NULL)
- return;
- for (i = 0; i < num_groups; i++)
- usr->gids[i] = gids[i];
- }
+ usr->gids = (DOM_GID *)talloc_zero(ctx,sizeof(DOM_GID) * (num_groups));
+ if (usr->gids == NULL && num_groups>0)
+ return;
+ for (i = 0; i < num_groups; i++)
+ usr->gids[i] = gids[i];
+
init_unistr2(&usr->uni_logon_srv, logon_srv, len_logon_srv);
init_unistr2(&usr->uni_logon_dom, logon_dom, len_logon_dom);
if (usr->ptr_user_info == 0)
return True;
- if(!smb_io_time("time", &usr->logon_time, ps, depth)) /* logon time */
+ if(!smb_io_time("logon time", &usr->logon_time, ps, depth)) /* logon time */
return False;
- if(!smb_io_time("time", &usr->logoff_time, ps, depth)) /* logoff time */
+ if(!smb_io_time("logoff time", &usr->logoff_time, ps, depth)) /* logoff time */
return False;
- if(!smb_io_time("time", &usr->kickoff_time, ps, depth)) /* kickoff time */
+ if(!smb_io_time("kickoff time", &usr->kickoff_time, ps, depth)) /* kickoff time */
return False;
- if(!smb_io_time("time", &usr->pass_last_set_time, ps, depth)) /* password last set time */
+ if(!smb_io_time("last set time", &usr->pass_last_set_time, ps, depth)) /* password last set time */
return False;
- if(!smb_io_time("time", &usr->pass_can_change_time , ps, depth)) /* password can change time */
+ if(!smb_io_time("can change time", &usr->pass_can_change_time , ps, depth)) /* password can change time */
return False;
- if(!smb_io_time("time", &usr->pass_must_change_time, ps, depth)) /* password must change time */
+ if(!smb_io_time("must change time", &usr->pass_must_change_time, ps, depth)) /* password must change time */
return False;
- if(!smb_io_unihdr("unihdr", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
+ if(!smb_io_unihdr("hdr_user_name", &usr->hdr_user_name, ps, depth)) /* username unicode string header */
return False;
- if(!smb_io_unihdr("unihdr", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
+ if(!smb_io_unihdr("hdr_full_name", &usr->hdr_full_name, ps, depth)) /* user's full name unicode string header */
return False;
- if(!smb_io_unihdr("unihdr", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
+ if(!smb_io_unihdr("hdr_logon_script", &usr->hdr_logon_script, ps, depth)) /* logon script unicode string header */
return False;
- if(!smb_io_unihdr("unihdr", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
+ if(!smb_io_unihdr("hdr_profile_path", &usr->hdr_profile_path, ps, depth)) /* profile path unicode string header */
return False;
- if(!smb_io_unihdr("unihdr", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
+ if(!smb_io_unihdr("hdr_home_dir", &usr->hdr_home_dir, ps, depth)) /* home directory unicode string header */
return False;
- if(!smb_io_unihdr("unihdr", &usr->hdr_dir_drive, ps, depth)) /* home directory drive unicode string header */
+ if(!smb_io_unihdr("hdr_dir_drive", &usr->hdr_dir_drive, ps, depth)) /* home directory drive unicode string header */
return False;
if(!prs_uint16("logon_count ", ps, depth, &usr->logon_count)) /* logon count */
if(!prs_uint16("bad_pw_count ", ps, depth, &usr->bad_pw_count)) /* bad password count */
return False;
- if(!prs_uint32("user_id ", ps, depth, &usr->user_id)) /* User ID */
+ if(!prs_uint32("user_rid ", ps, depth, &usr->user_rid)) /* User RID */
return False;
- if(!prs_uint32("group_id ", ps, depth, &usr->group_id)) /* Group ID */
+ if(!prs_uint32("group_rid ", ps, depth, &usr->group_rid)) /* Group RID */
return False;
if(!prs_uint32("num_groups ", ps, depth, &usr->num_groups)) /* num groups */
return False;
if(!prs_uint8s(False, "user_sess_key", ps, depth, usr->user_sess_key, 16)) /* unused user session key */
return False;
- if(!smb_io_unihdr("unihdr", &usr->hdr_logon_srv, ps, depth)) /* logon server unicode string header */
+ if(!smb_io_unihdr("hdr_logon_srv", &usr->hdr_logon_srv, ps, depth)) /* logon server unicode string header */
return False;
- if(!smb_io_unihdr("unihdr", &usr->hdr_logon_dom, ps, depth)) /* logon domain unicode string header */
+ if(!smb_io_unihdr("hdr_logon_dom", &usr->hdr_logon_dom, ps, depth)) /* logon domain unicode string header */
return False;
if(!prs_uint32("buffer_dom_id ", ps, depth, &usr->buffer_dom_id)) /* undocumented logon domain id pointer */
}
}
- if(!smb_io_unistr2("unistr2", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
+ if(!smb_io_unistr2("uni_user_name", &usr->uni_user_name, usr->hdr_user_name.buffer, ps, depth)) /* username unicode string */
return False;
- if(!smb_io_unistr2("unistr2", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
+ if(!smb_io_unistr2("uni_full_name", &usr->uni_full_name, usr->hdr_full_name.buffer, ps, depth)) /* user's full name unicode string */
return False;
- if(!smb_io_unistr2("unistr2", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
+ if(!smb_io_unistr2("uni_logon_script", &usr->uni_logon_script, usr->hdr_logon_script.buffer, ps, depth)) /* logon script unicode string */
return False;
- if(!smb_io_unistr2("unistr2", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
+ if(!smb_io_unistr2("uni_profile_path", &usr->uni_profile_path, usr->hdr_profile_path.buffer, ps, depth)) /* profile path unicode string */
return False;
- if(!smb_io_unistr2("unistr2", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
+ if(!smb_io_unistr2("uni_home_dir", &usr->uni_home_dir, usr->hdr_home_dir.buffer, ps, depth)) /* home directory unicode string */
return False;
- if(!smb_io_unistr2("unistr2", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
+ if(!smb_io_unistr2("uni_dir_drive", &usr->uni_dir_drive, usr->hdr_dir_drive.buffer, ps, depth)) /* home directory drive unicode string */
return False;
if(!prs_align(ps))
return False;
}
- if(!smb_io_unistr2("unistr2", &usr->uni_logon_srv, usr->hdr_logon_srv.buffer, ps, depth)) /* logon server unicode string */
+ if(!smb_io_unistr2("uni_logon_srv", &usr->uni_logon_srv, usr->hdr_logon_srv.buffer, ps, depth)) /* logon server unicode string */
return False;
- if(!smb_io_unistr2("unistr2", &usr->uni_logon_dom, usr->hdr_logon_srv.buffer, ps, depth)) /* logon domain unicode string */
+ if(!smb_io_unistr2("uni_logon_dom", &usr->uni_logon_dom, usr->hdr_logon_srv.buffer, ps, depth)) /* logon domain unicode string */
return False;
if(!smb_io_dom_sid2("", &usr->dom_sid, ps, depth)) /* domain SID */
if(!prs_align(ps))
return False;
- if(!smb_io_sam_info("", &q_l->sam_id, ps, depth)) /* domain SID */
+ if(!smb_io_sam_info("", &q_l->sam_id, ps, depth))
return False;
if(!prs_uint16("validation_level", ps, depth, &q_l->validation_level))
if(!prs_uint32("auth_resp ", ps, depth, &r_l->auth_resp)) /* 1 - Authoritative response; 0 - Non-Auth? */
return False;
- if(!prs_uint32("status ", ps, depth, &r_l->status))
+ if(!prs_ntstatus("status ", ps, depth, &r_l->status))
return False;
if(!prs_align(ps))
if(!smb_io_cred("", &r_l->srv_creds, ps, depth)) /* server credentials. server time stamp appears to be ignored. */
return False;
- if(!prs_uint32("status ", ps, depth, &r_l->status))
+ 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)
+{
+ 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));
+
+ 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 = 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++;
+
+ 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(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_stamp(char *desc, SAM_DELTA_STAMP *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(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 (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth))
+ return False;
+ if (!smb_io_unihdr("hdr_unknown", &info->hdr_unknown, ps, depth))
+ return False;
+
+ if (ps->data_offset + 40 > ps->buffer_size)
+ return False;
+ ps->data_offset += 40;
+
+ 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_buffer4("buf_sec_desc", &info->buf_sec_desc,
+ info->hdr_sec_desc.buffer, ps, depth))
+ return False;
+ if (!smb_io_unistr2("buf_unknown", &info->buf_unknown,
+ info->hdr_unknown.buffer, ps, depth))
+ return False;
+
+ 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++;
+
+ 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_buffer4("buf_sec_desc", &info->buf_sec_desc,
+ info->hdr_sec_desc.buffer, ps, depth))
+ return False;
+
+ 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++;
+
+ 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_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++;
+
+ if (!smb_io_unihdr("hdr_acct_name", &info->hdr_acct_name, ps, depth))
+ return False;
+ if (!smb_io_unihdr("hdr_full_name", &info->hdr_full_name, ps, depth))
+ return False;
+
+ if (!prs_uint32("user_rid ", ps, depth, &info->user_rid))
+ return False;
+ if (!prs_uint32("group_rid", ps, depth, &info->group_rid))
+ return False;
+
+ if (!smb_io_unihdr("hdr_home_dir ", &info->hdr_home_dir, ps, depth))
+ return False;
+ if (!smb_io_unihdr("hdr_dir_drive", &info->hdr_dir_drive, ps, depth))
+ return False;
+ if (!smb_io_unihdr("hdr_logon_script", &info->hdr_logon_script, ps,
+ depth))
+ return False;
+
+ if (!smb_io_unihdr("hdr_acct_desc", &info->hdr_acct_desc, ps, depth))
+ return False;
+ if (!smb_io_unihdr("hdr_workstations", &info->hdr_workstations, ps,
+ depth))
+ return False;
+
+ if (!smb_io_time("logon_time", &info->logon_time, ps, depth))
+ return False;
+ if (!smb_io_time("logoff_time", &info->logoff_time, ps, depth))
+ return False;
+
+ if (!prs_uint32("logon_divs ", ps, depth, &info->logon_divs))
+ return False;
+ if (!prs_uint32("ptr_logon_hrs", ps, depth, &info->ptr_logon_hrs))
+ return False;
+
+ if (!prs_uint16("bad_pwd_count", ps, depth, &info->bad_pwd_count))
+ return False;
+ if (!prs_uint16("logon_count", ps, depth, &info->logon_count))
+ return False;
+ if (!smb_io_time("pwd_last_set_time", &info->pwd_last_set_time, ps,
+ depth))
+ return False;
+ if (!smb_io_time("acct_expiry_time", &info->acct_expiry_time, ps,
+ depth))
+ return False;
+
+ if (!prs_uint32("acb_info", ps, depth, &info->acb_info))
+ return False;
+ if (!prs_uint8s(False, "nt_pwd", ps, depth, info->nt_pwd, 16))
+ return False;
+ if (!prs_uint8s(False, "lm_pwd", ps, depth, info->lm_pwd, 16))
+ return False;
+ if (!prs_uint8("lm_pwd_present", ps, depth, &info->lm_pwd_present))
+ return False;
+ if (!prs_uint8("nt_pwd_present", ps, depth, &info->nt_pwd_present))
+ return False;
+ if (!prs_uint8("pwd_expired", ps, depth, &info->pwd_expired))
+ return False;
+
+ if (!smb_io_unihdr("hdr_comment", &info->hdr_comment, ps, depth))
+ return False;
+ if (!smb_io_unihdr("hdr_parameters", &info->hdr_parameters, ps,
+ depth))
+ return False;
+ if (!prs_uint16("country", ps, depth, &info->country))
+ return False;
+ if (!prs_uint16("codepage", ps, depth, &info->codepage))
+ return False;
+
+ if (!smb_io_bufhdr2("hdr_priv_data", &hdr_priv_data, ps, depth))
+ return False;
+ if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth))
+ return False;
+ if (!smb_io_unihdr("hdr_profile", &info->hdr_profile, ps, depth))
+ return False;
+
+ for (i = 0; i < 3; i++)
+ {
+ if (!smb_io_unihdr("hdr_reserved", &info->hdr_reserved[i],
+ ps, depth))
+ return False;
+ }
+
+ for (i = 0; i < 4; i++)
+ {
+ if (!prs_uint32("dw_reserved", ps, depth,
+ &info->dw_reserved[i]))
+ return False;
+ }
+
+ if (!smb_io_unistr2("uni_acct_name", &info->uni_acct_name,
+ info->hdr_acct_name.buffer, ps, depth))
+ return False;
+ prs_align(ps);
+ if (!smb_io_unistr2("uni_full_name", &info->uni_full_name,
+ info->hdr_full_name.buffer, ps, depth))
+ return False;
+ prs_align(ps);
+ if (!smb_io_unistr2("uni_home_dir ", &info->uni_home_dir,
+ info->hdr_home_dir.buffer, ps, depth))
+ return False;
+ prs_align(ps);
+ if (!smb_io_unistr2("uni_dir_drive", &info->uni_dir_drive,
+ info->hdr_dir_drive.buffer, ps, depth))
+ return False;
+ prs_align(ps);
+ if (!smb_io_unistr2("uni_logon_script", &info->uni_logon_script,
+ info->hdr_logon_script.buffer, ps, depth))
+ return False;
+ prs_align(ps);
+ if (!smb_io_unistr2("uni_acct_desc", &info->uni_acct_desc,
+ info->hdr_acct_desc.buffer, ps, depth))
+ return False;
+ prs_align(ps);
+ if (!smb_io_unistr2("uni_workstations", &info->uni_workstations,
+ info->hdr_workstations.buffer, ps, depth))
+ return False;
+ prs_align(ps);
+
+ if (!prs_uint32("unknown1", ps, depth, &info->unknown1))
+ return False;
+ if (!prs_uint32("unknown2", ps, depth, &info->unknown2))
+ return False;
+
+ if (!smb_io_buffer4("buf_logon_hrs", &info->buf_logon_hrs,
+ info->ptr_logon_hrs, ps, depth))
+ return False;
+ prs_align(ps);
+ if (!smb_io_unistr2("uni_comment", &info->uni_comment,
+ info->hdr_comment.buffer, ps, depth))
+ return False;
+ prs_align(ps);
+ if (!smb_io_unistr2("uni_parameters", &info->uni_parameters,
+ info->hdr_parameters.buffer, ps, depth))
+ return False;
+ prs_align(ps);
+ if (hdr_priv_data.buffer != 0)
+ {
+ int old_offset = 0;
+ uint32 len = 0x44;
+ if (!prs_uint32("pwd_len", ps, depth, &len))
+ return False;
+ old_offset = ps->data_offset;
+ if (len == 0x44)
+ {
+ if (ps->io)
+ {
+ /* reading */
+ if (!prs_hash1(ps, ps->data_offset, sess_key))
+ return False;
+ }
+ if (!net_io_sam_passwd_info("pass", &info->pass,
+ ps, depth))
+ return False;
+
+ if (!ps->io)
+ {
+ /* writing */
+ if (!prs_hash1(ps, old_offset, sess_key))
+ return False;
+ }
+ }
+ if (old_offset + len > ps->buffer_size)
+ return False;
+ ps->data_offset = old_offset + len;
+ }
+ if (!smb_io_buffer4("buf_sec_desc", &info->buf_sec_desc,
+ info->hdr_sec_desc.buffer, ps, depth))
+ return False;
+ prs_align(ps);
+ if (!smb_io_unistr2("uni_profile", &info->uni_profile,
+ info->hdr_profile.buffer, ps, depth))
+ return False;
+
+ 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);
+ if (!prs_uint32("ptr_rids ", ps, depth, &info->ptr_rids))
+ return False;
+ if (!prs_uint32("ptr_attribs", ps, depth, &info->ptr_attribs))
+ return False;
+ if (!prs_uint32("num_members", ps, depth, &info->num_members))
+ return False;
+
+ if (ps->data_offset + 16 > ps->buffer_size)
+ return False;
+ ps->data_offset += 16;
+
+ if (info->ptr_rids != 0)
+ {
+ if (!prs_uint32("num_members2", ps, depth,
+ &info->num_members2))
+ return False;
+
+ 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);
+ if (!prs_uint32(tmp, ps, depth, &info->rids[i]))
+ return False;
+ }
+ }
+
+ if (info->ptr_attribs != 0)
+ {
+ if (!prs_uint32("num_members3", ps, depth,
+ &info->num_members3))
+ return False;
+ 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);
+ if (!prs_uint32(tmp, ps, depth, &info->attribs[i]))
+ return False;
+ }
+ }
+
+ 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++;
+
+ if (!smb_io_unihdr("hdr_als_name", &info->hdr_als_name, ps, depth))
+ return False;
+ if (!prs_uint32("als_rid", ps, depth, &info->als_rid))
+ return False;
+ if (!smb_io_bufhdr2("hdr_sec_desc", &info->hdr_sec_desc, ps, depth))
+ return False;
+ if (!smb_io_unihdr("hdr_als_desc", &info->hdr_als_desc, ps, depth))
+ return False;
+
+ if (ps->data_offset + 40 > ps->buffer_size)
+ return False;
+ ps->data_offset += 40;
+
+ if (!smb_io_unistr2("uni_als_name", &info->uni_als_name,
+ info->hdr_als_name.buffer, ps, depth))
+ return False;
+ if (!smb_io_buffer4("buf_sec_desc", &info->buf_sec_desc,
+ info->hdr_sec_desc.buffer, ps, depth))
+ return False;
+ if (!smb_io_unistr2("uni_als_desc", &info->uni_als_desc,
+ info->hdr_als_name.buffer, ps, depth))
+ return False;
+
+ 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);
+ if (!prs_uint32("num_members", ps, depth, &info->num_members))
+ return False;
+ if (!prs_uint32("ptr_members", ps, depth, &info->ptr_members))
+ return False;
+
+ if (info->ptr_members != 0)
+ {
+ if (ps->data_offset + 16 > ps->buffer_size)
+ return False;
+ ps->data_offset += 16;
+
+ if (!prs_uint32("num_sids", ps, depth, &info->num_sids))
+ return False;
+ 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);
+ if (!prs_uint32(tmp, ps, depth, &info->ptr_sids[i]))
+ return False;
+ }
+
+ 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);
+ if (!smb_io_dom_sid2(tmp, &info->sids[i],
+ ps, depth))
+ return False;
+ }
+ }
+ }
+
+ return True;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+static BOOL net_io_sam_dom_info(char *desc, SAM_DELTA_DOM *info,
+ prs_struct *ps, int depth)
+{
+ int i;
+
+ prs_debug(ps, depth, desc, "net_io_sam_dom_info");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if (!prs_uint32("unknown1", ps, depth, &info->unknown1))
+ return False;
+ if (!prs_uint32("unknown2", ps, depth, &info->unknown2))
+ return False;
+ if (!prs_uint32("unknown3", ps, depth, &info->unknown3))
+ return False;
+ if (!prs_uint32("unknown4", ps, depth, &info->unknown4))
+ return False;
+ if (!prs_uint32("count1", ps, depth, &info->count1))
+ return False;
+ if (!prs_uint32("ptr1", ps, depth, &info->ptr1))
+ return False;
+
+ if (!prs_uint16("count2", ps, depth, &info->count2))
+ return False;
+ if (!prs_uint16("count3", ps, depth, &info->count3))
+ return False;
+
+ if (!prs_uint32("ptr2", ps, depth, &info->ptr2))
+ return False;
+ if (!prs_uint32("ptr3", ps, depth, &info->ptr3))
+ return False;
+
+ if (!prs_uint32("unknown4b", ps, depth, &info->unknown4b))
+ return False;
+ if (!prs_uint32("unknown5", ps, depth, &info->unknown5))
+ 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 (!prs_uint32("unknown9", ps, depth, &info->unknown9))
+ return False;
+ if (!prs_uint32("unknown10", ps, depth, &info->unknown10))
+ return False;
+ if (!prs_uint32("unknown11", ps, depth, &info->unknown11))
+ return False;
+ if (!prs_uint32("unknown12", ps, depth, &info->unknown12))
+ return False;
+
+ if (!prs_uint32("unknown13", ps, depth, &info->unknown13))
+ return False;
+ if (!prs_uint32("unknown14", ps, depth, &info->unknown14))
+ return False;
+ if (!prs_uint32("unknown15", ps, depth, &info->unknown15))
+ return False;
+ if (!prs_uint32("unknown16", ps, depth, &info->unknown16))
+ return False;
+ if (!prs_uint32("unknown17", ps, depth, &info->unknown17))
+ return False;
+
+ for (i=0; i<info->count2; i++)
+ if (!prs_uint32("unknown18", ps, depth, &info->unknown18))
+ return False;
+
+ if (!prs_uint32("unknown19", ps, depth, &info->unknown19))
+ return False;
+
+ for (i=0; i<info->count1; i++)
+ if (!prs_uint32("unknown20", ps, depth, &info->unknown20))
+ return False;
+
+ if (!prs_uint32("ptr4", ps, depth, &info->ptr4))
+ return False;
+
+ if (!smb_io_unistr2("domain_name", &info->domain_name, True, ps, depth))
+ return False;
+
+ if(!smb_io_dom_sid2("domain_sid", &info->domain_sid, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+static BOOL net_io_sam_unk0e_info(char *desc, SAM_DELTA_UNK0E *info,
+ prs_struct *ps, int depth)
+{
+ int i;
+
+ prs_debug(ps, depth, desc, "net_io_sam_unk0e_info");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("buf_size", ps, depth, &info->buf_size))
+ return False;
+
+ if(!sec_io_desc("sec_desc", &info->sec_desc, ps, depth))
+ return False;
+
+ if(!smb_io_dom_sid2("sid", &info->sid, ps, depth))
+ return False;
+
+ if(!smb_io_unihdr("hdr_domain", &info->hdr_domain, ps, depth))
+ return False;
+
+ if(!prs_uint32("unknown0", ps, depth, &info->unknown0))
+ return False;
+ if(!prs_uint32("unknown1", ps, depth, &info->unknown1))
+ return False;
+ if(!prs_uint32("unknown2", ps, depth, &info->unknown2))
+ return False;
+
+ if(!prs_uint32("buf_size2", ps, depth, &info->buf_size2))
+ return False;
+ if(!prs_uint32("ptr", ps, depth, &info->ptr))
+ return False;
+
+ for (i=0; i<12; i++)
+ if(!prs_uint32("unknown3", ps, depth, &info->unknown3))
+ return False;
+
+ if (!smb_io_unistr2("domain", &info->domain, True, ps, depth))
+ return False;
+
+ return True;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+static BOOL net_io_sam_unk12_info(char *desc, SAM_DELTA_UNK12 *info,
+ prs_struct *ps, int depth)
+{
+ int i;
+
+ prs_debug(ps, depth, desc, "net_io_sam_unk12_info");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("buf_size", ps, depth, &info->buf_size))
+ return False;
+
+ if(!sec_io_desc("sec_desc", &info->sec_desc, ps, depth))
+ return False;
+
+ if (!smb_io_unistr2("secret", &info->secret, True, ps, depth))
+ return False;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("count1", ps, depth, &info->count1))
+ return False;
+ if(!prs_uint32("count2", ps, depth, &info->count2))
+ return False;
+ if(!prs_uint32("ptr", ps, depth, &info->ptr))
+ return False;
+
+
+ if(!smb_io_time("time1", &info->time1, ps, depth)) /* logon time */
+ return False;
+ if(!prs_uint32("count3", ps, depth, &info->count3))
+ return False;
+ if(!prs_uint32("count4", ps, depth, &info->count4))
+ return False;
+ if(!prs_uint32("ptr2", ps, depth, &info->ptr2))
+ return False;
+ if(!smb_io_time("time2", &info->time2, ps, depth)) /* logon time */
+ return False;
+ if(!prs_uint32("unknow1", ps, depth, &info->unknow1))
+ return False;
+
+
+ if(!prs_uint32("buf_size2", ps, depth, &info->buf_size2))
+ return False;
+ if(!prs_uint32("ptr3", ps, depth, &info->ptr3))
+ return False;
+ for(i=0; i<12; i++)
+ if(!prs_uint32("unknow2", ps, depth, &info->unknow2))
+ return False;
+
+ if(!prs_uint32("chal_len", ps, depth, &info->chal_len))
+ return False;
+ if(!prs_uint32("reserved1", ps, depth, &info->reserved1))
+ return False;
+ if(!prs_uint32("chal_len2", ps, depth, &info->chal_len2))
+ return False;
+
+ if(!prs_uint8s (False, "chal", ps, depth, info->chal, info->chal_len2))
+ return False;
+
+ if(!prs_uint32("key_len", ps, depth, &info->key_len))
+ return False;
+ if(!prs_uint32("reserved2", ps, depth, &info->reserved2))
+ return False;
+ if(!prs_uint32("key_len2", ps, depth, &info->key_len2))
+ return False;
+
+ if(!prs_uint8s (False, "key", ps, depth, info->key, info->key_len2))
+ return False;
+
+
+ if(!prs_uint32("buf_size3", ps, depth, &info->buf_size3))
+ return False;
+
+ if(!sec_io_desc("sec_desc2", &info->sec_desc2, ps, depth))
return False;
+
+ return True;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+static BOOL net_io_sam_privs_info(char *desc, SAM_DELTA_PRIVS *info,
+ prs_struct *ps, int depth)
+{
+ int i;
+
+ prs_debug(ps, depth, desc, "net_io_sam_privs_info");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("buf_size", ps, depth, &info->buf_size))
+ return False;
+
+ if(!sec_io_desc("sec_desc", &info->sec_desc, ps, depth))
+ return False;
+
+ if(!smb_io_dom_sid2("sid", &info->sid, ps, depth))
+ return False;
+
+ if(!prs_uint32("priv_count", ps, depth, &info->priv_count))
+ return False;
+ if(!prs_uint32("reserved1", ps, depth, &info->reserved1))
+ return False;
+
+ if(!prs_uint32("ptr1", ps, depth, &info->ptr1))
+ return False;
+ if(!prs_uint32("ptr2", ps, depth, &info->ptr2))
+ return False;
+
+ if(!prs_uint32("unknown1", ps, depth, &info->unknown1))
+ return False;
+ if(!prs_uint32("unknown2", ps, depth, &info->unknown2))
+ return False;
+ if(!prs_uint32("unknown3", ps, depth, &info->unknown3))
+ return False;
+ if(!prs_uint32("unknown4", ps, depth, &info->unknown4))
+ return False;
+ if(!prs_uint32("unknown5", ps, depth, &info->unknown5))
+ 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(!prs_uint32("unknown9", ps, depth, &info->unknown9))
+ return False;
+
+ if(!prs_uint32("buf_size2", ps, depth, &info->buf_size2))
+ return False;
+ if(!prs_uint32("ptr3", ps, depth, &info->ptr3))
+ return False;
+
+ for (i=0; i<12; i++)
+ if(!prs_uint32("unknown10", ps, depth, &info->unknown10))
+ return False;
+
+ if(!prs_uint32("attribute_count", ps, depth, &info->attribute_count))
+ return False;
+
+ info->attributes = talloc(ps->mem_ctx, sizeof(uint32) * info->attribute_count);
+
+ for (i=0; i<info->attribute_count; i++)
+ if(!prs_uint32("attributes", ps, depth, &info->attributes[i]))
+ return False;
+
+ if(!prs_uint32("privlist_count", ps, depth, &info->privlist_count))
+ return False;
+
+ info->hdr_privslist = talloc(ps->mem_ctx, sizeof(UNIHDR) * info->privlist_count);
+ info->uni_privslist = talloc(ps->mem_ctx, sizeof(UNISTR2) * info->privlist_count);
+
+ for (i=0; i<info->privlist_count; i++)
+ if(!smb_io_unihdr("hdr_privslist", &info->hdr_privslist[i], ps, depth))
+ return False;
+
+ for (i=0; i<info->privlist_count; i++)
+ if (!smb_io_unistr2("uni_privslist", &info->uni_privslist[i], True, ps, depth))
+ return False;
+
+ 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:
+ if (!net_io_sam_delta_stamp("", &delta->stamp, ps, depth))
+ return False;
+ break;
+
+ case SAM_DELTA_DOMAIN_INFO:
+ if (!net_io_sam_domain_info("", &delta->domain_info, ps, depth))
+ return False;
+ break;
+
+ case SAM_DELTA_GROUP_INFO:
+ if (!net_io_sam_group_info("", &delta->group_info, ps, depth))
+ return False;
+ break;
+
+ case SAM_DELTA_ACCOUNT_INFO:
+ if (!net_io_sam_account_info("", sess_key, &delta->account_info, ps, depth))
+ return False;
+ break;
+
+ case SAM_DELTA_GROUP_MEM:
+ if (!net_io_sam_group_mem_info("", &delta->grp_mem_info, ps, depth))
+ return False;
+ break;
+
+ case SAM_DELTA_ALIAS_INFO:
+ if (!net_io_sam_alias_info("", &delta->alias_info, ps, depth))
+ return False;
+ break;
+
+ case SAM_DELTA_DOM_INFO:
+ if (!net_io_sam_dom_info("", &delta->dom_info, ps, depth))
+ return False;
+ break;
+
+ case SAM_DELTA_ALIAS_MEM:
+ if (!net_io_sam_alias_mem_info("", &delta->als_mem_info, ps, depth))
+ return False;
+ break;
+
+ case SAM_DELTA_PRIVS_INFO:
+ if (!net_io_sam_privs_info("", &delta->privs_info, ps, depth))
+ return False;
+ break;
+
+ case SAM_DELTA_UNK0E_INFO:
+ if (!net_io_sam_unk0e_info("", &delta->unk0e_info, ps, depth))
+ return False;
+ break;
+
+ case SAM_DELTA_UNK12_INFO:
+ if (!net_io_sam_unk12_info("", &delta->unk12_info, ps, depth))
+ return False;
+ 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++;
+
+ if (!smb_io_cred("srv_creds", &r_s->srv_creds, ps, depth))
+ return False;
+ if (!prs_uint32("sync_context", ps, depth, &r_s->sync_context))
+ return False;
+
+ if (!prs_uint32("ptr_deltas", ps, depth, &r_s->ptr_deltas))
+ return False;
+ if (r_s->ptr_deltas != 0)
+ {
+ if (!prs_uint32("num_deltas ", ps, depth, &r_s->num_deltas))
+ return False;
+ if (!prs_uint32("ptr_deltas2", ps, depth, &r_s->ptr_deltas2))
+ return False;
+ if (r_s->ptr_deltas2 != 0)
+ {
+ if (!prs_uint32("num_deltas2", ps, depth,
+ &r_s->num_deltas2))
+ return False;
+
+ 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++)
+ {
+ if (!net_io_sam_delta_hdr("",
+ &r_s->hdr_deltas[i],
+ ps, depth))
+ return False;
+ }
+
+ 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++)
+ {
+ if (!net_io_sam_delta_ctr(
+ "", sess_key, &r_s->deltas[i],
+ r_s->hdr_deltas[i].type3,
+ ps, depth)) {
+ DEBUG(0, ("hmm, failed on i=%d\n", i));
+ return False;
+ }
+ }
+ }
+ }
+
+ prs_align(ps);
+ if (!prs_ntstatus("status", ps, depth, &(r_s->status)))
+ return False;
+
+ 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++;
+
+ 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_uint64("dom_mod_count", ps, depth, &q_s->dom_mod_count))
+ return False;
+ if (!prs_uint32("max_size", ps, depth, &q_s->max_size))
+ return False;
+
+ 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++;
+
+ if (!smb_io_cred("srv_creds", &r_s->srv_creds, ps, depth))
+ return False;
+ if (!prs_uint64("dom_mod_count", ps, depth, &r_s->dom_mod_count))
+ return False;
+
+ if (!prs_uint32("ptr_deltas", ps, depth, &r_s->ptr_deltas))
+ return False;
+ if (!prs_uint32("num_deltas", ps, depth, &r_s->num_deltas))
+ return False;
+ if (!prs_uint32("ptr_deltas2", ps, depth, &r_s->num_deltas2))
+ return False;
+
+ if (r_s->num_deltas2 != 0)
+ {
+ if (!prs_uint32("num_deltas2 ", ps, depth, &r_s->num_deltas2))
+ return False;
+
+ 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++)
+ {
+ if (!net_io_sam_delta_ctr(
+ "", sess_key,
+ &r_s->deltas[i],
+ r_s->hdr_deltas[i].type2,
+ ps, depth))
+
+ return False;
+ }
+ }
+ }
+
+ prs_align(ps);
+ if (!prs_ntstatus("status", ps, depth, &r_s->status))
+ return False;
+
return True;
}