LIBSMB_OBJ = libsmb/clientgen.o libsmb/namequery.o libsmb/nmblib.o \
libsmb/nterr.o libsmb/smbdes.o libsmb/smbencrypt.o \
libsmb/smberr.o libsmb/credentials.o libsmb/pwd_cache.o \
- libsmb/passchange.o libsmb/clienttrust.o
+ libsmb/passchange.o
RPC_SERVER_OBJ = \
rpc_server/srv_lsa.o \
rpc_client/cli_svcctl.o \
rpc_client/cli_samr.o \
rpc_client/cli_atsvc.o \
- rpc_client/cli_eventlog.o
-
+ rpc_client/cli_eventlog.o \
+ libsmb/clienttrust.o
LOCKING_OBJ = locking/locking.o locking/locking_shm.o locking/locking_slow.o \
locking/shmem.o locking/shmem_sysv.o
BOOL cli_message_end(struct cli_state *cli, int grp);
BOOL cli_dskattr(struct cli_state *cli, int *bsize, int *total, int *avail);
+/*The following definitions come from libsmb/clienttrust.c */
+
+BOOL change_trust_account_password(char *domain, char *remote_machine_list,
+ uint16 sec_chan);
+
/*The following definitions come from libsmb/credentials.c */
char *credstr(uchar *cred);
NET_USER_INFO_3 *user_info3);
BOOL cli_net_sam_logoff(struct cli_state *cli, uint16 nt_pipe_fnum, NET_ID_INFO_CTR *ctr);
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, uchar trust_passwd[16],
+ const char* srv_name,
SAM_DELTA_HDR hdr_deltas[MAX_SAM_DELTAS],
SAM_DELTA_CTR deltas [MAX_SAM_DELTAS],
uint32 *num_deltas);
BOOL get_samr_query_userinfo(struct cli_state *cli, uint16 fnum,
POLICY_HND *pol_open_domain,
uint32 info_level,
- uint32 user_rid, void *usr);
+ uint32 user_rid, SAM_USER_INFO_21 *usr);
BOOL get_samr_query_groupinfo(struct cli_state *cli, uint16 fnum,
POLICY_HND *pol_open_domain,
uint32 info_level,
BOOL make_samr_r_lookup_rids(SAMR_R_LOOKUP_RIDS *r_u,
uint32 num_names, fstring *name, uint8 *type,
uint32 status);
-BOOL samr_io_r_lookup_rids(char *desc, SAMR_R_LOOKUP_RIDS *r_u, prs_struct *ps, int depth);
+BOOL samr_io_r_lookup_rids(char *desc, SAMR_R_LOOKUP_RIDS *r_u, prs_struct *ps, int depth);
+void samr_free_r_lookup_rids(SAMR_R_LOOKUP_RIDS *r_u);
BOOL make_samr_q_delete_alias(SAMR_Q_DELETE_DOM_ALIAS *q_u, POLICY_HND *hnd);
BOOL samr_io_q_delete_alias(char *desc, SAMR_Q_DELETE_DOM_ALIAS *q_u, prs_struct *ps, int depth);
BOOL samr_io_r_delete_alias(char *desc, SAMR_R_DELETE_DOM_ALIAS *r_u, prs_struct *ps, int depth);
uint32 ptr; /* 0x0000 0000 - 32 bit unknown */
uint32 num_rids2; /* number of rids being looked up */
- uint32 rid[MAX_LOOKUP_SIDS]; /* domain RIDs being looked up */
+ uint32 *rid; /* domain RIDs being looked up */
} SAMR_Q_LOOKUP_RIDS;
uint32 ptr_names; /* pointer to aliases */
uint32 num_names2; /* number of aliases being looked up */
- UNIHDR hdr_name[MAX_LOOKUP_SIDS]; /* unicode account name header */
- UNISTR2 uni_name[MAX_LOOKUP_SIDS]; /* unicode account name string */
+ UNIHDR *hdr_name; /* unicode account name header */
+ UNISTR2 *uni_name; /* unicode account name string */
uint32 num_types1; /* number of users in aliases being looked up */
uint32 ptr_types; /* pointer to users in aliases */
uint32 num_types2; /* number of users in aliases being looked up */
- uint32 type[MAX_LOOKUP_SIDS]; /* SID_ENUM type */
+ uint32 *type; /* SID_ENUM type */
uint32 status;
ret = cli_net_req_chal(cli, fnum, srv_name, &clnt_chal, &srv_chal);
if (ret != 0)
{
- DEBUG(0,("cli_nt_setup_creds: request challenge failed\n"));
+ DEBUG(1,("cli_nt_setup_creds: request challenge failed\n"));
return ret;
}
sec_chan, 0x000001ff, &srv_chal);
if (ret != 0x0)
{
- DEBUG(0,("cli_nt_setup_creds: auth2 challenge failed\n"));
+ DEBUG(1,("cli_nt_setup_creds: auth2 challenge failed. status: %x\n", ret));
}
return ret;
#include "includes.h"
extern int DEBUGLEVEL;
-extern pstring scope;
extern pstring global_myname;
/****************************************************************************
if (ok && r_l.status != 0)
{
/* report error code */
- DEBUG(0,("do_net_logon_ctrl2: Error %s\n", get_nt_error_msg(r_l.status)));
+ DEBUG(5,("do_net_logon_ctrl2: Error %s\n", get_nt_error_msg(r_l.status)));
cli->nt_error = r_l.status;
ok = False;
}
if (status == 0x0 && r_a.status != 0)
{
/* report error code */
- DEBUG(0,("cli_net_auth2: Error %s\n",
+ DEBUG(5,("cli_net_auth2: Error %s\n",
get_nt_error_msg(r_a.status)));
cli->nt_error = r_a.status;
status = r_a.status;
/*
* Server replied with bad credential. Fail.
*/
- DEBUG(0,("cli_net_auth2: server %s replied with bad credential (bad machine \
+ DEBUG(5,("cli_net_auth2: server %s replied with bad credential (bad machine \
password ?).\n", cli->desthost ));
status = NT_STATUS_NETWORK_CREDENTIAL_CONFLICT | 0xC0000000;
}
if (ok && r_a.srv_flgs.neg_flags != q_a.clnt_flgs.neg_flags)
{
/* report different neg_flags */
- DEBUG(0,("cli_net_auth2: error neg_flags (q,r) differ - (%x,%x)\n",
+ DEBUG(5,("cli_net_auth2: error neg_flags (q,r) differ - (%x,%x)\n",
q_a.clnt_flgs.neg_flags, r_a.srv_flgs.neg_flags));
ok = False;
}
}
else
{
+ DEBUG(5,("rpc_api_pipe_req FAILED\n"));
status = 0xC0000000 | NT_STATUS_ACCESS_DENIED;
}
+ DEBUG(5,("cli_net_auth2 status: %x\n", status));
+
prs_mem_free(&rbuf);
prs_mem_free(&buf );
if (status == 0x0 && r_c.status != 0)
{
/* report error code */
- DEBUG(0,("cli_net_req_chal: Error %s\n", get_nt_error_msg(r_c.status)));
+ DEBUG(5,("cli_net_req_chal: Error %s\n", get_nt_error_msg(r_c.status)));
cli->nt_error = r_c.status;
status = r_c.status;
}
}
else
{
+ DEBUG(5,("rpc_api_pipe_req FAILED\n"));
status = 0xC0000000 | NT_STATUS_ACCESS_DENIED;
}
if (ok && r_s.status != 0)
{
/* report error code */
- DEBUG(0,("cli_net_srv_pwset: %s\n", get_nt_error_msg(r_s.status)));
+ DEBUG(5,("cli_net_srv_pwset: %s\n", get_nt_error_msg(r_s.status)));
cli->nt_error = r_s.status;
ok = False;
}
/*
* Server replied with bad credential. Fail.
*/
- DEBUG(0,("cli_net_srv_pwset: server %s replied with bad credential (bad machine \
+ DEBUG(5,("cli_net_srv_pwset: server %s replied with bad credential (bad machine \
password ?).\n", cli->desthost ));
ok = False;
}
if (ok && r_s.status != 0)
{
/* report error code */
- DEBUG(0,("cli_net_sam_logon: %s\n", get_nt_error_msg(r_s.status)));
+ DEBUG(5,("cli_net_sam_logon: %s\n", get_nt_error_msg(r_s.status)));
cli->nt_error = r_s.status;
ok = False;
}
/*
* Server replied with bad credential. Fail.
*/
- DEBUG(0,("cli_net_sam_logon: server %s replied with bad credential (bad machine \
+ DEBUG(5,("cli_net_sam_logon: server %s replied with bad credential (bad machine \
password ?).\n", cli->desthost ));
ok = False;
}
if (ok && r_s.switch_value != 3)
{
/* report different switch_value */
- DEBUG(0,("cli_net_sam_logon: switch_value of 3 expected %x\n",
+ DEBUG(5,("cli_net_sam_logon: switch_value of 3 expected %x\n",
r_s.switch_value));
ok = False;
}
if (ok && r_s.status != 0)
{
/* report error code */
- DEBUG(0,("cli_net_sam_logoff: %s\n", get_nt_error_msg(r_s.status)));
+ DEBUG(5,("cli_net_sam_logoff: %s\n", get_nt_error_msg(r_s.status)));
cli->nt_error = r_s.status;
ok = False;
}
/*
* Server replied with bad credential. Fail.
*/
- DEBUG(0,("cli_net_sam_logoff: server %s replied with bad credential (bad machine \
+ DEBUG(5,("cli_net_sam_logoff: server %s replied with bad credential (bad machine \
password ?).\n", cli->desthost ));
ok = False;
}
if (ok && r_s.status != 0 && r_s.status != NT_STATUS_MORE_ENTRIES)
{
/* report error code */
- DEBUG(0,("cli_net_sam_sync: %s\n", get_nt_error_msg(r_s.status)));
+ DEBUG(5,("cli_net_sam_sync: %s\n", get_nt_error_msg(r_s.status)));
cli->nt_error = r_s.status;
ok = False;
}
/* Update the credentials. */
if (ok && !clnt_deal_with_creds(cli->sess_key, &(cli->clnt_cred), &(r_s.srv_creds)))
{
- DEBUG(0,("cli_net_sam_sync: server %s replied with bad credential (bad machine password ?).\n", cli->desthost));
+ DEBUG(5,("cli_net_sam_sync: server %s replied with bad credential (bad machine password ?).\n", cli->desthost));
ok = False;
}
if (r_s.status == NT_STATUS_MORE_ENTRIES)
{
- DEBUG(2, ("(More entries)\n"));
+ DEBUG(5, ("(More entries)\n"));
}
}
}
return ok;
}
-/*********************************************************
- Change the domain password on the PDC.
-**********************************************************/
-
-static BOOL modify_trust_password( char *domain, char *remote_machine,
- unsigned char orig_trust_passwd_hash[16],
- unsigned char new_trust_passwd_hash[16],
- uint16 sec_chan)
-{
- uint16 nt_pipe_fnum;
- struct cli_state cli;
- struct nmb_name calling, called;
-
- make_nmb_name(&calling, global_myname , 0x0 , scope);
- make_nmb_name(&called , remote_machine, 0x20, scope);
-
- ZERO_STRUCT(cli);
- if(cli_initialise(&cli) == NULL)
- {
- DEBUG(0,("modify_trust_password: unable to initialize client \
-connection.\n"));
- return False;
- }
-
- if(!resolve_name( remote_machine, &cli.dest_ip, 0x20))
- {
- DEBUG(0,("modify_trust_password: Can't resolve address for \
-%s\n", remote_machine));
- return False;
- }
-
- if (ismyip(cli.dest_ip))
- {
- DEBUG(0,("modify_trust_password: Machine %s is one of our \
-addresses. Cannot add to ourselves.\n", remote_machine));
- return False;
- }
-
- cli.protocol = PROTOCOL_NT1;
-
- pwd_set_nullpwd(&cli.pwd);
-
- if (!cli_establish_connection(&cli, remote_machine, &cli.dest_ip,
- &calling, &called,
- "IPC$", "IPC", False, True))
- {
- fstring errstr;
- cli_safe_errstr(&cli, errstr, sizeof(errstr));
- DEBUG(0,("modify_trust_password: machine %s rejected the SMB \
-session. Error was : %s.\n", remote_machine, errstr ));
- cli_shutdown(&cli);
- return False;
- }
-
-
- if (cli.protocol != PROTOCOL_NT1)
- {
- DEBUG(0,("modify_trust_password: machine %s didn't negotiate \
-NT protocol.\n", remote_machine));
- cli_shutdown(&cli);
- return False;
- }
-
- if (!(IS_BITS_SET_ALL(cli.sec_mode, 1)))
- {
- DEBUG(0,("modify_trust_password: machine %s isn't in user \
-level security mode\n", remote_machine));
- cli_shutdown(&cli);
- return False;
- }
-
- /*
- * Ok - we have an anonymous connection to the IPC$ share.
- * Now start the NT Domain stuff :-).
- */
-
- if (!cli_nt_session_open(&cli, PIPE_NETLOGON, &nt_pipe_fnum))
- {
- fstring errstr;
- cli_safe_errstr(&cli, errstr, sizeof(errstr));
- DEBUG(0,("modify_trust_password: unable to open the domain \
-client session to server %s. Error was : %s.\n", remote_machine, errstr ));
- cli_nt_session_close(&cli, nt_pipe_fnum);
- cli_ulogoff(&cli);
- cli_shutdown(&cli);
- return False;
- }
-
- if (cli_nt_setup_creds(&cli, nt_pipe_fnum,
- cli.mach_acct, global_myname,
- orig_trust_passwd_hash, sec_chan) != 0x0)
- {
- fstring errstr;
- cli_safe_errstr(&cli, errstr, sizeof(errstr));
- DEBUG(0,("modify_trust_password: unable to setup the PDC \
-credentials to server %s. Error was : %s.\n", remote_machine, errstr ));
- cli_nt_session_close(&cli, nt_pipe_fnum);
- cli_ulogoff(&cli);
- cli_shutdown(&cli);
- return False;
- }
-
- if (!cli_nt_srv_pwset( &cli, nt_pipe_fnum, new_trust_passwd_hash,
- sec_chan ) )
- {
- fstring errstr;
- cli_safe_errstr(&cli, errstr, sizeof(errstr));
- DEBUG(0,("modify_trust_password: unable to change password for \
-workstation %s in domain %s to Domain controller %s. Error was %s.\n",
- global_myname, domain, remote_machine, errstr ));
- cli_nt_session_close(&cli, nt_pipe_fnum);
- cli_ulogoff(&cli);
- cli_shutdown(&cli);
- return False;
- }
-
- cli_nt_session_close(&cli, nt_pipe_fnum);
- cli_ulogoff(&cli);
- cli_shutdown(&cli);
-
- return True;
-}
-
-/************************************************************************
- Change the trust account password for a domain.
- The user of this function must have locked the trust password file for
- update.
-************************************************************************/
-
-BOOL change_trust_account_password(char *domain, char *remote_machine_list,
- uint16 sec_chan)
-{
- fstring remote_machine;
- unsigned char old_trust_passwd_hash[16];
- unsigned char new_trust_passwd_hash[16];
- time_t lct;
- BOOL res;
-
- if(!get_trust_account_password( old_trust_passwd_hash, &lct)) {
- DEBUG(0,("change_trust_account_password: unable to read the machine \
-account password for domain %s.\n", domain));
- return False;
- }
-
- /*
- * Create the new (random) password.
- */
- generate_random_buffer( new_trust_passwd_hash, 16, True);
-
- while(remote_machine_list &&
- next_token(&remote_machine_list, remote_machine,
- LIST_SEP, sizeof(remote_machine))) {
- strupper(remote_machine);
- if(modify_trust_password( domain, remote_machine,
- old_trust_passwd_hash, new_trust_passwd_hash, sec_chan)) {
- DEBUG(0,("%s : change_trust_account_password: Changed password for \
-domain %s.\n", timestring(), domain));
- /*
- * Return the result of trying to write the new password
- * back into the trust account file.
- */
- res = set_trust_account_password(new_trust_passwd_hash);
- memset(new_trust_passwd_hash, 0, 16);
- memset(old_trust_passwd_hash, 0, 16);
- return res;
- }
- }
-
- memset(new_trust_passwd_hash, 0, 16);
- memset(old_trust_passwd_hash, 0, 16);
-
- DEBUG(0,("%s : change_trust_account_password: Failed to change password for \
-domain %s.\n", timestring(), domain));
- return False;
-}
BOOL do_sam_sync(struct cli_state *cli, uchar trust_passwd[16],
+ const char* srv_name,
SAM_DELTA_HDR hdr_deltas[MAX_SAM_DELTAS],
SAM_DELTA_CTR deltas [MAX_SAM_DELTAS],
uint32 *num_deltas)
*num_deltas = 0;
- DEBUG(2,("Attempting SAM sync with PDC, domain: %s name: %s\n",
- cli->domain, global_myname));
+ DEBUG(5,("Attempting SAM sync with PDC, domain: %s name: %s\n",
+ cli->domain, srv_name));
/* open NETLOGON session. negotiate credentials */
res = res ? cli_nt_session_open(cli, PIPE_NETLOGON, &nt_pipe_fnum) : False;
res = res ? cli_nt_setup_creds(cli, nt_pipe_fnum,
- cli->mach_acct, global_myname,
+ cli->mach_acct, srv_name,
trust_passwd, SEC_CHAN_BDC) == 0x0 : False;
memset(trust_passwd, 0, 16);
if (!res)
{
- DEBUG(0, ("SAM synchronisation FAILED\n"));
+ DEBUG(5, ("SAM synchronisation FAILED\n"));
return False;
}
- DEBUG(0, ("SAM synchronisation returned %d entries\n", *num_deltas));
+ DEBUG(5, ("SAM synchronisation returned %d entries\n", *num_deltas));
return True;
}
return False;
}
- ret = do_sam_sync(&cli, trust_passwd, hdr_deltas, deltas, &num);
+ ret = do_sam_sync(&cli, trust_passwd, global_myname,
+ hdr_deltas, deltas, &num);
if (ret)
{
prs_struct *rdata, uint32 data_to_read,
uint32 rdata_offset)
{
- int size = cli->max_recv_frag;
+ size_t size = cli->max_recv_frag;
int file_offset = 0;
int num_read;
char *data;
uint32 new_data_size = rdata_offset + data_to_read;
+ uint8 cls;
+ uint32 type;
DEBUG(5,("rpc_read: data_to_read: %d data offset: %d file offset: %d\n",
data_to_read, rdata_offset, file_offset));
file_offset += num_read;
data += num_read;
- if (cli_error(cli, NULL, NULL)) return False;
+ if (cli_error(cli, &cls, &type))
+ {
+ if (cls != ERRDOS || type != ERRmoredata)
+ {
+ return False;
+ }
+ }
} while (num_read > 0 && data_to_read > 0);
int len;
uint16 setup[2]; /* only need 2 uint16 setup parameters */
- uint32 err;
+ uint8 cls;
+ uint32 type;
BOOL first = True;
BOOL last = True;
RPC_HDR rhdr;
prs_mem_free(&hps);
- if (cli_error(cli, NULL, &err)) return False;
+ if (cli_error(cli, &cls, &type))
+ {
+ if (cls != ERRDOS || type != ERRmoredata)
+ {
+ return False;
+ }
+ }
if (first)
{
{
if (strequal(pipe_name, pipe_names[pipe_idx].client_pipe ))
{
- DEBUG(5,("Bind Abstract Syntax: "));
+ DEBUG(5,("Bind Abstract Syntax:\n"));
dump_data(5, (char*)&(pipe_names[pipe_idx].abstr_syntax),
sizeof(pipe_names[pipe_idx].abstr_syntax));
- DEBUG(5,("Bind Transfer Syntax: "));
+ DEBUG(5,("Bind Transfer Syntax:\n"));
dump_data(5, (char*)&(pipe_names[pipe_idx].trans_syntax),
sizeof(pipe_names[pipe_idx].trans_syntax));
BOOL get_samr_query_userinfo(struct cli_state *cli, uint16 fnum,
POLICY_HND *pol_open_domain,
uint32 info_level,
- uint32 user_rid, void *usr)
+ uint32 user_rid, SAM_USER_INFO_21 *usr)
{
POLICY_HND pol_open_user;
BOOL ret = True;
- if (pol_open_domain == NULL) return False;
+ if (pol_open_domain == NULL || usr == NULL) return False;
+
+ bzero(usr, sizeof(*usr));
/* send open domain (on user sid) */
if (!samr_open_user(cli, fnum,
/* send user info query */
if (!samr_query_userinfo(cli, fnum,
&pol_open_user,
- info_level, usr))
+ info_level, (void*)usr))
{
DEBUG(5,("samr_query_userinfo: error in query user info, level 0x%x\n",
info_level));
if (p && r_e.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_CHGPASSWD_USER: %s\n", get_nt_error_msg(r_e.status)));
+ DEBUG(4,("SAMR_R_CHGPASSWD_USER: %s\n", get_nt_error_msg(r_e.status)));
p = False;
}
if (p && r_e.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_UNKNOWN_38: %s\n", get_nt_error_msg(r_e.status)));
+ DEBUG(4,("SAMR_R_UNKNOWN_38: %s\n", get_nt_error_msg(r_e.status)));
p = False;
}
#endif
if (p && r_e.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_QUERY_DOMAIN_INFO: %s\n", get_nt_error_msg(r_e.status)));
+ DEBUG(4,("SAMR_R_QUERY_DOMAIN_INFO: %s\n", get_nt_error_msg(r_e.status)));
p = False;
}
if (p && r_e.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_ENUM_DOM_GROUPS: %s\n", get_nt_error_msg(r_e.status)));
+ DEBUG(4,("SAMR_R_ENUM_DOM_GROUPS: %s\n", get_nt_error_msg(r_e.status)));
p = False;
}
if (p && r_e.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_ENUM_DOM_ALIASES: %s\n", get_nt_error_msg(r_e.status)));
+ DEBUG(4,("SAMR_R_ENUM_DOM_ALIASES: %s\n", get_nt_error_msg(r_e.status)));
p = False;
}
if (p && r_e.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_ENUM_DOM_USERS: %s\n", get_nt_error_msg(r_e.status)));
+ DEBUG(4,("SAMR_R_ENUM_DOM_USERS: %s\n", get_nt_error_msg(r_e.status)));
p = False;
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_CONNECT: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_CONNECT: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_OPEN_USER: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_OPEN_USER: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_OPEN_ALIAS: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_OPEN_ALIAS: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_DEL_ALIASMEM: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_DEL_ALIASMEM: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_ADD_ALIASMEM: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_ADD_ALIASMEM: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_DELETE_DOM_ALIAS: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_DELETE_DOM_ALIAS: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_CREATE_USER: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_CREATE_USER: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_CREATE_DOM_ALIAS: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_CREATE_DOM_ALIAS: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_GET_ALIASINFO: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_GET_ALIASINFO: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_SET_ALIASINFO: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_SET_ALIASINFO: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_OPEN_GROUP: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_OPEN_GROUP: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_DEL_GROUPMEM: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_DEL_GROUPMEM: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_ADD_GROUPMEM: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_ADD_GROUPMEM: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_DELETE_DOM_GROUP: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_DELETE_DOM_GROUP: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_CREATE_DOM_GROUP: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_CREATE_DOM_GROUP: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_SET_GROUPINFO: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_SET_GROUPINFO: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_OPEN_DOMAIN: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_OPEN_DOMAIN: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_LOOKUP_DOMAIN: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_LOOKUP_DOMAIN: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_LOOKUP_NAMES: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_LOOKUP_NAMES: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
{
SAMR_R_LOOKUP_RIDS r_o;
BOOL p;
+ ZERO_STRUCT(r_o);
samr_io_r_lookup_rids("", &r_o, &rdata, 0);
p = rdata.offset != 0;
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_LOOKUP_RIDS: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_LOOKUP_RIDS: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
p = False;
}
}
+
+ samr_free_r_lookup_rids(&r_o);
}
prs_mem_free(&data );
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_QUERY_ALIASMEM: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_QUERY_ALIASMEM: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_QUERY_USERALIASES: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_QUERY_USERALIASES: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_QUERY_GROUPMEM: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_QUERY_GROUPMEM: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_QUERY_USERGROUPS: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_QUERY_USERGROUPS: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_QUERY_GROUPINFO: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_QUERY_GROUPINFO: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.ctr->switch_value1 != switch_value)
{
- DEBUG(0,("SAMR_R_QUERY_GROUPINFO: received incorrect level %d\n",
+ DEBUG(4,("SAMR_R_QUERY_GROUPINFO: received incorrect level %d\n",
r_o.ctr->switch_value1));
}
DEBUG(4,("SAMR Query User Info. level: %d\n", switch_value));
- if (pol == NULL || switch_value == 0) return False;
+ if (pol == NULL || usr == NULL || switch_value == 0) return False;
/* create and send a MSRPC command with api SAMR_QUERY_USERINFO */
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_QUERY_USERINFO: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_QUERY_USERINFO: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.switch_value != switch_value)
{
- DEBUG(0,("SAMR_R_QUERY_USERINFO: received incorrect level %d\n",
+ DEBUG(4,("SAMR_R_QUERY_USERINFO: received incorrect level %d\n",
r_o.switch_value));
}
if (p && r_c.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_CLOSE_HND: %s\n", get_nt_error_msg(r_c.status)));
+ DEBUG(4,("SAMR_CLOSE_HND: %s\n", get_nt_error_msg(r_c.status)));
p = False;
}
}
if (!valid_close)
{
- DEBUG(0,("SAMR_CLOSE_HND: non-zero handle returned\n"));
+ DEBUG(4,("SAMR_CLOSE_HND: non-zero handle returned\n"));
}
}
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SAMR_R_QUERY_DISPINFO: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(4,("SAMR_R_QUERY_DISPINFO: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.switch_level != level)
{
- DEBUG(0,("SAMR_R_QUERY_DISPINFO: received incorrect level %d\n",
+ DEBUG(4,("SAMR_R_QUERY_DISPINFO: received incorrect level %d\n",
r_o.switch_level));
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SVC_OPEN_SC_MAN: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(1,("SVC_OPEN_SC_MAN: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
if (p && r_o.status != 0)
{
/* report error code */
- DEBUG(0,("SVC_OPEN_SC_MAN: %s\n", get_nt_error_msg(r_o.status)));
+ DEBUG(1,("SVC_OPEN_SC_MAN: %s\n", get_nt_error_msg(r_o.status)));
p = False;
}
{
fstring errmsg;
- if (r_o.dos_status != ERRmoredata) {
- smb_safe_err_msg(ERRDOS, r_o.dos_status,
- errmsg, sizeof(errmsg));
- /* report error code */
- DEBUG(0,("SVC_ENUM_SVCS_STATUS: %s\n", errmsg));
+ if (r_o.dos_status != ERRmoredata)
+ {
+ smb_safe_err_msg(ERRDOS, r_o.dos_status,
+ errmsg, sizeof(errmsg));
+ /* report error code */
+ DEBUG(1,("SVC_ENUM_SVCS_STATUS: %s\n", errmsg));
}
p = r_o.dos_status == ERRmoredata;
}
if (p && r_c.status != 0)
{
/* report error code */
- DEBUG(0,("SVC_QUERY_SVC_CONFIG: %s\n", get_nt_error_msg(r_c.status)));
+ DEBUG(1,("SVC_QUERY_SVC_CONFIG: %s\n", get_nt_error_msg(r_c.status)));
p = False;
}
if (p && r_c.status != 0)
{
/* report error code */
- DEBUG(0,("SVC_CLOSE: %s\n", get_nt_error_msg(r_c.status)));
+ DEBUG(1,("SVC_CLOSE: %s\n", get_nt_error_msg(r_c.status)));
p = False;
}
}
if (!valid_close)
{
- DEBUG(0,("SVC_CLOSE: non-zero handle returned\n"));
+ DEBUG(1,("SVC_CLOSE: non-zero handle returned\n"));
}
}
}
POLICY_HND *pol, uint32 flags,
uint32 num_rids, uint32 *rid)
{
- int i;
if (q_u == NULL) return False;
DEBUG(5,("make_samr_r_unknwon_12\n"));
q_u->flags = flags;
q_u->ptr = 0;
q_u->num_rids2 = num_rids;
-
- for (i = 0; i < num_rids; i++)
- {
- q_u->rid[i] = rid[i];
- }
+ q_u->rid = rid;
return True;
}
r_u->ptr_types = 1;
r_u->num_types2 = num_names;
- SMB_ASSERT_ARRAY(r_u->hdr_name, num_names);
+ r_u->hdr_name = malloc(num_names * sizeof(r_u->hdr_name[0]));
+ if (r_u->hdr_name == NULL)
+ {
+ return False;
+ }
+ r_u->uni_name = malloc(num_names * sizeof(r_u->uni_name[0]));
+ if (r_u->uni_name == NULL)
+ {
+ free(r_u->hdr_name);
+ return False;
+ }
+ r_u->type = malloc(r_u->num_types2 * sizeof(r_u->type[0]));
+ if (r_u->type == NULL)
+ {
+ free(r_u->hdr_name);
+ free(r_u->uni_name);
+ return False;
+ }
+
for (i = 0; i < num_names; i++)
{
/*******************************************************************
reads or writes a structure.
********************************************************************/
-BOOL samr_io_r_lookup_rids(char *desc, SAMR_R_LOOKUP_RIDS *r_u, prs_struct *ps, int depth)
+BOOL samr_io_r_lookup_rids(char *desc, SAMR_R_LOOKUP_RIDS *r_u, prs_struct *ps, int depth)
{
int i;
fstring tmp;
if (r_u->ptr_names != 0 && r_u->num_names1 != 0)
{
- SMB_ASSERT_ARRAY(r_u->hdr_name, r_u->num_names2);
+ r_u->hdr_name = Realloc(r_u->hdr_name, r_u->num_names2 *
+ sizeof(r_u->hdr_name[0]));
+ if (r_u->hdr_name == NULL)
+ {
+ return False;
+ }
+ r_u->uni_name = Realloc(r_u->uni_name, r_u->num_names2 *
+ sizeof(r_u->uni_name[0]));
+ if (r_u->uni_name == NULL)
+ {
+ free(r_u->hdr_name);
+ return False;
+ }
for (i = 0; i < r_u->num_names2; i++)
{
prs_grow(ps);
if (r_u->ptr_types != 0 && r_u->num_types1 != 0)
{
+ r_u->type = Realloc(r_u->type, r_u->num_types2 *
+ sizeof(r_u->type[0]));
+ if (r_u->type == NULL)
+ {
+ if (r_u->uni_name != NULL)
+ {
+ free(r_u->uni_name);
+ }
+ if (r_u->hdr_name != NULL)
+ {
+ free(r_u->hdr_name);
+ }
+ return False;
+ }
+
for (i = 0; i < r_u->num_types2; i++)
{
prs_grow(ps);
prs_uint32("status", ps, depth, &(r_u->status));
+ if (!ps->io)
+ {
+ /* storing. don't need memory any more */
+ samr_free_r_lookup_rids(r_u);
+ }
+
return True;
}
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+void samr_free_r_lookup_rids(SAMR_R_LOOKUP_RIDS *r_u)
+{
+ if (r_u->uni_name != NULL)
+ {
+ free(r_u->uni_name);
+ r_u->uni_name = NULL;
+ }
+ if (r_u->hdr_name != NULL)
+ {
+ free(r_u->hdr_name);
+ r_u->hdr_name = NULL;
+ }
+ if (r_u->type != NULL)
+ {
+ free(r_u->type);
+ r_u->type = NULL;
+ }
+}
+
/*******************************************************************
makes a SAMR_Q_OPEN_ALIAS structure.
********************************************************************/
DOM_SID pol_sid;
SAMR_R_LOOKUP_RIDS r_u;
+ ZERO_STRUCT(r_u);
DEBUG(5,("samr_lookup_rids: %d\n", __LINE__));
extern struct cli_state *smb_cli;
extern FILE* out_hnd;
+extern pstring global_myname;
/****************************************************************************
res = res ? cli_nt_session_open(smb_cli, PIPE_NETLOGON, &nt_pipe_fnum) : False;
res = res ? cli_nt_setup_creds(smb_cli, nt_pipe_fnum,
- smb_cli->mach_acct,
+ smb_cli->mach_acct, global_myname,
trust_passwd, SEC_CHAN_WKSTA) == 0x0 : False;
#if 0
res = res ? cli_nt_session_open(smb_cli, PIPE_NETLOGON, &nt_pipe_fnum) : False;
res = res ? cli_nt_setup_creds(smb_cli, nt_pipe_fnum, inter_dom_acct,
- trust_passwd, SEC_CHAN_DOMAIN) == 0x0 : False;
+ trust_passwd, global_myname,
+ SEC_CHAN_DOMAIN) == 0x0 : False;
memset(trust_passwd, 0, 16);
return;
}
- if (do_sam_sync(smb_cli, trust_passwd, hdr_deltas, deltas, &num))
+ if (do_sam_sync(smb_cli, global_myname,
+ trust_passwd, 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);
/* read some users */
res = res ? samr_enum_dom_users(smb_cli, fnum,
&info->dom.samr_pol_open_domain,
- start_idx, acb_mask, unk_1, 0x8000,
+ start_idx, acb_mask, unk_1, 0xf0000000,
&info->dom.sam, &info->dom.num_sam_entries) : False;
if (res && info->dom.num_sam_entries == 0)
}
if(cli_nt_setup_creds(&cli, nt_pipe_fnum,
- cli.mach_acct, trust_passwd, SEC_CHAN_WKSTA) == False)
+ cli.mach_acct, global_myname, trust_passwd, SEC_CHAN_WKSTA) == False)
{
DEBUG(0,("domain_client_validate: unable to setup the PDC credentials to machine \
%s. Error was : %s.\n", cli.desthost, cli_errstr(&cli)));