summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h19
-rw-r--r--source3/include/rpc_netlogon.h23
-rw-r--r--source3/lib/domain_namemap.c2
-rw-r--r--source3/lib/sids.c2
-rw-r--r--source3/lib/util.c27
-rw-r--r--source3/lib/util_pwdb.c11
-rw-r--r--source3/libsmb/smbdes.c6
-rw-r--r--source3/passdb/smbpassfile.c2
-rw-r--r--source3/rpc_client/cli_netlogon.c50
-rw-r--r--source3/rpc_parse/parse_net.c143
-rw-r--r--source3/rpc_parse/parse_prs.c21
-rw-r--r--source3/rpcclient/cmd_netlogon.c11
-rw-r--r--source3/rpcclient/display.c88
-rw-r--r--source3/utils/smbpasswd.c26
14 files changed, 349 insertions, 82 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 4cea4b6cee..10d2054d1e 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -474,6 +474,7 @@ enum remote_arch_types get_remote_arch(void);
char *align4(char *q, char *base);
char *align2(char *q, char *base);
void out_ascii(FILE *f, unsigned char *buf,int len);
+void out_struct(FILE *f,char *buf1,int len, int per_line);
void out_data(FILE *f,char *buf1,int len, int per_line);
void print_asc(int level, unsigned char const *buf,int len);
void dump_data(int level, const char *buf1, int len);
@@ -1759,7 +1760,10 @@ BOOL cli_net_sam_logoff(struct cli_state *cli, uint16 nt_pipe_fnum, NET_ID_INFO_
BOOL cli_net_sam_sync(struct cli_state *cli, uint16 nt_pipe_fnum, uint32 database_id, uint32 *num_deltas, SAM_DELTA_HDR *hdr_deltas, SAM_DELTA_CTR *deltas);
BOOL change_trust_account_password(char *domain, char *remote_machine_list,
uint16 sec_chan);
-BOOL do_sam_sync(struct cli_state *cli);
+BOOL do_sam_sync(struct cli_state *cli,
+ SAM_DELTA_HDR hdr_deltas[MAX_SAM_DELTAS],
+ SAM_DELTA_CTR deltas [MAX_SAM_DELTAS],
+ uint32 *num_deltas);
/*The following definitions come from rpc_client/cli_pipe.c */
@@ -2247,7 +2251,8 @@ void make_sam_account_info(SAM_ACCOUNT_INFO *info, char *user_name,
char *full_name, uint32 user_rid, uint32 group_rid,
char *home_dir, char *dir_drive, char *logon_script,
char *acct_desc, uint32 acb_info, char *profile);
-void net_io_r_sam_sync(char *desc, NET_R_SAM_SYNC *r_s, prs_struct *ps, int depth);
+void net_io_r_sam_sync(char *desc, uint8 sess_key[16],
+ NET_R_SAM_SYNC *r_s, prs_struct *ps, int depth);
/*The following definitions come from rpc_parse/parse_prs.c */
@@ -2261,6 +2266,7 @@ void prs_align(prs_struct *ps);
BOOL prs_grow(prs_struct *ps);
BOOL prs_uint8(char *name, prs_struct *ps, int depth, uint8 *data8);
BOOL prs_uint16(char *name, prs_struct *ps, int depth, uint16 *data16);
+BOOL prs_hash1(prs_struct *ps, uint32 offset, uint8 sess_key[16]);
BOOL prs_uint32(char *name, prs_struct *ps, int depth, uint32 *data32);
BOOL prs_uint8s(BOOL charmode, char *name, prs_struct *ps, int depth, uint8 *data8s, int len);
BOOL prs_uint16s(BOOL charmode, char *name, prs_struct *ps, int depth, uint16 *data16s, int len);
@@ -3253,6 +3259,13 @@ void display_at_enum_info(FILE *out_hnd, enum action_type action,
void display_at_job_info(FILE *out_hnd, enum action_type action,
AT_JOB_INFO *job, fstring command);
void display_eventlog_eventrecord(FILE *out_hnd, enum action_type action, EVENTLOGRECORD *ev);
+void display_sam_sync_ctr(FILE *out_hnd, enum action_type action,
+ SAM_DELTA_HDR *delta,
+ SAM_DELTA_CTR *ctr);
+void display_sam_sync(FILE *out_hnd, enum action_type action,
+ SAM_DELTA_HDR *deltas,
+ SAM_DELTA_CTR *ctr,
+ uint32 num);
/*The following definitions come from rpcclient/rpcclient.c */
@@ -3316,7 +3329,7 @@ SMB_BIG_UINT sys_disk_free(char *path,SMB_BIG_UINT *bsize,SMB_BIG_UINT *dfree,SM
BOOL init_dfs_table(void);
int under_dfs(connection_struct *conn, const char *path,
- char *local_path, size_t path_len);
+ char *local_path, size_t local_plen);
/*The following definitions come from smbd/dir.c */
diff --git a/source3/include/rpc_netlogon.h b/source3/include/rpc_netlogon.h
index 2c02e96d18..6e28280dcc 100644
--- a/source3/include/rpc_netlogon.h
+++ b/source3/include/rpc_netlogon.h
@@ -447,6 +447,26 @@ typedef struct sam_group_info_info
} SAM_GROUP_INFO;
+/* SAM_PWD */
+typedef struct sam_passwd_info
+{
+ uint32 unk_0; /* 0x0000 0002 */
+
+ UNIHDR hdr_lm_pwd;
+ uint8 buf_lm_pwd[16];
+
+ uint32 ptr_1;
+
+ UNIHDR hdr_nt_pwd;
+ uint8 buf_nt_pwd[16];
+
+ uint32 ptr_2;
+ uint32 ptr_3;
+ uint32 ptr_4;
+ uint32 ptr_5;
+
+} SAM_PWD;
+
/* SAM_ACCOUNT_INFO (0x5) */
typedef struct sam_account_info_info
{
@@ -485,7 +505,6 @@ typedef struct sam_account_info_info
uint16 country;
uint16 codepage;
- BUFHDR2 hdr_priv_data;
BUFHDR2 hdr_sec_desc; /* security descriptor */
UNIHDR hdr_profile;
@@ -507,7 +526,7 @@ typedef struct sam_account_info_info
BUFFER4 buf_logon_hrs;
UNISTR2 uni_comment;
UNISTR2 uni_parameters;
- BUFFER4 buf_priv_data;
+ SAM_PWD pass;
BUFFER4 buf_sec_desc;
UNISTR2 uni_profile;
diff --git a/source3/lib/domain_namemap.c b/source3/lib/domain_namemap.c
index fb6ecf2acf..ed4325a4d7 100644
--- a/source3/lib/domain_namemap.c
+++ b/source3/lib/domain_namemap.c
@@ -891,6 +891,8 @@ static BOOL lookup_remote_ntname(const char *ntname, DOM_SID *sid, uint8 *type)
uint8 *types;
const char *names[1];
+ DEBUG(5,("lookup_remote_ntname: %s\n", ntname));
+
if (!cli_connect_serverlist(&cli, lp_passwordserver()))
{
return False;
diff --git a/source3/lib/sids.c b/source3/lib/sids.c
index 7eb968a435..c75168ee56 100644
--- a/source3/lib/sids.c
+++ b/source3/lib/sids.c
@@ -196,7 +196,7 @@ BOOL get_domain_sids(DOM_SID *sid3, DOM_SID *sid5, char *servers)
if (!cli_connect_serverlist(&cli, servers))
{
- DEBUG(0,("get_member_domain_sid: unable to initialise client connection.\n"));
+ DEBUG(0,("get_domain_sids: unable to initialise client connection.\n"));
return False;
}
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 8a9452ee00..9a4d0d9e25 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -2931,6 +2931,33 @@ void out_ascii(FILE *f, unsigned char *buf,int len)
}
}
+void out_struct(FILE *f,char *buf1,int len, int per_line)
+{
+ unsigned char *buf = (unsigned char *)buf1;
+ int i;
+
+ if (len<=0)
+ {
+ return;
+ }
+
+ fprintf(f, "{\n\t");
+ for (i=0;i<len;)
+ {
+ fprintf(f, "0x%02X",(int)buf[i]);
+ i++;
+ if (i != len)
+ {
+ fprintf(f, ", ");
+ }
+ if (i%per_line == 0 && i != len)
+ {
+ fprintf(f, "\n\t");
+ }
+ }
+ fprintf(f, "\n};\n");
+}
+
void out_data(FILE *f,char *buf1,int len, int per_line)
{
unsigned char *buf = (unsigned char *)buf1;
diff --git a/source3/lib/util_pwdb.c b/source3/lib/util_pwdb.c
index f78bdfff5d..0bf0cd9c4f 100644
--- a/source3/lib/util_pwdb.c
+++ b/source3/lib/util_pwdb.c
@@ -625,7 +625,16 @@ BOOL pwdb_initialise(BOOL is_server)
}
else
{
- if (!get_domain_sids(&global_member_sid, &global_sam_sid, global_myname))
+ char *srvs;
+ if (lp_server_role() == ROLE_DOMAIN_PDC)
+ {
+ srvs = global_myname;
+ }
+ else
+ {
+ srvs = lp_passwordserver();
+ }
+ if (!get_domain_sids(&global_member_sid, &global_sam_sid, srvs))
{
return False;
}
diff --git a/source3/libsmb/smbdes.c b/source3/libsmb/smbdes.c
index 579d0dd8b4..fa7d64cec8 100644
--- a/source3/libsmb/smbdes.c
+++ b/source3/libsmb/smbdes.c
@@ -365,6 +365,10 @@ void SamOEMhash( unsigned char *data, unsigned char *key, int val)
unsigned char index_j = 0;
unsigned char j = 0;
int ind;
+ int len = 0;
+ if (val == 1) len = 516;
+ if (val == 0) len = 16;
+ if (val == 2) len = 68;
for (ind = 0; ind < 256; ind++)
{
@@ -381,7 +385,7 @@ void SamOEMhash( unsigned char *data, unsigned char *key, int val)
s_box[ind] = s_box[j];
s_box[j] = tc;
}
- for( ind = 0; ind < (val ? 516 : 16); ind++)
+ for( ind = 0; ind < len; ind++)
{
unsigned char tc;
unsigned char t;
diff --git a/source3/passdb/smbpassfile.c b/source3/passdb/smbpassfile.c
index 0165d76488..ecf9efe303 100644
--- a/source3/passdb/smbpassfile.c
+++ b/source3/passdb/smbpassfile.c
@@ -52,6 +52,8 @@ static void get_trust_account_file_name( char *domain, char *name, char *mac_fil
pstrcat(mac_file, ".");
pstrcat(mac_file, name);
pstrcat(mac_file, ".mac");
+
+ DEBUG(5,("trust_account_file_name: %s\n", mac_file));
}
/************************************************************************
diff --git a/source3/rpc_client/cli_netlogon.c b/source3/rpc_client/cli_netlogon.c
index c7483677f0..188390ae54 100644
--- a/source3/rpc_client/cli_netlogon.c
+++ b/source3/rpc_client/cli_netlogon.c
@@ -505,7 +505,7 @@ BOOL cli_net_sam_sync(struct cli_state *cli, uint16 nt_pipe_fnum, uint32 databas
r_s.hdr_deltas = hdr_deltas;
r_s.deltas = deltas;
- net_io_r_sam_sync("", &r_s, &rbuf, 0);
+ net_io_r_sam_sync("", cli->sess_key, &r_s, &rbuf, 0);
ok = (rbuf.offset != 0);
if (ok && r_s.status != 0 && r_s.status != NT_STATUS_MORE_ENTRIES)
@@ -713,20 +713,19 @@ domain %s.\n", timestring(), domain));
return False;
}
-BOOL do_sam_sync(struct cli_state *cli)
+BOOL do_sam_sync(struct cli_state *cli,
+ SAM_DELTA_HDR hdr_deltas[MAX_SAM_DELTAS],
+ SAM_DELTA_CTR deltas [MAX_SAM_DELTAS],
+ uint32 *num_deltas)
{
uint16 nt_pipe_fnum;
BOOL res = True;
unsigned char trust_passwd[16];
- int i, j;
- SAM_DELTA_HDR hdr_deltas[MAX_SAM_DELTAS];
- SAM_DELTA_CTR deltas[MAX_SAM_DELTAS];
- uint32 num_deltas;
- fstring name;
- char *data;
+ *num_deltas = 0;
- DEBUG(2,("Attempting SAM synchronisation with PDC\n"));
+ DEBUG(2,("Attempting SAM sync with PDC, domain: %s name: %s\n",
+ cli->domain, global_myname));
res = res ? trust_get_passwd(trust_passwd, cli->domain, global_myname) : False;
@@ -736,10 +735,10 @@ BOOL do_sam_sync(struct cli_state *cli)
res = res ? cli_nt_setup_creds(cli, nt_pipe_fnum, cli->mach_acct,
trust_passwd, SEC_CHAN_BDC) : False;
- res = res ? cli_net_sam_sync(cli, nt_pipe_fnum, 0, &num_deltas, hdr_deltas, deltas) : False;
-
memset(trust_passwd, 0, 16);
+ res = res ? cli_net_sam_sync(cli, nt_pipe_fnum, 0, num_deltas, hdr_deltas, deltas) : False;
+
/* close the session */
cli_nt_session_close(cli, nt_pipe_fnum);
@@ -749,34 +748,7 @@ BOOL do_sam_sync(struct cli_state *cli)
return False;
}
- DEBUG(0, ("SAM synchronisation returned %d entries\n", num_deltas));
-
- for (i = 0; i < num_deltas; i++)
- {
- switch (hdr_deltas[i].type)
- {
- case 1:
- unistr2_to_ascii(name, &(deltas[i].domain_info.uni_dom_name), sizeof(fstring)-1);
- DEBUG(0, ("Domain: %s\n", name));
- break;
-
- case 2:
- unistr2_to_ascii(name, &(deltas[i].group_info.uni_grp_name), sizeof(fstring)-1);
- DEBUG(0, ("Group: %s\n", name));
- break;
-
- case 5:
- unistr2_to_ascii(name, &(deltas[i].account_info.uni_acct_name), sizeof(fstring)-1);
- DEBUG(0, ("Account: %s\n", name));
-
- data = deltas[i].account_info.buf_priv_data.buffer;
- for (j = 0; j < deltas[i].account_info.buf_priv_data.buf_len; j++)
- {
- snprintf(&name[2*j], 3, "%02X", data[j]);
- }
- DEBUG(0, ("Private Data: %s\n", name));
- }
- }
+ DEBUG(0, ("SAM synchronisation returned %d entries\n", *num_deltas));
return True;
}
diff --git a/source3/rpc_parse/parse_net.c b/source3/rpc_parse/parse_net.c
index 271ac3afeb..b74fb7ab0d 100644
--- a/source3/rpc_parse/parse_net.c
+++ b/source3/rpc_parse/parse_net.c
@@ -1288,7 +1288,6 @@ void make_sam_account_info(SAM_ACCOUNT_INFO *info, char *user_name,
make_uni_hdr(&(info->hdr_workstations), 0);
make_uni_hdr(&(info->hdr_comment), 0);
make_uni_hdr(&(info->hdr_parameters), 0);
- make_bufhdr2(&(info->hdr_priv_data), 0, 0, 0);
make_bufhdr2(&(info->hdr_sec_desc), 0, 0, 0);
info->user_rid = user_rid;
@@ -1326,8 +1325,37 @@ void make_sam_account_info(SAM_ACCOUNT_INFO *info, char *user_name,
/*******************************************************************
reads or writes a structure.
********************************************************************/
-static void net_io_sam_account_info(char *desc, SAM_ACCOUNT_INFO *info, prs_struct *ps, int depth)
+static void net_io_sam_passwd_info(char *desc, SAM_PWD *pwd,
+ prs_struct *ps, int depth)
{
+ if (pwd == NULL) return;
+
+ 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);
+
+ prs_uint32("ptr_1 ", ps, depth, &(pwd->ptr_1 ));
+
+ 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);
+
+ prs_uint32("ptr_2 ", ps, depth, &(pwd->ptr_2 ));
+ prs_uint32("ptr_3 ", ps, depth, &(pwd->ptr_3 ));
+ prs_uint32("ptr_4 ", ps, depth, &(pwd->ptr_4 ));
+ prs_uint32("ptr_5 ", ps, depth, &(pwd->ptr_5 ));
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+static void net_io_sam_account_info(char *desc, uint8 sess_key[16],
+ SAM_ACCOUNT_INFO *info, prs_struct *ps, int depth)
+{
+ BUFHDR2 hdr_priv_data;
int i;
if (info == NULL) return;
@@ -1370,7 +1398,7 @@ static void net_io_sam_account_info(char *desc, SAM_ACCOUNT_INFO *info, prs_stru
prs_uint16("country" , ps, depth, &(info->country ));
prs_uint16("codepage", ps, depth, &(info->codepage));
- smb_io_bufhdr2("hdr_priv_data", &(info->hdr_priv_data), ps, depth);
+ 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);
@@ -1386,34 +1414,66 @@ static void net_io_sam_account_info(char *desc, SAM_ACCOUNT_INFO *info, prs_stru
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);
- smb_io_buffer4("buf_priv_data" , &(info->buf_priv_data ),
- info->hdr_priv_data.buffer, ps, depth);
+ prs_align(ps);
+ if (hdr_priv_data.buffer != 0)
+ {
+ int old_offset;
+ uint32 len = 0x44;
+ prs_uint32("pwd_len", ps, depth, &len);
+ old_offset = ps->offset;
+ if (len == 0x44)
+ {
+ if (ps->io)
+ {
+ /* reading */
+ prs_hash1(ps, ps->offset, sess_key);
+ }
+ net_io_sam_passwd_info("pass", &(info->pass), ps, depth);
+ if (!ps->io)
+ {
+ /* writing */
+ prs_hash1(ps, old_offset, sess_key);
+ }
+ }
+ ps->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);
}
/*******************************************************************
@@ -1551,7 +1611,9 @@ static void net_io_sam_alias_mem_info(char *desc, SAM_ALIAS_MEM_INFO *info, prs_
/*******************************************************************
reads or writes a structure.
********************************************************************/
-static void net_io_sam_delta_ctr(char *desc, SAM_DELTA_CTR *delta, uint16 type, prs_struct *ps, int depth)
+static void net_io_sam_delta_ctr(char *desc, uint8 sess_key[16],
+ SAM_DELTA_CTR *delta, uint16 type,
+ prs_struct *ps, int depth)
{
if (delta == NULL) return;
@@ -1560,34 +1622,56 @@ static void net_io_sam_delta_ctr(char *desc, SAM_DELTA_CTR *delta, uint16 type,
switch (type)
{
- case 1:
- net_io_sam_domain_info("", &(delta->domain_info), ps, depth);
- break;
- case 2:
- net_io_sam_group_info("", &(delta->group_info), ps, depth);
- break;
- case 5:
- net_io_sam_account_info("", &(delta->account_info), ps, depth);
- break;
- case 8:
- net_io_sam_group_mem_info("", &(delta->grp_mem_info), ps, depth);
- break;
- case 9:
- net_io_sam_alias_info("", &(delta->alias_info), ps, depth);
- break;
- case 0xC:
- net_io_sam_alias_mem_info("", &(delta->als_mem_info), ps, depth);
- break;
- default:
- DEBUG(0, ("Replication error: Unknown delta type %x\n", type));
+ case 1:
+ {
+ net_io_sam_domain_info("", &(delta->domain_info),
+ ps, depth);
+ break;
+ }
+ case 2:
+ {
+ net_io_sam_group_info("", &(delta->group_info),
+ ps, depth);
+ break;
+ }
+ case 5:
+ {
+ net_io_sam_account_info("", sess_key,
+ &(delta->account_info),
+ ps, depth);
+ break;
+ }
+ case 8:
+ {
+ net_io_sam_group_mem_info("", &(delta->grp_mem_info),
+ ps, depth);
+ break;
+ }
+ case 9:
+ {
+ net_io_sam_alias_info("", &(delta->alias_info),
+ ps, depth);
+ break;
+ }
+ case 0xC:
+ {
+ net_io_sam_alias_mem_info("", &(delta->als_mem_info),
+ ps, depth);
+ break;
+ }
+ default:
+ {
+ DEBUG(0, ("Replication error: Unknown delta type %x\n", type));
+ break;
+ }
}
-
}
/*******************************************************************
reads or writes a structure.
********************************************************************/
-void net_io_r_sam_sync(char *desc, NET_R_SAM_SYNC *r_s, prs_struct *ps, int depth)
+void net_io_r_sam_sync(char *desc, uint8 sess_key[16],
+ NET_R_SAM_SYNC *r_s, prs_struct *ps, int depth)
{
int i;
@@ -1620,7 +1704,8 @@ void net_io_r_sam_sync(char *desc, NET_R_SAM_SYNC *r_s, prs_struct *ps, int dept
for (i = 0; i < r_s->num_deltas2; i++)
{
- net_io_sam_delta_ctr("", &r_s->deltas[i],
+ net_io_sam_delta_ctr("", sess_key,
+ &r_s->deltas[i],
r_s->hdr_deltas[i].type3, ps, depth);
}
}
diff --git a/source3/rpc_parse/parse_prs.c b/source3/rpc_parse/parse_prs.c
index a231fb57cf..c55ec9c225 100644
--- a/source3/rpc_parse/parse_prs.c
+++ b/source3/rpc_parse/parse_prs.c
@@ -129,6 +129,27 @@ BOOL prs_uint16(char *name, prs_struct *ps, int depth, uint16 *data16)
}
/*******************************************************************
+ hash a stream.
+ ********************************************************************/
+BOOL prs_hash1(prs_struct *ps, uint32 offset, uint8 sess_key[16])
+{
+ char *q = mem_data(&(ps->data), offset);
+ if (q == NULL) return False;
+
+#ifdef DEBUG_PASSWORD
+ DEBUG(100,("prs_hash1\n"));
+ dump_data(100, sess_key, 16);
+ dump_data(100, q, 68);
+#endif
+ SamOEMhash(q, sess_key, 2);
+#ifdef DEBUG_PASSWORD
+ dump_data(100, q, 68);
+#endif
+
+ return True;
+}
+
+/*******************************************************************
stream a uint32
********************************************************************/
BOOL prs_uint32(char *name, prs_struct *ps, int depth, uint32 *data32)
diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c
index def5dba297..1d99b99f9c 100644
--- a/source3/rpcclient/cmd_netlogon.c
+++ b/source3/rpcclient/cmd_netlogon.c
@@ -179,5 +179,14 @@ experimental SAM synchronisation.
****************************************************************************/
void cmd_sam_sync(struct client_info *info)
{
- do_sam_sync(smb_cli);
+ SAM_DELTA_HDR hdr_deltas[MAX_SAM_DELTAS];
+ SAM_DELTA_CTR deltas[MAX_SAM_DELTAS];
+ uint32 num;
+
+ if (do_sam_sync(smb_cli, hdr_deltas, deltas, &num))
+ {
+ display_sam_sync(out_hnd, ACTION_HEADER , hdr_deltas, deltas, num);
+ display_sam_sync(out_hnd, ACTION_ENUMERATE, hdr_deltas, deltas, num);
+ display_sam_sync(out_hnd, ACTION_FOOTER , hdr_deltas, deltas, num);
+ }
}
diff --git a/source3/rpcclient/display.c b/source3/rpcclient/display.c
index dc801805c6..97e1cc8344 100644
--- a/source3/rpcclient/display.c
+++ b/source3/rpcclient/display.c
@@ -1903,6 +1903,94 @@ void display_eventlog_eventrecord(FILE *out_hnd, enum action_type action, EVENTL
}
}
+/****************************************************************************
+ display sam sync structure
+ ****************************************************************************/
+void display_sam_sync_ctr(FILE *out_hnd, enum action_type action,
+ SAM_DELTA_HDR *delta,
+ SAM_DELTA_CTR *ctr)
+{
+ fstring name;
+
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ switch (delta->type)
+ {
+ case 1:
+ {
+ unistr2_to_ascii(name, &(ctr->domain_info.uni_dom_name), sizeof(name)-1);
+ fprintf(out_hnd, "Domain: %s\n", name);
+ break;
+ }
+ case 2:
+ {
+ unistr2_to_ascii(name, &(ctr->group_info.uni_grp_name), sizeof(name)-1);
+ fprintf(out_hnd, "Group: %s\n", name);
+ break;
+ }
+ case 5:
+ {
+ unistr2_to_ascii(name, &(ctr->account_info.uni_acct_name), sizeof(name)-1);
+ fprintf(out_hnd, "Account: %s\n", name);
+
+ out_struct(out_hnd,
+ ctr->account_info.pass.buf_lm_pwd, 16, 8);
+ out_struct(out_hnd,
+ ctr->account_info.pass.buf_nt_pwd, 16, 8);
+
+ }
+ }
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+ display sam sync structure
+ ****************************************************************************/
+void display_sam_sync(FILE *out_hnd, enum action_type action,
+ SAM_DELTA_HDR *deltas,
+ SAM_DELTA_CTR *ctr,
+ uint32 num)
+{
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ fprintf(out_hnd, "\tSAM Database Sync\n");
+ fprintf(out_hnd, "\t-----------------\n");
+
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ int i;
+ for (i = 0; i < num; i++)
+ {
+ display_sam_sync_ctr(out_hnd, ACTION_HEADER , &deltas[i], &ctr[i]);
+ display_sam_sync_ctr(out_hnd, ACTION_ENUMERATE, &deltas[i], &ctr[i]);
+ display_sam_sync_ctr(out_hnd, ACTION_FOOTER , &deltas[i], &ctr[i]);
+ }
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ fprintf(out_hnd, "\n");
+ break;
+ }
+ }
+}
+
#if COPY_THIS_TEMPLATE
/****************************************************************************
diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c
index 29f2d364e5..e9360651da 100644
--- a/source3/utils/smbpasswd.c
+++ b/source3/utils/smbpasswd.c
@@ -89,6 +89,8 @@ static int join_domain(char *domain, char *remote)
BOOL ret;
uint16 sec_chan;
+ DEBUG(5,("join_domain: domain %s remote %s\n", domain, remote));
+
pstrcpy(remote_machine, remote ? remote : "");
fstrcpy(trust_passwd, global_myname);
strlower(trust_passwd);
@@ -97,19 +99,28 @@ static int join_domain(char *domain, char *remote)
switch (lp_server_role())
{
case ROLE_DOMAIN_PDC:
+ {
DEBUG(0, ("Cannot join domain - we are PDC!\n"));
- return;
+ return 1;
+ }
case ROLE_DOMAIN_BDC:
+ {
+ DEBUG(0, ("Joining Domain as BDC\n"));
sec_chan = SEC_CHAN_BDC;
break;
+ }
default:
+ {
+ DEBUG(0, ("Joining Domain as Workstation\n"));
sec_chan = SEC_CHAN_WKSTA;
+ }
}
/*
* Create the machine account password file.
*/
- if(!trust_password_lock( domain, global_myname, True)) {
+ if(!trust_password_lock( domain, global_myname, True))
+ {
fprintf(stderr, "unable to open the machine account password file for \
machine %s in domain %s.\n", global_myname, domain);
return 1;
@@ -119,7 +130,8 @@ machine %s in domain %s.\n", global_myname, domain);
* Write the old machine account password.
*/
- if(!set_trust_account_password( orig_trust_passwd_hash)) {
+ if(!set_trust_account_password( orig_trust_passwd_hash))
+ {
fprintf(stderr, "unable to write the machine account password for \
machine %s in domain %s.\n", global_myname, domain);
trust_password_unlock();
@@ -130,7 +142,8 @@ machine %s in domain %s.\n", global_myname, domain);
* If we are given a remote machine assume this is the PDC.
*/
- if(remote == NULL) {
+ if(remote == NULL)
+ {
pstrcpy(remote_machine, lp_passwordserver());
}
@@ -145,12 +158,15 @@ unable to join domain.\n");
trust_password_unlock();
if(!ret) {
- trust_password_delete( domain, global_myname);
fprintf(stderr,"Unable to join domain %s.\n",domain);
} else {
printf("Joined domain %s.\n",domain);
}
+#if 0
+ trust_password_delete( domain, global_myname);
+#endif
+
return (int)ret;
}