mirror of
https://github.com/samba-team/samba.git
synced 2025-01-12 09:18:10 +03:00
whoa. _major_ restructure of rpcclient. fixed some buuugs, created a few.
found out that getopt() _must_ have optind set to 0 before reuse. still haven't decided what to do with the net* api yet...
This commit is contained in:
parent
cda2577881
commit
29c480085e
@ -1846,8 +1846,8 @@ struct cli_state *do_connect(char *server, char *share, int smb_port)
|
|||||||
make_nmb_name(&called , server, name_type, "");
|
make_nmb_name(&called , server, name_type, "");
|
||||||
make_nmb_name(&stupid_smbserver_called , "*SMBSERVER", 0x20, scope);
|
make_nmb_name(&stupid_smbserver_called , "*SMBSERVER", 0x20, scope);
|
||||||
|
|
||||||
fstrcpy(smb_cli->user_name, username);
|
fstrcpy(smb_cli->usr.user_name, username);
|
||||||
fstrcpy(smb_cli->domain, workgroup);
|
fstrcpy(smb_cli->usr.domain, workgroup);
|
||||||
|
|
||||||
ip = ipzero;
|
ip = ipzero;
|
||||||
if (have_ip) ip = dest_ip;
|
if (have_ip) ip = dest_ip;
|
||||||
@ -1862,17 +1862,17 @@ struct cli_state *do_connect(char *server, char *share, int smb_port)
|
|||||||
{
|
{
|
||||||
if (password[0] == 0)
|
if (password[0] == 0)
|
||||||
{
|
{
|
||||||
pwd_set_nullpwd(&(smb_cli->pwd));
|
pwd_set_nullpwd(&(smb_cli->usr.pwd));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* generate 16 byte hashes */
|
/* generate 16 byte hashes */
|
||||||
pwd_make_lm_nt_16(&(smb_cli->pwd), password);
|
pwd_make_lm_nt_16(&(smb_cli->usr.pwd), password);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pwd_read(&(smb_cli->pwd), "Password:", True);
|
pwd_read(&(smb_cli->usr.pwd), "Password:", True);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* paranoia: destroy the local copy of the password */
|
/* paranoia: destroy the local copy of the password */
|
||||||
|
@ -183,6 +183,10 @@ struct acct_info
|
|||||||
void (*fn)(const char*, const DOM_SID*, uint32, const char*,\
|
void (*fn)(const char*, const DOM_SID*, uint32, const char*,\
|
||||||
uint32, const uint32*, char *const *const, uint32* const)
|
uint32, const uint32*, char *const *const, uint32* const)
|
||||||
|
|
||||||
|
#define DISP_FN(fn)\
|
||||||
|
void (*fn)(const char*, const DOM_SID*, uint16, uint32, \
|
||||||
|
SAM_DISPINFO_CTR *)
|
||||||
|
|
||||||
#define REG_FN(fn)\
|
#define REG_FN(fn)\
|
||||||
void (*fn)(int, const char *, int)
|
void (*fn)(int, const char *, int)
|
||||||
#define REG_KEY_FN(fn)\
|
#define REG_KEY_FN(fn)\
|
||||||
|
@ -481,8 +481,6 @@ int set_maxfiles(int requested_max);
|
|||||||
void reg_get_subkey(char *full_keyname, char *key_name, char *subkey_name);
|
void reg_get_subkey(char *full_keyname, char *key_name, char *subkey_name);
|
||||||
BOOL reg_split_key(const char *full_keyname, uint32 *reg_type, char *key_name);
|
BOOL reg_split_key(const char *full_keyname, uint32 *reg_type, char *key_name);
|
||||||
BOOL become_user_permanently(uid_t uid, gid_t gid);
|
BOOL become_user_permanently(uid_t uid, gid_t gid);
|
||||||
BOOL resolve_srv_name(const char* srv_name, fstring dest_host,
|
|
||||||
struct in_addr *ip);
|
|
||||||
|
|
||||||
/*The following definitions come from lib/util_array.c */
|
/*The following definitions come from lib/util_array.c */
|
||||||
|
|
||||||
@ -805,6 +803,8 @@ FILE *startlmhosts(char *fname);
|
|||||||
BOOL getlmhostsent( FILE *fp, pstring name, int *name_type, struct in_addr *ipaddr);
|
BOOL getlmhostsent( FILE *fp, pstring name, int *name_type, struct in_addr *ipaddr);
|
||||||
void endlmhosts(FILE *fp);
|
void endlmhosts(FILE *fp);
|
||||||
BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type);
|
BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type);
|
||||||
|
BOOL resolve_srv_name(const char* srv_name, fstring dest_host,
|
||||||
|
struct in_addr *ip);
|
||||||
BOOL find_master_ip(char *group, struct in_addr *master_ip);
|
BOOL find_master_ip(char *group, struct in_addr *master_ip);
|
||||||
|
|
||||||
/*The following definitions come from libsmb/nmblib.c */
|
/*The following definitions come from libsmb/nmblib.c */
|
||||||
@ -1776,7 +1776,7 @@ BOOL at_del_job(struct cli_state *cli, uint16 fnum,
|
|||||||
char *server_name, uint32 min_jobid, uint32 max_jobid);
|
char *server_name, uint32 min_jobid, uint32 max_jobid);
|
||||||
BOOL at_enum_jobs(struct cli_state *cli, uint16 fnum,
|
BOOL at_enum_jobs(struct cli_state *cli, uint16 fnum,
|
||||||
char *server_name, uint32 *num_jobs,
|
char *server_name, uint32 *num_jobs,
|
||||||
AT_ENUM_INFO *jobs, fstring *commands);
|
AT_ENUM_INFO *jobs, char ***commands);
|
||||||
BOOL at_query_job(struct cli_state *cli, uint16 fnum, char *server_name,
|
BOOL at_query_job(struct cli_state *cli, uint16 fnum, char *server_name,
|
||||||
uint32 jobid, AT_JOB_INFO *job, fstring command);
|
uint32 jobid, AT_JOB_INFO *job, fstring command);
|
||||||
|
|
||||||
@ -2293,6 +2293,11 @@ BOOL get_samr_query_aliasinfo(
|
|||||||
BOOL msrpc_sam_create_dom_user(const char* srv_name, DOM_SID *sid1,
|
BOOL msrpc_sam_create_dom_user(const char* srv_name, DOM_SID *sid1,
|
||||||
char *acct_name, uint16 acb_info,
|
char *acct_name, uint16 acb_info,
|
||||||
uint32 *rid);
|
uint32 *rid);
|
||||||
|
BOOL msrpc_sam_query_dispinfo(const char* srv_name, const char* domain,
|
||||||
|
DOM_SID *sid1,
|
||||||
|
uint16 switch_value,
|
||||||
|
uint32 *num_entries, SAM_DISPINFO_CTR *ctr,
|
||||||
|
DISP_FN(disp_fn));
|
||||||
|
|
||||||
/*The following definitions come from rpc_parse/parse_at.c */
|
/*The following definitions come from rpc_parse/parse_at.c */
|
||||||
|
|
||||||
@ -3769,7 +3774,8 @@ void display_query_svc_cfg(FILE *out_hnd, enum action_type action,
|
|||||||
void display_svc_info(FILE *out_hnd, enum action_type action,
|
void display_svc_info(FILE *out_hnd, enum action_type action,
|
||||||
const ENUM_SRVC_STATUS *const svc);
|
const ENUM_SRVC_STATUS *const svc);
|
||||||
void display_at_enum_info(FILE *out_hnd, enum action_type action,
|
void display_at_enum_info(FILE *out_hnd, enum action_type action,
|
||||||
uint32 num_jobs, const AT_ENUM_INFO *const jobs, const fstring *const commands);
|
uint32 num_jobs, const AT_ENUM_INFO *const jobs,
|
||||||
|
char *const *const commands);
|
||||||
void display_at_job_info(FILE *out_hnd, enum action_type action,
|
void display_at_job_info(FILE *out_hnd, enum action_type action,
|
||||||
AT_JOB_INFO *const job, fstring command);
|
AT_JOB_INFO *const job, fstring command);
|
||||||
void display_eventlog_eventrecord(FILE *out_hnd, enum action_type action, EVENTLOGRECORD *const ev);
|
void display_eventlog_eventrecord(FILE *out_hnd, enum action_type action, EVENTLOGRECORD *const ev);
|
||||||
@ -3784,6 +3790,13 @@ void display_sam_unk_info_2(FILE *out_hnd, enum action_type action,
|
|||||||
SAM_UNK_INFO_2 *const info2);
|
SAM_UNK_INFO_2 *const info2);
|
||||||
void display_sam_unk_ctr(FILE *out_hnd, enum action_type action,
|
void display_sam_unk_ctr(FILE *out_hnd, enum action_type action,
|
||||||
uint32 switch_value, SAM_UNK_CTR *const ctr);
|
uint32 switch_value, SAM_UNK_CTR *const ctr);
|
||||||
|
void display_sam_info_1(FILE *out_hnd, enum action_type action,
|
||||||
|
SAM_ENTRY1 *const e1, SAM_STR1 *const s1);
|
||||||
|
void display_sam_info_1_ctr(FILE *out_hnd, enum action_type action,
|
||||||
|
uint32 count, SAM_DISPINFO_1 *const ctr);
|
||||||
|
void display_sam_disp_info_ctr(FILE *out_hnd, enum action_type action,
|
||||||
|
uint16 level, uint32 count,
|
||||||
|
SAM_DISPINFO_CTR *const ctr);
|
||||||
void display_print_info_0(FILE *out_hnd, enum action_type action,
|
void display_print_info_0(FILE *out_hnd, enum action_type action,
|
||||||
PRINTER_INFO_0 *const i0);
|
PRINTER_INFO_0 *const i0);
|
||||||
void display_print_info_1(FILE *out_hnd, enum action_type action,
|
void display_print_info_1(FILE *out_hnd, enum action_type action,
|
||||||
|
@ -76,34 +76,10 @@ struct client_info
|
|||||||
{
|
{
|
||||||
struct in_addr dest_ip;
|
struct in_addr dest_ip;
|
||||||
fstring dest_host;
|
fstring dest_host;
|
||||||
fstring query_host;
|
|
||||||
uint8 name_type;
|
|
||||||
|
|
||||||
fstring myhostname;
|
fstring myhostname;
|
||||||
fstring mach_acct;
|
fstring mach_acct;
|
||||||
|
|
||||||
pstring cur_dir;
|
|
||||||
pstring base_dir;
|
|
||||||
pstring file_sel;
|
|
||||||
|
|
||||||
fstring service;
|
|
||||||
fstring share;
|
|
||||||
fstring svc_type;
|
|
||||||
|
|
||||||
time_t newer_than;
|
|
||||||
int archive_level;
|
|
||||||
int dir_total;
|
|
||||||
int put_total_time_ms;
|
|
||||||
int put_total_size;
|
|
||||||
int get_total_time_ms;
|
|
||||||
int get_total_size;
|
|
||||||
int print_mode;
|
|
||||||
BOOL translation;
|
|
||||||
BOOL recurse_dir;
|
|
||||||
BOOL prompt;
|
|
||||||
BOOL lowercase;
|
|
||||||
BOOL abort_mget;
|
|
||||||
|
|
||||||
struct tar_client_info tar;
|
struct tar_client_info tar;
|
||||||
struct nt_client_info dom;
|
struct nt_client_info dom;
|
||||||
};
|
};
|
||||||
|
@ -3228,24 +3228,3 @@ BOOL become_user_permanently(uid_t uid, gid_t gid)
|
|||||||
return(True);
|
return(True);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL resolve_srv_name(const char* srv_name, fstring dest_host,
|
|
||||||
struct in_addr *ip)
|
|
||||||
{
|
|
||||||
DEBUG(10,("resolve_srv_name: %s\n", srv_name));
|
|
||||||
|
|
||||||
if (srv_name == NULL || strequal("\\\\.", srv_name))
|
|
||||||
{
|
|
||||||
fstrcpy(dest_host, global_myname);
|
|
||||||
ip = interpret_addr2("127.0.0.1");
|
|
||||||
return True;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strnequal("\\\\", srv_name, 2))
|
|
||||||
{
|
|
||||||
return False;
|
|
||||||
}
|
|
||||||
|
|
||||||
fstrcpy(dest_host, &srv_name[2]);
|
|
||||||
return resolve_name(dest_host, ip, 0x20);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
|
|
||||||
extern pstring scope;
|
extern pstring scope;
|
||||||
|
extern pstring global_myname;
|
||||||
extern int DEBUGLEVEL;
|
extern int DEBUGLEVEL;
|
||||||
|
|
||||||
/* nmbd.c sets this to True. */
|
/* nmbd.c sets this to True. */
|
||||||
@ -646,7 +647,30 @@ BOOL resolve_name(const char *name, struct in_addr *return_ip, int name_type)
|
|||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/********************************************************
|
||||||
|
resolve a name of format \\server_name or \\ipaddress
|
||||||
|
into a name. also, cut the \\ from the front for us.
|
||||||
|
*********************************************************/
|
||||||
|
BOOL resolve_srv_name(const char* srv_name, fstring dest_host,
|
||||||
|
struct in_addr *ip)
|
||||||
|
{
|
||||||
|
DEBUG(10,("resolve_srv_name: %s\n", srv_name));
|
||||||
|
|
||||||
|
if (srv_name == NULL || strequal("\\\\.", srv_name))
|
||||||
|
{
|
||||||
|
fstrcpy(dest_host, global_myname);
|
||||||
|
ip = interpret_addr2("127.0.0.1");
|
||||||
|
return True;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!strnequal("\\\\", srv_name, 2))
|
||||||
|
{
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
|
||||||
|
fstrcpy(dest_host, &srv_name[2]);
|
||||||
|
return resolve_name(dest_host, ip, 0x20);
|
||||||
|
}
|
||||||
|
|
||||||
/********************************************************
|
/********************************************************
|
||||||
find the IP address of the master browser or DMB for a workgroup
|
find the IP address of the master browser or DMB for a workgroup
|
||||||
|
@ -128,7 +128,7 @@ enumerate scheduled jobs
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
BOOL at_enum_jobs(struct cli_state *cli, uint16 fnum,
|
BOOL at_enum_jobs(struct cli_state *cli, uint16 fnum,
|
||||||
char *server_name, uint32 *num_jobs,
|
char *server_name, uint32 *num_jobs,
|
||||||
AT_ENUM_INFO *jobs, fstring *commands)
|
AT_ENUM_INFO *jobs, char ***commands)
|
||||||
{
|
{
|
||||||
prs_struct rbuf;
|
prs_struct rbuf;
|
||||||
prs_struct buf;
|
prs_struct buf;
|
||||||
@ -167,13 +167,18 @@ BOOL at_enum_jobs(struct cli_state *cli, uint16 fnum,
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
*num_jobs = r_e.num_entries;
|
*num_jobs = 0;
|
||||||
memcpy(jobs, &r_e.info, r_e.num_entries * sizeof(AT_ENUM_INFO));
|
memcpy(jobs, &r_e.info, r_e.num_entries * sizeof(AT_ENUM_INFO));
|
||||||
|
|
||||||
for (i = 0; i < r_e.num_entries; i++)
|
for (i = 0; i < r_e.num_entries; i++)
|
||||||
{
|
{
|
||||||
unistr2_to_ascii(commands[i], &r_e.command[i],
|
fstring cmd;
|
||||||
sizeof(commands[i]));
|
unistr2_to_ascii(cmd, &r_e.command[i], sizeof(cmd));
|
||||||
|
add_chars_to_array(num_jobs, commands, cmd);
|
||||||
|
}
|
||||||
|
if ((*num_jobs) != r_e.num_entries)
|
||||||
|
{
|
||||||
|
p = False;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2444,6 +2444,7 @@ BOOL samr_query_dispinfo( POLICY_HND *pol_domain, uint16 level,
|
|||||||
if (p && r_o.ptr_entries != 0)
|
if (p && r_o.ptr_entries != 0)
|
||||||
{
|
{
|
||||||
valid_query = True;
|
valid_query = True;
|
||||||
|
(*num_entries) = r_o.num_entries;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1388,12 +1388,50 @@ BOOL msrpc_sam_create_dom_user(const char* srv_name, DOM_SID *sid1,
|
|||||||
|
|
||||||
if (res2)
|
if (res2)
|
||||||
{
|
{
|
||||||
DEBUG(5,("cmd_sam_create_dom_user: succeeded\n"));
|
DEBUG(5,("msrpc_sam_create_dom_user: succeeded\n"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DEBUG(5,("cmd_sam_create_dom_user: failed\n"));
|
DEBUG(5,("msrpc_sam_create_dom_user: failed\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return res2;
|
return res2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
experimental SAM query display info.
|
||||||
|
****************************************************************************/
|
||||||
|
BOOL msrpc_sam_query_dispinfo(const char* srv_name, const char* domain,
|
||||||
|
DOM_SID *sid1,
|
||||||
|
uint16 switch_value,
|
||||||
|
uint32 *num_entries, SAM_DISPINFO_CTR *ctr,
|
||||||
|
DISP_FN(disp_fn))
|
||||||
|
{
|
||||||
|
BOOL res = True;
|
||||||
|
BOOL res1 = True;
|
||||||
|
uint32 ace_perms = 0x304; /* absolutely no idea. */
|
||||||
|
POLICY_HND sam_pol;
|
||||||
|
POLICY_HND pol_dom;
|
||||||
|
|
||||||
|
/* establish a connection. */
|
||||||
|
res = res ? samr_connect( srv_name, 0x02000000, &sam_pol) : False;
|
||||||
|
|
||||||
|
/* connect to the domain */
|
||||||
|
res = res ? samr_open_domain( &sam_pol, ace_perms, sid1,
|
||||||
|
&pol_dom) : False;
|
||||||
|
|
||||||
|
/* send a samr query_disp_info command */
|
||||||
|
res1 = res ? samr_query_dispinfo( &pol_dom, switch_value,
|
||||||
|
num_entries, ctr) : False;
|
||||||
|
|
||||||
|
res = res ? samr_close(&sam_pol) : False;
|
||||||
|
res = res ? samr_close(&pol_dom) : False;
|
||||||
|
|
||||||
|
if (res1 && disp_fn != NULL)
|
||||||
|
{
|
||||||
|
disp_fn(domain, sid1, switch_value, *num_entries, ctr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -344,16 +344,18 @@ void cmd_at(struct client_info *info, int argc, char *argv[])
|
|||||||
else if (jobid == -1) /* enumerate */
|
else if (jobid == -1) /* enumerate */
|
||||||
{
|
{
|
||||||
AT_ENUM_INFO jobs[AT_MAX_JOBS];
|
AT_ENUM_INFO jobs[AT_MAX_JOBS];
|
||||||
fstring commands[AT_MAX_JOBS];
|
char **commands;
|
||||||
uint32 num_jobs;
|
uint32 num_jobs;
|
||||||
|
|
||||||
if (at_enum_jobs(smb_cli, nt_pipe_fnum, dest_wks, &num_jobs,
|
if (at_enum_jobs(smb_cli, nt_pipe_fnum, dest_wks, &num_jobs,
|
||||||
jobs, commands))
|
jobs, &commands))
|
||||||
{
|
{
|
||||||
display_at_enum_info(out_hnd, ACTION_HEADER , num_jobs, jobs, commands);
|
display_at_enum_info(out_hnd, ACTION_HEADER , num_jobs, jobs, commands);
|
||||||
display_at_enum_info(out_hnd, ACTION_ENUMERATE, num_jobs, jobs, commands);
|
display_at_enum_info(out_hnd, ACTION_ENUMERATE, num_jobs, jobs, commands);
|
||||||
display_at_enum_info(out_hnd, ACTION_FOOTER , num_jobs, jobs, commands);
|
display_at_enum_info(out_hnd, ACTION_FOOTER , num_jobs, jobs, commands);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free_char_array(num_jobs, commands);
|
||||||
}
|
}
|
||||||
else /* job info */
|
else /* job info */
|
||||||
{
|
{
|
||||||
|
@ -294,13 +294,10 @@ void cmd_reg_enum(struct client_info *info, int argc, char *argv[])
|
|||||||
|
|
||||||
full_keyname = argv[1];
|
full_keyname = argv[1];
|
||||||
|
|
||||||
if (msrpc_reg_enum_key(srv_name, full_keyname,
|
(void)(msrpc_reg_enum_key(srv_name, full_keyname,
|
||||||
reg_display_key,
|
reg_display_key,
|
||||||
reg_display_key_info,
|
reg_display_key_info,
|
||||||
reg_display_val_info))
|
reg_display_val_info));
|
||||||
{
|
|
||||||
pstrcpy(info->cur_dir, full_keyname);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -1104,9 +1101,6 @@ void cmd_reg_shutdown(struct client_info *info, int argc, char *argv[])
|
|||||||
fstrcat(srv_name, info->dest_host);
|
fstrcat(srv_name, info->dest_host);
|
||||||
strupper(srv_name);
|
strupper(srv_name);
|
||||||
|
|
||||||
argc--;
|
|
||||||
argv++;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv,"fim:t:r-")) != EOF)
|
while ((opt = getopt(argc, argv,"fim:t:r-")) != EOF)
|
||||||
{
|
{
|
||||||
switch (opt)
|
switch (opt)
|
||||||
|
@ -278,15 +278,13 @@ void cmd_sam_lookup_domain(struct client_info *info, int argc, char *argv[])
|
|||||||
report(out_hnd, "Lookup Domain in SAM Server\n");
|
report(out_hnd, "Lookup Domain in SAM Server\n");
|
||||||
|
|
||||||
/* establish a connection. */
|
/* establish a connection. */
|
||||||
res = res ? samr_connect(
|
res = res ? samr_connect( srv_name, 0x02000000,
|
||||||
srv_name, 0x02000000,
|
|
||||||
&sam_pol) : False;
|
&sam_pol) : False;
|
||||||
|
|
||||||
/* connect to the domain */
|
/* connect to the domain */
|
||||||
res = res ? samr_query_lookup_domain(
|
res = res ? samr_query_lookup_domain( &sam_pol, domain, &dom_sid) : False;
|
||||||
&sam_pol, domain, &dom_sid) : False;
|
|
||||||
|
|
||||||
res = res ? samr_close( &sam_pol) : False;
|
res = res ? samr_close(&sam_pol) : False;
|
||||||
|
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
@ -350,18 +348,15 @@ void cmd_sam_del_aliasmem(struct client_info *info, int argc, char *argv[])
|
|||||||
report(out_hnd, "SAM Domain Alias Member\n");
|
report(out_hnd, "SAM Domain Alias Member\n");
|
||||||
|
|
||||||
/* establish a connection. */
|
/* establish a connection. */
|
||||||
res = res ? samr_connect(
|
res = res ? samr_connect( srv_name, 0x02000000,
|
||||||
srv_name, 0x02000000,
|
|
||||||
&sam_pol) : False;
|
&sam_pol) : False;
|
||||||
|
|
||||||
/* connect to the domain */
|
/* connect to the domain */
|
||||||
res = res ? samr_open_domain(
|
res = res ? samr_open_domain( &sam_pol, ace_perms, &sid1,
|
||||||
&sam_pol, ace_perms, &sid1,
|
|
||||||
&pol_dom) : False;
|
&pol_dom) : False;
|
||||||
|
|
||||||
/* connect to the domain */
|
/* connect to the domain */
|
||||||
res1 = res ? samr_open_alias(
|
res1 = res ? samr_open_alias( &pol_dom,
|
||||||
&pol_dom,
|
|
||||||
0x000f001f, alias_rid, &alias_pol) : False;
|
0x000f001f, alias_rid, &alias_pol) : False;
|
||||||
|
|
||||||
while (argc > 0 && res2 && res1)
|
while (argc > 0 && res2 && res1)
|
||||||
@ -370,7 +365,7 @@ void cmd_sam_del_aliasmem(struct client_info *info, int argc, char *argv[])
|
|||||||
argv++;
|
argv++;
|
||||||
/* get a sid, delete a member from the alias */
|
/* get a sid, delete a member from the alias */
|
||||||
res2 = res2 ? string_to_sid(&member_sid, argv[0]) : False;
|
res2 = res2 ? string_to_sid(&member_sid, argv[0]) : False;
|
||||||
res2 = res2 ? samr_del_aliasmem( &alias_pol, &member_sid) : False;
|
res2 = res2 ? samr_del_aliasmem(&alias_pol, &member_sid) : False;
|
||||||
|
|
||||||
if (res2)
|
if (res2)
|
||||||
{
|
{
|
||||||
@ -378,9 +373,9 @@ void cmd_sam_del_aliasmem(struct client_info *info, int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res1 = res1 ? samr_close( &alias_pol) : False;
|
res1 = res1 ? samr_close(&alias_pol) : False;
|
||||||
res = res ? samr_close( &pol_dom) : False;
|
res = res ? samr_close(&pol_dom) : False;
|
||||||
res = res ? samr_close( &sam_pol) : False;
|
res = res ? samr_close(&sam_pol) : False;
|
||||||
|
|
||||||
if (res && res1 && res2)
|
if (res && res1 && res2)
|
||||||
{
|
{
|
||||||
@ -442,19 +437,16 @@ void cmd_sam_delete_dom_alias(struct client_info *info, int argc, char *argv[])
|
|||||||
report(out_hnd, "SAM Delete Domain Alias\n");
|
report(out_hnd, "SAM Delete Domain Alias\n");
|
||||||
|
|
||||||
/* establish a connection. */
|
/* establish a connection. */
|
||||||
res = res ? samr_connect(
|
res = res ? samr_connect( srv_name, 0x02000000,
|
||||||
srv_name, 0x02000000,
|
|
||||||
&sam_pol) : False;
|
&sam_pol) : False;
|
||||||
|
|
||||||
/* connect to the domain */
|
/* connect to the domain */
|
||||||
res = res ? samr_open_domain(
|
res = res ? samr_open_domain( &sam_pol, ace_perms, &sid1,
|
||||||
&sam_pol, ace_perms, &sid1,
|
|
||||||
&pol_dom) : False;
|
&pol_dom) : False;
|
||||||
|
|
||||||
names[0] = name;
|
names[0] = name;
|
||||||
|
|
||||||
res1 = res ? samr_query_lookup_names(
|
res1 = res ? samr_query_lookup_names( &pol_dom, 0x000003e8,
|
||||||
&pol_dom, 0x000003e8,
|
|
||||||
1, names,
|
1, names,
|
||||||
&num_rids, rid, type) : False;
|
&num_rids, rid, type) : False;
|
||||||
|
|
||||||
@ -464,15 +456,14 @@ void cmd_sam_delete_dom_alias(struct client_info *info, int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* connect to the domain */
|
/* connect to the domain */
|
||||||
res1 = res1 ? samr_open_alias(
|
res1 = res1 ? samr_open_alias( &pol_dom,
|
||||||
&pol_dom,
|
|
||||||
0x000f001f, alias_rid, &alias_pol) : False;
|
0x000f001f, alias_rid, &alias_pol) : False;
|
||||||
|
|
||||||
res2 = res1 ? samr_delete_dom_alias( &alias_pol) : False;
|
res2 = res1 ? samr_delete_dom_alias(&alias_pol) : False;
|
||||||
|
|
||||||
res1 = res1 ? samr_close( &alias_pol) : False;
|
res1 = res1 ? samr_close(&alias_pol) : False;
|
||||||
res = res ? samr_close( &pol_dom) : False;
|
res = res ? samr_close(&pol_dom) : False;
|
||||||
res = res ? samr_close( &sam_pol) : False;
|
res = res ? samr_close(&sam_pol) : False;
|
||||||
|
|
||||||
if (res && res1 && res2)
|
if (res && res1 && res2)
|
||||||
{
|
{
|
||||||
@ -539,11 +530,11 @@ void cmd_sam_add_aliasmem(struct client_info *info, int argc, char *argv[])
|
|||||||
report(out_hnd, "SAM Domain Alias Member\n");
|
report(out_hnd, "SAM Domain Alias Member\n");
|
||||||
|
|
||||||
/* lookup domain controller; receive a policy handle */
|
/* lookup domain controller; receive a policy handle */
|
||||||
res3 = res3 ? lsa_open_policy( srv_name,
|
res3 = res3 ? lsa_open_policy(srv_name,
|
||||||
&lsa_pol, True) : False;
|
&lsa_pol, True) : False;
|
||||||
|
|
||||||
/* send lsa lookup sids call */
|
/* send lsa lookup sids call */
|
||||||
res4 = res3 ? lsa_lookup_names( &lsa_pol,
|
res4 = res3 ? lsa_lookup_names(&lsa_pol,
|
||||||
num_names, names,
|
num_names, names,
|
||||||
&sids, NULL, &num_sids) : False;
|
&sids, NULL, &num_sids) : False;
|
||||||
|
|
||||||
@ -572,24 +563,21 @@ void cmd_sam_add_aliasmem(struct client_info *info, int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* establish a connection. */
|
/* establish a connection. */
|
||||||
res = res ? samr_connect(
|
res = res ? samr_connect( srv_name, 0x02000000,
|
||||||
srv_name, 0x02000000,
|
|
||||||
&sam_pol) : False;
|
&sam_pol) : False;
|
||||||
|
|
||||||
/* connect to the domain */
|
/* connect to the domain */
|
||||||
res = res ? samr_open_domain(
|
res = res ? samr_open_domain( &sam_pol, ace_perms, &sid1,
|
||||||
&sam_pol, ace_perms, &sid1,
|
|
||||||
&pol_dom) : False;
|
&pol_dom) : False;
|
||||||
|
|
||||||
/* connect to the domain */
|
/* connect to the domain */
|
||||||
res1 = res ? samr_open_alias(
|
res1 = res ? samr_open_alias( &pol_dom,
|
||||||
&pol_dom,
|
|
||||||
0x000f001f, alias_rid, &alias_pol) : False;
|
0x000f001f, alias_rid, &alias_pol) : False;
|
||||||
|
|
||||||
for (i = 1; i < num_sids && res2 && res1; i++)
|
for (i = 1; i < num_sids && res2 && res1; i++)
|
||||||
{
|
{
|
||||||
/* add a member to the alias */
|
/* add a member to the alias */
|
||||||
res2 = res2 ? samr_add_aliasmem( &alias_pol, &sids[i]) : False;
|
res2 = res2 ? samr_add_aliasmem(&alias_pol, &sids[i]) : False;
|
||||||
|
|
||||||
if (res2)
|
if (res2)
|
||||||
{
|
{
|
||||||
@ -598,9 +586,9 @@ void cmd_sam_add_aliasmem(struct client_info *info, int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res1 = res1 ? samr_close( &alias_pol) : False;
|
res1 = res1 ? samr_close(&alias_pol) : False;
|
||||||
res = res ? samr_close( &pol_dom) : False;
|
res = res ? samr_close(&pol_dom) : False;
|
||||||
res = res ? samr_close( &sam_pol) : False;
|
res = res ? samr_close(&sam_pol) : False;
|
||||||
|
|
||||||
if (sids != NULL)
|
if (sids != NULL)
|
||||||
{
|
{
|
||||||
@ -743,9 +731,6 @@ void cmd_sam_create_dom_user(struct client_info *info, int argc, char *argv[])
|
|||||||
acb_info = ACB_WSTRUST;
|
acb_info = ACB_WSTRUST;
|
||||||
}
|
}
|
||||||
|
|
||||||
argc--;
|
|
||||||
argv++;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv,"is")) != EOF)
|
while ((opt = getopt(argc, argv,"is")) != EOF)
|
||||||
{
|
{
|
||||||
switch (opt)
|
switch (opt)
|
||||||
@ -834,25 +819,20 @@ void cmd_sam_create_dom_alias(struct client_info *info, int argc, char *argv[])
|
|||||||
domain, acct_name, acct_desc);
|
domain, acct_name, acct_desc);
|
||||||
|
|
||||||
/* establish a connection. */
|
/* establish a connection. */
|
||||||
res = res ? samr_connect(
|
res = res ? samr_connect( srv_name, 0x02000000,
|
||||||
srv_name, 0x02000000,
|
|
||||||
&sam_pol) : False;
|
&sam_pol) : False;
|
||||||
|
|
||||||
/* connect to the domain */
|
/* connect to the domain */
|
||||||
res = res ? samr_open_domain(
|
res = res ? samr_open_domain( &sam_pol, ace_perms, &sid1,
|
||||||
&sam_pol, ace_perms, &sid1,
|
|
||||||
&pol_dom) : False;
|
&pol_dom) : False;
|
||||||
|
|
||||||
/* create a domain alias */
|
/* create a domain alias */
|
||||||
res1 = res ? create_samr_domain_alias(
|
res1 = res ? create_samr_domain_alias( &pol_dom,
|
||||||
&pol_dom,
|
|
||||||
acct_name, acct_desc, &alias_rid) : False;
|
acct_name, acct_desc, &alias_rid) : False;
|
||||||
|
|
||||||
res = res ? samr_close(
|
res = res ? samr_close( &pol_dom) : False;
|
||||||
&pol_dom) : False;
|
|
||||||
|
|
||||||
res = res ? samr_close(
|
res = res ? samr_close( &sam_pol) : False;
|
||||||
&sam_pol) : False;
|
|
||||||
|
|
||||||
if (res && res1)
|
if (res && res1)
|
||||||
{
|
{
|
||||||
@ -914,18 +894,15 @@ void cmd_sam_del_groupmem(struct client_info *info, int argc, char *argv[])
|
|||||||
report(out_hnd, "SAM Add Domain Group member\n");
|
report(out_hnd, "SAM Add Domain Group member\n");
|
||||||
|
|
||||||
/* establish a connection. */
|
/* establish a connection. */
|
||||||
res = res ? samr_connect(
|
res = res ? samr_connect( srv_name, 0x02000000,
|
||||||
srv_name, 0x02000000,
|
|
||||||
&sam_pol) : False;
|
&sam_pol) : False;
|
||||||
|
|
||||||
/* connect to the domain */
|
/* connect to the domain */
|
||||||
res = res ? samr_open_domain(
|
res = res ? samr_open_domain( &sam_pol, ace_perms, &sid1,
|
||||||
&sam_pol, ace_perms, &sid1,
|
|
||||||
&pol_dom) : False;
|
&pol_dom) : False;
|
||||||
|
|
||||||
/* connect to the domain */
|
/* connect to the domain */
|
||||||
res1 = res ? samr_open_group(
|
res1 = res ? samr_open_group( &pol_dom,
|
||||||
&pol_dom,
|
|
||||||
0x0000001f, group_rid, &pol_grp) : False;
|
0x0000001f, group_rid, &pol_grp) : False;
|
||||||
|
|
||||||
while (argc > 0 && res2 && res1)
|
while (argc > 0 && res2 && res1)
|
||||||
@ -935,7 +912,7 @@ void cmd_sam_del_groupmem(struct client_info *info, int argc, char *argv[])
|
|||||||
|
|
||||||
/* get a rid, delete a member from the group */
|
/* get a rid, delete a member from the group */
|
||||||
member_rid = get_number(argv[0]);
|
member_rid = get_number(argv[0]);
|
||||||
res2 = res2 ? samr_del_groupmem( &pol_grp, member_rid) : False;
|
res2 = res2 ? samr_del_groupmem(&pol_grp, member_rid) : False;
|
||||||
|
|
||||||
if (res2)
|
if (res2)
|
||||||
{
|
{
|
||||||
@ -943,9 +920,9 @@ void cmd_sam_del_groupmem(struct client_info *info, int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res1 = res1 ? samr_close( &pol_grp) : False;
|
res1 = res1 ? samr_close(&pol_grp) : False;
|
||||||
res = res ? samr_close( &pol_dom) : False;
|
res = res ? samr_close(&pol_dom) : False;
|
||||||
res = res ? samr_close( &sam_pol) : False;
|
res = res ? samr_close(&sam_pol) : False;
|
||||||
|
|
||||||
if (res && res1 && res2)
|
if (res && res1 && res2)
|
||||||
{
|
{
|
||||||
@ -1008,19 +985,16 @@ void cmd_sam_delete_dom_group(struct client_info *info, int argc, char *argv[])
|
|||||||
report(out_hnd, "SAM Delete Domain Group\n");
|
report(out_hnd, "SAM Delete Domain Group\n");
|
||||||
|
|
||||||
/* establish a connection. */
|
/* establish a connection. */
|
||||||
res = res ? samr_connect(
|
res = res ? samr_connect( srv_name, 0x02000000,
|
||||||
srv_name, 0x02000000,
|
|
||||||
&sam_pol) : False;
|
&sam_pol) : False;
|
||||||
|
|
||||||
/* connect to the domain */
|
/* connect to the domain */
|
||||||
res = res ? samr_open_domain(
|
res = res ? samr_open_domain( &sam_pol, ace_perms, &sid1,
|
||||||
&sam_pol, ace_perms, &sid1,
|
|
||||||
&pol_dom) : False;
|
&pol_dom) : False;
|
||||||
|
|
||||||
names[0] = name;
|
names[0] = name;
|
||||||
|
|
||||||
res1 = res ? samr_query_lookup_names(
|
res1 = res ? samr_query_lookup_names( &pol_dom, 0x000003e8,
|
||||||
&pol_dom, 0x000003e8,
|
|
||||||
1, names,
|
1, names,
|
||||||
&num_rids, rid, type) : False;
|
&num_rids, rid, type) : False;
|
||||||
|
|
||||||
@ -1030,15 +1004,14 @@ void cmd_sam_delete_dom_group(struct client_info *info, int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* connect to the domain */
|
/* connect to the domain */
|
||||||
res1 = res1 ? samr_open_group(
|
res1 = res1 ? samr_open_group( &pol_dom,
|
||||||
&pol_dom,
|
|
||||||
0x0000001f, group_rid, &pol_grp) : False;
|
0x0000001f, group_rid, &pol_grp) : False;
|
||||||
|
|
||||||
res2 = res1 ? samr_delete_dom_group( &pol_grp) : False;
|
res2 = res1 ? samr_delete_dom_group(&pol_grp) : False;
|
||||||
|
|
||||||
res1 = res1 ? samr_close( &pol_grp) : False;
|
res1 = res1 ? samr_close(&pol_grp) : False;
|
||||||
res = res ? samr_close( &pol_dom) : False;
|
res = res ? samr_close(&pol_dom) : False;
|
||||||
res = res ? samr_close( &sam_pol) : False;
|
res = res ? samr_close(&sam_pol) : False;
|
||||||
|
|
||||||
if (res && res1 && res2)
|
if (res && res1 && res2)
|
||||||
{
|
{
|
||||||
@ -1121,40 +1094,33 @@ void cmd_sam_add_groupmem(struct client_info *info, int argc, char *argv[])
|
|||||||
report(out_hnd, "SAM Add Domain Group member\n");
|
report(out_hnd, "SAM Add Domain Group member\n");
|
||||||
|
|
||||||
/* establish a connection. */
|
/* establish a connection. */
|
||||||
res = res ? samr_connect(
|
res = res ? samr_connect( srv_name, 0x02000000,
|
||||||
srv_name, 0x02000000,
|
|
||||||
&sam_pol) : False;
|
&sam_pol) : False;
|
||||||
|
|
||||||
/* connect to the domain */
|
/* connect to the domain */
|
||||||
res4 = res ? samr_open_domain(
|
res4 = res ? samr_open_domain( &sam_pol, ace_perms, &sid1,
|
||||||
&sam_pol, ace_perms, &sid1,
|
|
||||||
&pol_dom) : False;
|
&pol_dom) : False;
|
||||||
|
|
||||||
/* connect to the domain */
|
/* connect to the domain */
|
||||||
res3 = res ? samr_open_domain(
|
res3 = res ? samr_open_domain( &sam_pol, ace_perms, &sid_1_5_20,
|
||||||
&sam_pol, ace_perms, &sid_1_5_20,
|
|
||||||
&pol_blt) : False;
|
&pol_blt) : False;
|
||||||
|
|
||||||
res2 = res4 ? samr_query_lookup_names(
|
res2 = res4 ? samr_query_lookup_names( &pol_dom, 0x000003e8,
|
||||||
&pol_dom, 0x000003e8,
|
|
||||||
1, group_names,
|
1, group_names,
|
||||||
&num_group_rids, group_rid, group_type) : False;
|
&num_group_rids, group_rid, group_type) : False;
|
||||||
|
|
||||||
/* open the group */
|
/* open the group */
|
||||||
res2 = res2 ? samr_open_group(
|
res2 = res2 ? samr_open_group( &pol_dom,
|
||||||
&pol_dom,
|
|
||||||
0x0000001f, group_rid[0], &pol_grp) : False;
|
0x0000001f, group_rid[0], &pol_grp) : False;
|
||||||
|
|
||||||
if (!res2 || (group_type != NULL && group_type[0] == SID_NAME_UNKNOWN))
|
if (!res2 || (group_type != NULL && group_type[0] == SID_NAME_UNKNOWN))
|
||||||
{
|
{
|
||||||
res2 = res3 ? samr_query_lookup_names(
|
res2 = res3 ? samr_query_lookup_names( &pol_blt, 0x000003e8,
|
||||||
&pol_blt, 0x000003e8,
|
|
||||||
1, group_names,
|
1, group_names,
|
||||||
&num_group_rids, group_rid, group_type) : False;
|
&num_group_rids, group_rid, group_type) : False;
|
||||||
|
|
||||||
/* open the group */
|
/* open the group */
|
||||||
res2 = res2 ? samr_open_group(
|
res2 = res2 ? samr_open_group( &pol_blt,
|
||||||
&pol_blt,
|
|
||||||
0x0000001f, group_rid[0], &pol_grp) : False;
|
0x0000001f, group_rid[0], &pol_grp) : False;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1164,8 +1130,7 @@ void cmd_sam_add_groupmem(struct client_info *info, int argc, char *argv[])
|
|||||||
group_name);
|
group_name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
res1 = res2 ? samr_query_lookup_names(
|
res1 = res2 ? samr_query_lookup_names( &pol_dom, 0x000003e8,
|
||||||
&pol_dom, 0x000003e8,
|
|
||||||
num_names, names,
|
num_names, names,
|
||||||
&num_rids, rid, type) : False;
|
&num_rids, rid, type) : False;
|
||||||
|
|
||||||
@ -1181,7 +1146,7 @@ void cmd_sam_add_groupmem(struct client_info *info, int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (samr_add_groupmem( &pol_grp, rid[i]))
|
if (samr_add_groupmem(&pol_grp, rid[i]))
|
||||||
{
|
{
|
||||||
report(out_hnd, "RID added to Group 0x%x: 0x%x\n",
|
report(out_hnd, "RID added to Group 0x%x: 0x%x\n",
|
||||||
group_rid[0], rid[i]);
|
group_rid[0], rid[i]);
|
||||||
@ -1189,10 +1154,10 @@ void cmd_sam_add_groupmem(struct client_info *info, int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
res1 = res ? samr_close( &pol_grp) : False;
|
res1 = res ? samr_close(&pol_grp) : False;
|
||||||
res1 = res3 ? samr_close( &pol_blt) : False;
|
res1 = res3 ? samr_close(&pol_blt) : False;
|
||||||
res1 = res4 ? samr_close( &pol_dom) : False;
|
res1 = res4 ? samr_close(&pol_dom) : False;
|
||||||
res = res ? samr_close( &sam_pol) : False;
|
res = res ? samr_close(&sam_pol) : False;
|
||||||
|
|
||||||
free_char_array(num_names, names);
|
free_char_array(num_names, names);
|
||||||
|
|
||||||
@ -1274,25 +1239,20 @@ void cmd_sam_create_dom_group(struct client_info *info, int argc, char *argv[])
|
|||||||
domain, acct_name, acct_desc);
|
domain, acct_name, acct_desc);
|
||||||
|
|
||||||
/* establish a connection. */
|
/* establish a connection. */
|
||||||
res = res ? samr_connect(
|
res = res ? samr_connect( srv_name, 0x02000000,
|
||||||
srv_name, 0x02000000,
|
|
||||||
&sam_pol) : False;
|
&sam_pol) : False;
|
||||||
|
|
||||||
/* connect to the domain */
|
/* connect to the domain */
|
||||||
res = res ? samr_open_domain(
|
res = res ? samr_open_domain( &sam_pol, ace_perms, &sid1,
|
||||||
&sam_pol, ace_perms, &sid1,
|
|
||||||
&pol_dom) : False;
|
&pol_dom) : False;
|
||||||
|
|
||||||
/* read some users */
|
/* read some users */
|
||||||
res1 = res ? create_samr_domain_group(
|
res1 = res ? create_samr_domain_group( &pol_dom,
|
||||||
&pol_dom,
|
|
||||||
acct_name, acct_desc, &group_rid) : False;
|
acct_name, acct_desc, &group_rid) : False;
|
||||||
|
|
||||||
res = res ? samr_close(
|
res = res ? samr_close( &pol_dom) : False;
|
||||||
&pol_dom) : False;
|
|
||||||
|
|
||||||
res = res ? samr_close(
|
res = res ? samr_close( &sam_pol) : False;
|
||||||
&sam_pol) : False;
|
|
||||||
|
|
||||||
if (res && res1)
|
if (res && res1)
|
||||||
{
|
{
|
||||||
@ -1336,9 +1296,6 @@ void cmd_sam_enum_users(struct client_info *info, int argc, char *argv[])
|
|||||||
fstrcat(srv_name, info->dest_host);
|
fstrcat(srv_name, info->dest_host);
|
||||||
strupper(srv_name);
|
strupper(srv_name);
|
||||||
|
|
||||||
argc--;
|
|
||||||
argv++;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "uga")) != EOF)
|
while ((opt = getopt(argc, argv, "uga")) != EOF)
|
||||||
{
|
{
|
||||||
switch (opt)
|
switch (opt)
|
||||||
@ -1363,7 +1320,7 @@ void cmd_sam_enum_users(struct client_info *info, int argc, char *argv[])
|
|||||||
|
|
||||||
report(out_hnd, "SAM Enumerate Users\n");
|
report(out_hnd, "SAM Enumerate Users\n");
|
||||||
|
|
||||||
msrpc_sam_enum_users( srv_name, domain, &sid1,
|
msrpc_sam_enum_users(srv_name, domain, &sid1,
|
||||||
&sam, &num_sam_entries,
|
&sam, &num_sam_entries,
|
||||||
sam_display_user,
|
sam_display_user,
|
||||||
request_user_info ? sam_display_user_info : NULL,
|
request_user_info ? sam_display_user_info : NULL,
|
||||||
@ -1425,26 +1382,22 @@ void cmd_sam_query_groupmem(struct client_info *info, int argc, char *argv[])
|
|||||||
info->myhostname, srv_name, domain, sid_str);
|
info->myhostname, srv_name, domain, sid_str);
|
||||||
|
|
||||||
/* establish a connection. */
|
/* establish a connection. */
|
||||||
res = res ? samr_connect(
|
res = res ? samr_connect( srv_name, 0x02000000,
|
||||||
srv_name, 0x02000000,
|
|
||||||
&sam_pol) : False;
|
&sam_pol) : False;
|
||||||
|
|
||||||
/* connect to the domain */
|
/* connect to the domain */
|
||||||
res = res ? samr_open_domain(
|
res = res ? samr_open_domain( &sam_pol, 0x304, &sid,
|
||||||
&sam_pol, 0x304, &sid,
|
|
||||||
&pol_dom) : False;
|
&pol_dom) : False;
|
||||||
|
|
||||||
/* look up group rid */
|
/* look up group rid */
|
||||||
names[0] = group_name;
|
names[0] = group_name;
|
||||||
res1 = res ? samr_query_lookup_names(
|
res1 = res ? samr_query_lookup_names( &pol_dom, 0x3e8,
|
||||||
&pol_dom, 0x3e8,
|
|
||||||
1, names,
|
1, names,
|
||||||
&num_rids, rid, type) : False;
|
&num_rids, rid, type) : False;
|
||||||
|
|
||||||
if (res1 && num_rids == 1)
|
if (res1 && num_rids == 1)
|
||||||
{
|
{
|
||||||
res1 = req_groupmem_info(
|
res1 = req_groupmem_info( &pol_dom,
|
||||||
&pol_dom,
|
|
||||||
domain,
|
domain,
|
||||||
&sid,
|
&sid,
|
||||||
rid[0],
|
rid[0],
|
||||||
@ -1452,11 +1405,9 @@ void cmd_sam_query_groupmem(struct client_info *info, int argc, char *argv[])
|
|||||||
sam_display_group_members);
|
sam_display_group_members);
|
||||||
}
|
}
|
||||||
|
|
||||||
res = res ? samr_close(
|
res = res ? samr_close( &sam_pol) : False;
|
||||||
&sam_pol) : False;
|
|
||||||
|
|
||||||
res = res ? samr_close(
|
res = res ? samr_close( &pol_dom) : False;
|
||||||
&pol_dom) : False;
|
|
||||||
|
|
||||||
if (res1)
|
if (res1)
|
||||||
{
|
{
|
||||||
@ -1517,37 +1468,31 @@ void cmd_sam_query_group(struct client_info *info, int argc, char *argv[])
|
|||||||
info->myhostname, srv_name, domain, sid_str);
|
info->myhostname, srv_name, domain, sid_str);
|
||||||
|
|
||||||
/* establish a connection. */
|
/* establish a connection. */
|
||||||
res = res ? samr_connect(
|
res = res ? samr_connect( srv_name, 0x02000000,
|
||||||
srv_name, 0x02000000,
|
|
||||||
&sam_pol) : False;
|
&sam_pol) : False;
|
||||||
|
|
||||||
/* connect to the domain */
|
/* connect to the domain */
|
||||||
res = res ? samr_open_domain(
|
res = res ? samr_open_domain( &sam_pol, 0x304, &sid,
|
||||||
&sam_pol, 0x304, &sid,
|
|
||||||
&pol_dom) : False;
|
&pol_dom) : False;
|
||||||
|
|
||||||
/* look up group rid */
|
/* look up group rid */
|
||||||
names[0] = group_name;
|
names[0] = group_name;
|
||||||
res1 = res ? samr_query_lookup_names(
|
res1 = res ? samr_query_lookup_names( &pol_dom, 0x3e8,
|
||||||
&pol_dom, 0x3e8,
|
|
||||||
1, names,
|
1, names,
|
||||||
&num_rids, rid, type) : False;
|
&num_rids, rid, type) : False;
|
||||||
|
|
||||||
if (res1 && num_rids == 1)
|
if (res1 && num_rids == 1)
|
||||||
{
|
{
|
||||||
res1 = query_groupinfo(
|
res1 = query_groupinfo( &pol_dom,
|
||||||
&pol_dom,
|
|
||||||
domain,
|
domain,
|
||||||
&sid,
|
&sid,
|
||||||
rid[0],
|
rid[0],
|
||||||
sam_display_group_info);
|
sam_display_group_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
res = res ? samr_close(
|
res = res ? samr_close( &sam_pol) : False;
|
||||||
&sam_pol) : False;
|
|
||||||
|
|
||||||
res = res ? samr_close(
|
res = res ? samr_close( &pol_dom) : False;
|
||||||
&pol_dom) : False;
|
|
||||||
|
|
||||||
if (res1)
|
if (res1)
|
||||||
{
|
{
|
||||||
@ -1608,37 +1553,31 @@ void cmd_sam_query_user(struct client_info *info, int argc, char *argv[])
|
|||||||
info->myhostname, srv_name, domain, sid_str);
|
info->myhostname, srv_name, domain, sid_str);
|
||||||
|
|
||||||
/* establish a connection. */
|
/* establish a connection. */
|
||||||
res = res ? samr_connect(
|
res = res ? samr_connect( srv_name, 0x02000000,
|
||||||
srv_name, 0x02000000,
|
|
||||||
&sam_pol) : False;
|
&sam_pol) : False;
|
||||||
|
|
||||||
/* connect to the domain */
|
/* connect to the domain */
|
||||||
res = res ? samr_open_domain(
|
res = res ? samr_open_domain( &sam_pol, 0x304, &sid,
|
||||||
&sam_pol, 0x304, &sid,
|
|
||||||
&pol_dom) : False;
|
&pol_dom) : False;
|
||||||
|
|
||||||
/* look up user rid */
|
/* look up user rid */
|
||||||
names[0] = user_name;
|
names[0] = user_name;
|
||||||
res1 = res ? samr_query_lookup_names(
|
res1 = res ? samr_query_lookup_names( &pol_dom, 0x3e8,
|
||||||
&pol_dom, 0x3e8,
|
|
||||||
1, names,
|
1, names,
|
||||||
&num_rids, rid, type) : False;
|
&num_rids, rid, type) : False;
|
||||||
|
|
||||||
/* send user info query */
|
/* send user info query */
|
||||||
if (res1 && num_rids == 1)
|
if (res1 && num_rids == 1)
|
||||||
{
|
{
|
||||||
res1 = req_user_info(
|
res1 = req_user_info( &pol_dom,
|
||||||
&pol_dom,
|
|
||||||
domain,
|
domain,
|
||||||
&sid,
|
&sid,
|
||||||
rid[0],
|
rid[0],
|
||||||
sam_display_user_info);
|
sam_display_user_info);
|
||||||
}
|
}
|
||||||
res = res ? samr_close(
|
res = res ? samr_close( &sam_pol) : False;
|
||||||
&sam_pol) : False;
|
|
||||||
|
|
||||||
res = res ? samr_close(
|
res = res ? samr_close( &pol_dom) : False;
|
||||||
&pol_dom) : False;
|
|
||||||
|
|
||||||
if (res1)
|
if (res1)
|
||||||
{
|
{
|
||||||
@ -1696,9 +1635,6 @@ void cmd_sam_set_userinfo2(struct client_info *info, int argc, char *argv[])
|
|||||||
|
|
||||||
safe_strcpy(user_name, argv[0], sizeof(user_name));
|
safe_strcpy(user_name, argv[0], sizeof(user_name));
|
||||||
|
|
||||||
argc--;
|
|
||||||
argv++;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv,"s:")) != EOF)
|
while ((opt = getopt(argc, argv,"s:")) != EOF)
|
||||||
{
|
{
|
||||||
switch (opt)
|
switch (opt)
|
||||||
@ -1721,25 +1657,21 @@ void cmd_sam_set_userinfo2(struct client_info *info, int argc, char *argv[])
|
|||||||
report(out_hnd, "SAM Set User Info: %s\n", user_name);
|
report(out_hnd, "SAM Set User Info: %s\n", user_name);
|
||||||
|
|
||||||
/* establish a connection. */
|
/* establish a connection. */
|
||||||
res = res ? samr_connect(
|
res = res ? samr_connect( srv_name, 0x02000000,
|
||||||
srv_name, 0x02000000,
|
|
||||||
&sam_pol) : False;
|
&sam_pol) : False;
|
||||||
|
|
||||||
/* connect to the domain */
|
/* connect to the domain */
|
||||||
res = res ? samr_open_domain(
|
res = res ? samr_open_domain( &sam_pol, 0x02000000, &sid,
|
||||||
&sam_pol, 0x02000000, &sid,
|
|
||||||
&pol_dom) : False;
|
&pol_dom) : False;
|
||||||
|
|
||||||
/* look up user rid */
|
/* look up user rid */
|
||||||
names[0] = user_name;
|
names[0] = user_name;
|
||||||
res1 = res ? samr_query_lookup_names(
|
res1 = res ? samr_query_lookup_names( &pol_dom, 0x3e8,
|
||||||
&pol_dom, 0x3e8,
|
|
||||||
1, names,
|
1, names,
|
||||||
&num_rids, rid, type) : False;
|
&num_rids, rid, type) : False;
|
||||||
|
|
||||||
/* send set user info */
|
/* send set user info */
|
||||||
if (res1 && num_rids == 1 && get_samr_query_userinfo(
|
if (res1 && num_rids == 1 && get_samr_query_userinfo( &pol_dom,
|
||||||
&pol_dom,
|
|
||||||
0x10, rid[0],
|
0x10, rid[0],
|
||||||
(void*)&usr16))
|
(void*)&usr16))
|
||||||
{
|
{
|
||||||
@ -1762,16 +1694,13 @@ void cmd_sam_set_userinfo2(struct client_info *info, int argc, char *argv[])
|
|||||||
|
|
||||||
if (usr != NULL)
|
if (usr != NULL)
|
||||||
{
|
{
|
||||||
res1 = set_samr_set_userinfo2(
|
res1 = set_samr_set_userinfo2( &pol_dom,
|
||||||
&pol_dom,
|
|
||||||
switch_value, rid[0], usr);
|
switch_value, rid[0], usr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res = res ? samr_close(
|
res = res ? samr_close( &sam_pol) : False;
|
||||||
&sam_pol) : False;
|
|
||||||
|
|
||||||
res = res ? samr_close(
|
res = res ? samr_close( &pol_dom) : False;
|
||||||
&pol_dom) : False;
|
|
||||||
|
|
||||||
if (res1)
|
if (res1)
|
||||||
{
|
{
|
||||||
@ -1830,10 +1759,7 @@ void cmd_sam_set_userinfo(struct client_info *info, int argc, char *argv[])
|
|||||||
|
|
||||||
safe_strcpy(user_name, argv[0], sizeof(user_name));
|
safe_strcpy(user_name, argv[0], sizeof(user_name));
|
||||||
|
|
||||||
argc--;
|
if (argc == 1)
|
||||||
argv++;
|
|
||||||
|
|
||||||
if (argc == 0)
|
|
||||||
{
|
{
|
||||||
fstring pass_str;
|
fstring pass_str;
|
||||||
char *pass;
|
char *pass;
|
||||||
@ -1875,25 +1801,21 @@ void cmd_sam_set_userinfo(struct client_info *info, int argc, char *argv[])
|
|||||||
report(out_hnd, "Password: %s\n", password);
|
report(out_hnd, "Password: %s\n", password);
|
||||||
|
|
||||||
/* establish a connection. */
|
/* establish a connection. */
|
||||||
res = res ? samr_connect(
|
res = res ? samr_connect( srv_name, 0x02000000,
|
||||||
srv_name, 0x02000000,
|
|
||||||
&sam_pol) : False;
|
&sam_pol) : False;
|
||||||
|
|
||||||
/* connect to the domain */
|
/* connect to the domain */
|
||||||
res = res ? samr_open_domain(
|
res = res ? samr_open_domain( &sam_pol, 0x02000000, &sid,
|
||||||
&sam_pol, 0x02000000, &sid,
|
|
||||||
&pol_dom) : False;
|
&pol_dom) : False;
|
||||||
|
|
||||||
/* look up user rid */
|
/* look up user rid */
|
||||||
names[0] = user_name;
|
names[0] = user_name;
|
||||||
res1 = res ? samr_query_lookup_names(
|
res1 = res ? samr_query_lookup_names( &pol_dom, 0x3e8,
|
||||||
&pol_dom, 0x3e8,
|
|
||||||
1, names,
|
1, names,
|
||||||
&num_rids, rid, type) : False;
|
&num_rids, rid, type) : False;
|
||||||
|
|
||||||
/* send set user info */
|
/* send set user info */
|
||||||
if (res1 && num_rids == 1 && get_samr_query_userinfo(
|
if (res1 && num_rids == 1 && get_samr_query_userinfo( &pol_dom,
|
||||||
&pol_dom,
|
|
||||||
0x15, rid[0], &usr21))
|
0x15, rid[0], &usr21))
|
||||||
{
|
{
|
||||||
void *usr = NULL;
|
void *usr = NULL;
|
||||||
@ -1954,16 +1876,13 @@ void cmd_sam_set_userinfo(struct client_info *info, int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
if (usr != NULL)
|
if (usr != NULL)
|
||||||
{
|
{
|
||||||
res1 = set_samr_set_userinfo(
|
res1 = set_samr_set_userinfo( &pol_dom,
|
||||||
&pol_dom,
|
|
||||||
switch_value, rid[0], usr);
|
switch_value, rid[0], usr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
res = res ? samr_close(
|
res = res ? samr_close( &sam_pol) : False;
|
||||||
&sam_pol) : False;
|
|
||||||
|
|
||||||
res = res ? samr_close(
|
res = res ? samr_close( &pol_dom) : False;
|
||||||
&pol_dom) : False;
|
|
||||||
|
|
||||||
if (res1)
|
if (res1)
|
||||||
{
|
{
|
||||||
@ -1977,6 +1896,17 @@ void cmd_sam_set_userinfo(struct client_info *info, int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void sam_display_disp_info(const char* domain, const DOM_SID *sid,
|
||||||
|
uint16 info, uint32 num,
|
||||||
|
SAM_DISPINFO_CTR *ctr)
|
||||||
|
|
||||||
|
{
|
||||||
|
report(out_hnd, "SAM Display Info for Domain %s\n", domain);
|
||||||
|
|
||||||
|
display_sam_disp_info_ctr(out_hnd, ACTION_HEADER , info, num, ctr);
|
||||||
|
display_sam_disp_info_ctr(out_hnd, ACTION_ENUMERATE, info, num, ctr);
|
||||||
|
display_sam_disp_info_ctr(out_hnd, ACTION_FOOTER , info, num, ctr);
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
experimental SAM query display info.
|
experimental SAM query display info.
|
||||||
@ -1987,14 +1917,10 @@ void cmd_sam_query_dispinfo(struct client_info *info, int argc, char *argv[])
|
|||||||
fstring domain;
|
fstring domain;
|
||||||
fstring sid;
|
fstring sid;
|
||||||
DOM_SID sid1;
|
DOM_SID sid1;
|
||||||
BOOL res = True;
|
|
||||||
uint16 switch_value = 1;
|
uint16 switch_value = 1;
|
||||||
uint32 ace_perms = 0x304; /* absolutely no idea. */
|
|
||||||
SAM_DISPINFO_CTR ctr;
|
SAM_DISPINFO_CTR ctr;
|
||||||
SAM_DISPINFO_1 inf1;
|
SAM_DISPINFO_1 inf1;
|
||||||
uint32 num_entries;
|
uint32 num_entries;
|
||||||
POLICY_HND sam_pol;
|
|
||||||
POLICY_HND pol_dom;
|
|
||||||
|
|
||||||
sid_to_string(sid, &info->dom.level5_sid);
|
sid_to_string(sid, &info->dom.level5_sid);
|
||||||
fstrcpy(domain, info->dom.level5_dom);
|
fstrcpy(domain, info->dom.level5_dom);
|
||||||
@ -2016,41 +1942,14 @@ void cmd_sam_query_dispinfo(struct client_info *info, int argc, char *argv[])
|
|||||||
switch_value = strtoul(argv[1], (char**)NULL, 10);
|
switch_value = strtoul(argv[1], (char**)NULL, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(out_hnd, "SAM Query Domain Info: info level %d\n", switch_value);
|
|
||||||
fprintf(out_hnd, "From: %s To: %s Domain: %s SID: %s\n",
|
|
||||||
info->myhostname, srv_name, domain, sid);
|
|
||||||
|
|
||||||
/* establish a connection. */
|
|
||||||
res = res ? samr_connect(
|
|
||||||
srv_name, 0x02000000,
|
|
||||||
&sam_pol) : False;
|
|
||||||
|
|
||||||
/* connect to the domain */
|
|
||||||
res = res ? samr_open_domain(
|
|
||||||
&sam_pol, ace_perms, &sid1,
|
|
||||||
&pol_dom) : False;
|
|
||||||
|
|
||||||
ctr.sam.info1 = &inf1;
|
ctr.sam.info1 = &inf1;
|
||||||
|
|
||||||
/* send a samr query_disp_info command */
|
if (msrpc_sam_query_dispinfo( srv_name, domain, &sid1,
|
||||||
res = res ? samr_query_dispinfo(
|
switch_value,
|
||||||
&pol_dom, switch_value,
|
&num_entries, &ctr, sam_display_disp_info))
|
||||||
&num_entries, &ctr) : False;
|
|
||||||
|
|
||||||
res = res ? samr_close(
|
|
||||||
&sam_pol) : False;
|
|
||||||
|
|
||||||
res = res ? samr_close(
|
|
||||||
&pol_dom) : False;
|
|
||||||
|
|
||||||
if (res)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
DEBUG(5,("cmd_sam_query_dispinfo: succeeded\n"));
|
DEBUG(5,("cmd_sam_query_dispinfo: succeeded\n"));
|
||||||
#if 0
|
|
||||||
display_sam_disp_info_ctr(out_hnd, ACTION_HEADER , switch_value, &ctr);
|
|
||||||
display_sam_disp_info_ctr(out_hnd, ACTION_ENUMERATE, switch_value, &ctr);
|
|
||||||
display_sam_disp_info_ctr(out_hnd, ACTION_FOOTER , switch_value, &ctr);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2094,7 +1993,7 @@ void cmd_sam_query_dominfo(struct client_info *info, int argc, char *argv[])
|
|||||||
report(out_hnd, "From: %s Domain: %s SID: %s\n",
|
report(out_hnd, "From: %s Domain: %s SID: %s\n",
|
||||||
info->myhostname, domain, sid);
|
info->myhostname, domain, sid);
|
||||||
|
|
||||||
if (sam_query_dominfo( srv_name, &sid1, switch_value, &ctr))
|
if (sam_query_dominfo(srv_name, &sid1, switch_value, &ctr))
|
||||||
{
|
{
|
||||||
DEBUG(5,("cmd_sam_query_dominfo: succeeded\n"));
|
DEBUG(5,("cmd_sam_query_dominfo: succeeded\n"));
|
||||||
display_sam_unk_ctr(out_hnd, ACTION_HEADER , switch_value, &ctr);
|
display_sam_unk_ctr(out_hnd, ACTION_HEADER , switch_value, &ctr);
|
||||||
@ -2155,25 +2054,22 @@ void cmd_sam_query_aliasmem(struct client_info *info, int argc, char *argv[])
|
|||||||
info->myhostname, srv_name, domain, sid_str);
|
info->myhostname, srv_name, domain, sid_str);
|
||||||
|
|
||||||
/* establish a connection. */
|
/* establish a connection. */
|
||||||
res = res ? samr_connect(
|
res = res ? samr_connect( srv_name, 0x02000000,
|
||||||
srv_name, 0x02000000,
|
|
||||||
&sam_pol) : False;
|
&sam_pol) : False;
|
||||||
|
|
||||||
/* connect to the domain */
|
/* connect to the domain */
|
||||||
res = res ? samr_open_domain(
|
res = res ? samr_open_domain( &sam_pol, 0x304, &sid,
|
||||||
&sam_pol, 0x304, &sid,
|
|
||||||
&pol_dom) : False;
|
&pol_dom) : False;
|
||||||
|
|
||||||
/* look up alias rid */
|
/* look up alias rid */
|
||||||
names[0] = alias_name;
|
names[0] = alias_name;
|
||||||
res1 = res ? samr_query_lookup_names(
|
res1 = res ? samr_query_lookup_names( &pol_dom, 0x3e8,
|
||||||
&pol_dom, 0x3e8,
|
|
||||||
1, names,
|
1, names,
|
||||||
&num_rids, rid, type) : False;
|
&num_rids, rid, type) : False;
|
||||||
|
|
||||||
if (res1 && num_rids == 1)
|
if (res1 && num_rids == 1)
|
||||||
{
|
{
|
||||||
res1 = req_aliasmem_info(
|
res1 = req_aliasmem_info(srv_name,
|
||||||
&pol_dom,
|
&pol_dom,
|
||||||
domain,
|
domain,
|
||||||
&sid,
|
&sid,
|
||||||
@ -2182,11 +2078,9 @@ void cmd_sam_query_aliasmem(struct client_info *info, int argc, char *argv[])
|
|||||||
sam_display_alias_members);
|
sam_display_alias_members);
|
||||||
}
|
}
|
||||||
|
|
||||||
res = res ? samr_close(
|
res = res ? samr_close( &sam_pol) : False;
|
||||||
&sam_pol) : False;
|
|
||||||
|
|
||||||
res = res ? samr_close(
|
res = res ? samr_close( &pol_dom) : False;
|
||||||
&pol_dom) : False;
|
|
||||||
|
|
||||||
if (res1)
|
if (res1)
|
||||||
{
|
{
|
||||||
@ -2247,37 +2141,31 @@ void cmd_sam_query_alias(struct client_info *info, int argc, char *argv[])
|
|||||||
info->myhostname, srv_name, domain, sid_str);
|
info->myhostname, srv_name, domain, sid_str);
|
||||||
|
|
||||||
/* establish a connection. */
|
/* establish a connection. */
|
||||||
res = res ? samr_connect(
|
res = res ? samr_connect( srv_name, 0x02000000,
|
||||||
srv_name, 0x02000000,
|
|
||||||
&sam_pol) : False;
|
&sam_pol) : False;
|
||||||
|
|
||||||
/* connect to the domain */
|
/* connect to the domain */
|
||||||
res = res ? samr_open_domain(
|
res = res ? samr_open_domain( &sam_pol, 0x304, &sid,
|
||||||
&sam_pol, 0x304, &sid,
|
|
||||||
&pol_dom) : False;
|
&pol_dom) : False;
|
||||||
|
|
||||||
/* look up alias rid */
|
/* look up alias rid */
|
||||||
names[0] = alias_name;
|
names[0] = alias_name;
|
||||||
res1 = res ? samr_query_lookup_names(
|
res1 = res ? samr_query_lookup_names( &pol_dom, 0x3e8,
|
||||||
&pol_dom, 0x3e8,
|
|
||||||
1, names,
|
1, names,
|
||||||
&num_rids, rid, type) : False;
|
&num_rids, rid, type) : False;
|
||||||
|
|
||||||
if (res1 && num_rids == 1)
|
if (res1 && num_rids == 1)
|
||||||
{
|
{
|
||||||
res1 = query_aliasinfo(
|
res1 = query_aliasinfo( &pol_dom,
|
||||||
&pol_dom,
|
|
||||||
domain,
|
domain,
|
||||||
&sid,
|
&sid,
|
||||||
rid[0],
|
rid[0],
|
||||||
sam_display_alias_info);
|
sam_display_alias_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
res = res ? samr_close(
|
res = res ? samr_close( &sam_pol) : False;
|
||||||
&sam_pol) : False;
|
|
||||||
|
|
||||||
res = res ? samr_close(
|
res = res ? samr_close( &pol_dom) : False;
|
||||||
&pol_dom) : False;
|
|
||||||
|
|
||||||
if (res1)
|
if (res1)
|
||||||
{
|
{
|
||||||
@ -2319,9 +2207,6 @@ void cmd_sam_enum_aliases(struct client_info *info, int argc, char *argv[])
|
|||||||
fstrcat(srv_name, info->dest_host);
|
fstrcat(srv_name, info->dest_host);
|
||||||
strupper(srv_name);
|
strupper(srv_name);
|
||||||
|
|
||||||
argc--;
|
|
||||||
argv++;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "ma")) != EOF)
|
while ((opt = getopt(argc, argv, "ma")) != EOF)
|
||||||
{
|
{
|
||||||
switch (opt)
|
switch (opt)
|
||||||
@ -2382,9 +2267,6 @@ void cmd_sam_enum_groups(struct client_info *info, int argc, char *argv[])
|
|||||||
fstrcat(srv_name, info->dest_host);
|
fstrcat(srv_name, info->dest_host);
|
||||||
strupper(srv_name);
|
strupper(srv_name);
|
||||||
|
|
||||||
argc--;
|
|
||||||
argv++;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "mg")) != EOF)
|
while ((opt = getopt(argc, argv, "mg")) != EOF)
|
||||||
{
|
{
|
||||||
switch (opt)
|
switch (opt)
|
||||||
@ -2432,9 +2314,6 @@ void cmd_sam_enum_domains(struct client_info *info, int argc, char *argv[])
|
|||||||
fstrcat(srv_name, info->dest_host);
|
fstrcat(srv_name, info->dest_host);
|
||||||
strupper(srv_name);
|
strupper(srv_name);
|
||||||
|
|
||||||
argc--;
|
|
||||||
argv++;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "i")) != EOF)
|
while ((opt = getopt(argc, argv, "i")) != EOF)
|
||||||
{
|
{
|
||||||
switch (opt)
|
switch (opt)
|
||||||
|
@ -201,9 +201,6 @@ void cmd_svc_enum(struct client_info *info, int argc, char *argv[])
|
|||||||
fstrcat(srv_name, info->dest_host);
|
fstrcat(srv_name, info->dest_host);
|
||||||
strupper(srv_name);
|
strupper(srv_name);
|
||||||
|
|
||||||
argc--;
|
|
||||||
argv++;
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv,"i")) != EOF)
|
while ((opt = getopt(argc, argv,"i")) != EOF)
|
||||||
{
|
{
|
||||||
switch (opt)
|
switch (opt)
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -45,6 +45,7 @@ extern int DEBUGLEVEL;
|
|||||||
static int process_tok(fstring tok);
|
static int process_tok(fstring tok);
|
||||||
static void cmd_help(struct client_info *info, int argc, char *argv[]);
|
static void cmd_help(struct client_info *info, int argc, char *argv[]);
|
||||||
static void cmd_quit(struct client_info *info, int argc, char *argv[]);
|
static void cmd_quit(struct client_info *info, int argc, char *argv[]);
|
||||||
|
static void cmd_set (struct client_info *info, int argc, char *argv[]);
|
||||||
|
|
||||||
static struct user_credentials usr;
|
static struct user_credentials usr;
|
||||||
|
|
||||||
@ -498,6 +499,12 @@ commands[] =
|
|||||||
{COMPL_NONE, COMPL_NONE}
|
{COMPL_NONE, COMPL_NONE}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"rpcclient",
|
||||||
|
cmd_set,
|
||||||
|
"run rpcclient inside rpcclient (change options etc.)",
|
||||||
|
{COMPL_NONE, COMPL_NONE}
|
||||||
|
},
|
||||||
/*
|
/*
|
||||||
* bye bye
|
* bye bye
|
||||||
*/
|
*/
|
||||||
@ -642,6 +649,9 @@ static int process_tok(char *tok)
|
|||||||
return(-2);
|
return(-2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* command options mask */
|
||||||
|
static uint32 cmd_set_options = 0xffffffff;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
process commands from the client
|
process commands from the client
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -651,6 +661,9 @@ static BOOL do_command(struct client_info *info, char *line)
|
|||||||
char *ptr = line;
|
char *ptr = line;
|
||||||
pstring tok;
|
pstring tok;
|
||||||
|
|
||||||
|
cmd_argc = 0;
|
||||||
|
cmd_argv = NULL;
|
||||||
|
|
||||||
/* get the first part of the command */
|
/* get the first part of the command */
|
||||||
if (!next_token(&ptr,tok,NULL, sizeof(tok)))
|
if (!next_token(&ptr,tok,NULL, sizeof(tok)))
|
||||||
{
|
{
|
||||||
@ -668,10 +681,15 @@ static BOOL do_command(struct client_info *info, char *line)
|
|||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd_set_options = 0x0;
|
||||||
|
|
||||||
if ((i = process_tok(cmd_argv[0])) >= 0)
|
if ((i = process_tok(cmd_argv[0])) >= 0)
|
||||||
{
|
{
|
||||||
optind = -1;
|
int argc = (int)cmd_argc;
|
||||||
commands[i].fn(info, (uint32)cmd_argc, cmd_argv);
|
char **argv = cmd_argv;
|
||||||
|
optind = 0;
|
||||||
|
|
||||||
|
commands[i].fn(info, argc, argv);
|
||||||
}
|
}
|
||||||
else if (i == -2)
|
else if (i == -2)
|
||||||
{
|
{
|
||||||
@ -683,8 +701,6 @@ static BOOL do_command(struct client_info *info, char *line)
|
|||||||
}
|
}
|
||||||
|
|
||||||
free_char_array(cmd_argc, cmd_argv);
|
free_char_array(cmd_argc, cmd_argv);
|
||||||
cmd_argc = 0;
|
|
||||||
cmd_argv = NULL;
|
|
||||||
|
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
@ -728,28 +744,31 @@ static BOOL process( struct client_info *info, char *cmd_str)
|
|||||||
pstring line;
|
pstring line;
|
||||||
char *cmd = cmd_str;
|
char *cmd = cmd_str;
|
||||||
|
|
||||||
if (cmd[0] != '\0') while (cmd[0] != '\0')
|
if (cmd != NULL)
|
||||||
{
|
{
|
||||||
char *p;
|
while (cmd[0] != '\0')
|
||||||
|
|
||||||
if ((p = strchr(cmd, ';')) == 0)
|
|
||||||
{
|
{
|
||||||
strncpy(line, cmd, 999);
|
char *p;
|
||||||
line[1000] = '\0';
|
|
||||||
cmd += strlen(cmd);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (p - cmd > 999) p = cmd + 999;
|
|
||||||
strncpy(line, cmd, p - cmd);
|
|
||||||
line[p - cmd] = '\0';
|
|
||||||
cmd = p + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* input language code to internal one */
|
if ((p = strchr(cmd, ';')) == 0)
|
||||||
CNV_INPUT (line);
|
{
|
||||||
|
strncpy(line, cmd, 999);
|
||||||
|
line[1000] = '\0';
|
||||||
|
cmd += strlen(cmd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (p - cmd > 999) p = cmd + 999;
|
||||||
|
strncpy(line, cmd, p - cmd);
|
||||||
|
line[p - cmd] = '\0';
|
||||||
|
cmd = p + 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (!do_command(info, line)) continue;
|
/* input language code to internal one */
|
||||||
|
CNV_INPUT (line);
|
||||||
|
|
||||||
|
if (!do_command(info, line)) continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else while (!feof(stdin))
|
else while (!feof(stdin))
|
||||||
{
|
{
|
||||||
@ -760,7 +779,7 @@ static BOOL process( struct client_info *info, char *cmd_str)
|
|||||||
#ifndef HAVE_LIBREADLINE
|
#ifndef HAVE_LIBREADLINE
|
||||||
|
|
||||||
/* display a prompt */
|
/* display a prompt */
|
||||||
fprintf(out_hnd, "smb: %s> ", CNV_LANG(info->cur_dir));
|
fprintf(out_hnd, "%s$ ", CNV_LANG(cli_info.dest_host));
|
||||||
fflush(out_hnd);
|
fflush(out_hnd);
|
||||||
|
|
||||||
#ifdef CLIX
|
#ifdef CLIX
|
||||||
@ -786,8 +805,8 @@ static BOOL process( struct client_info *info, char *cmd_str)
|
|||||||
|
|
||||||
#else /* HAVE_LIBREADLINE */
|
#else /* HAVE_LIBREADLINE */
|
||||||
|
|
||||||
slprintf(promptline, sizeof(promptline) - 1, "smb: %s> ",
|
slprintf(promptline, sizeof(promptline) - 1, "%s$ ",
|
||||||
CNV_LANG(info->cur_dir));
|
CNV_LANG(cli_info.dest_host));
|
||||||
|
|
||||||
if (!readline(promptline))
|
if (!readline(promptline))
|
||||||
break;
|
break;
|
||||||
@ -824,12 +843,11 @@ usage on the program
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
static void usage(char *pname)
|
static void usage(char *pname)
|
||||||
{
|
{
|
||||||
fprintf(out_hnd, "Usage: %s [service] [-S server] [-d debuglevel] [-l log] ",
|
fprintf(out_hnd, "Usage: %s [password] [-S server] [-U user] -[W domain] [-l log] ",
|
||||||
pname);
|
pname);
|
||||||
|
|
||||||
fprintf(out_hnd, "\nVersion %s\n",VERSION);
|
fprintf(out_hnd, "\nVersion %s\n",VERSION);
|
||||||
fprintf(out_hnd, "\t-d debuglevel set the debuglevel\n");
|
fprintf(out_hnd, "\t-d debuglevel set the debuglevel\n");
|
||||||
fprintf(out_hnd, "\tservice connect to \\\\server\\share \n");
|
|
||||||
fprintf(out_hnd, "\t-S server connect to \\\\server\\IPC$ \n");
|
fprintf(out_hnd, "\t-S server connect to \\\\server\\IPC$ \n");
|
||||||
fprintf(out_hnd, "\t-l log basename. Basename for log/debug files\n");
|
fprintf(out_hnd, "\t-l log basename. Basename for log/debug files\n");
|
||||||
fprintf(out_hnd, "\t-n netbios name. Use this name as my netbios name\n");
|
fprintf(out_hnd, "\t-n netbios name. Use this name as my netbios name\n");
|
||||||
@ -838,19 +856,13 @@ static void usage(char *pname)
|
|||||||
fprintf(out_hnd, "\t-I dest IP use this IP to connect to\n");
|
fprintf(out_hnd, "\t-I dest IP use this IP to connect to\n");
|
||||||
fprintf(out_hnd, "\t-E write messages to stderr instead of stdout\n");
|
fprintf(out_hnd, "\t-E write messages to stderr instead of stdout\n");
|
||||||
fprintf(out_hnd, "\t-U username set the network username\n");
|
fprintf(out_hnd, "\t-U username set the network username\n");
|
||||||
|
fprintf(out_hnd, "\t-U username%%pass set the network username and password\n");
|
||||||
fprintf(out_hnd, "\t-W domain set the domain name\n");
|
fprintf(out_hnd, "\t-W domain set the domain name\n");
|
||||||
fprintf(out_hnd, "\t-c command string execute semicolon separated commands\n");
|
fprintf(out_hnd, "\t-c 'command string' execute semicolon separated commands\n");
|
||||||
fprintf(out_hnd, "\t-t terminal code terminal i/o code {sjis|euc|jis7|jis8|junet|hex}\n");
|
fprintf(out_hnd, "\t-t terminal code terminal i/o code {sjis|euc|jis7|jis8|junet|hex}\n");
|
||||||
fprintf(out_hnd, "\n");
|
fprintf(out_hnd, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
enum client_action
|
|
||||||
{
|
|
||||||
CLIENT_NONE,
|
|
||||||
CLIENT_IPC,
|
|
||||||
CLIENT_SVC
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBREADLINE
|
#ifdef HAVE_LIBREADLINE
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -1320,27 +1332,319 @@ static char *complete_cmd_null(char *text, int state)
|
|||||||
|
|
||||||
#endif /* HAVE_LIBREADLINE */
|
#endif /* HAVE_LIBREADLINE */
|
||||||
|
|
||||||
|
static void set_user_password(struct user_credentials *u,
|
||||||
|
BOOL got_pass, char *password)
|
||||||
|
{
|
||||||
|
/* set the password cache info */
|
||||||
|
if (got_pass)
|
||||||
|
{
|
||||||
|
if (password == NULL)
|
||||||
|
{
|
||||||
|
pwd_set_nullpwd(&(u->pwd));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* generate 16 byte hashes */
|
||||||
|
pwd_make_lm_nt_16(&(u->pwd), password);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pwd_read(&(u->pwd), "Enter Password:", True);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#define CMD_INTER 0x0
|
||||||
|
#define CMD_STR 0x1
|
||||||
|
#define CMD_DBF 0x2
|
||||||
|
#define CMD_SVC 0x4
|
||||||
|
#define CMD_TERM 0x8
|
||||||
|
#define CMD_PASS 0x10
|
||||||
|
#define CMD_USER 0x20
|
||||||
|
#define CMD_NOPW 0x40
|
||||||
|
#define CMD_DBLV 0x80
|
||||||
|
#define CMD_HELP 0x100
|
||||||
|
#define CMD_SOCK 0x200
|
||||||
|
#define CMD_IFACE 0x400
|
||||||
|
#define CMD_DOM 0x800
|
||||||
|
#define CMD_IP 0x1000
|
||||||
|
#define CMD_HOST 0x2000
|
||||||
|
#define CMD_NAME 0x4000
|
||||||
|
#define CMD_DBG 0x8000
|
||||||
|
#define CMD_SCOPE 0x10000
|
||||||
|
|
||||||
|
static void cmd_set(struct client_info *info, int argc, char *argv[])
|
||||||
|
{
|
||||||
|
BOOL interactive = True;
|
||||||
|
char *cmd_str = NULL;
|
||||||
|
char opt;
|
||||||
|
extern FILE *dbf;
|
||||||
|
extern char *optarg;
|
||||||
|
static pstring servicesf = CONFIGFILE;
|
||||||
|
pstring term_code;
|
||||||
|
pstring password; /* local copy only, if one is entered */
|
||||||
|
|
||||||
|
#ifdef KANJI
|
||||||
|
pstrcpy(term_code, KANJI);
|
||||||
|
#else /* KANJI */
|
||||||
|
*term_code = 0;
|
||||||
|
#endif /* KANJI */
|
||||||
|
|
||||||
|
if (*argv[1] != '-')
|
||||||
|
{
|
||||||
|
if (argc > 1 && (*argv[1] != '-'))
|
||||||
|
{
|
||||||
|
cmd_set_options |= CMD_PASS;
|
||||||
|
pstrcpy(password,argv[1]);
|
||||||
|
memset(argv[1],'X',strlen(argv[1]));
|
||||||
|
argc--;
|
||||||
|
argv++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while ((opt = getopt(argc, argv, "s:B:O:M:S:i:N:n:d:l:hI:EB:U:L:t:m:W:T:D:c:")) != EOF)
|
||||||
|
{
|
||||||
|
switch (opt)
|
||||||
|
{
|
||||||
|
case 'm':
|
||||||
|
{
|
||||||
|
/* FIXME ... max_protocol seems to be funny here */
|
||||||
|
|
||||||
|
int max_protocol = 0;
|
||||||
|
max_protocol = interpret_protocol(optarg,max_protocol);
|
||||||
|
fprintf(stderr, "max protocol not currently supported\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'O':
|
||||||
|
{
|
||||||
|
cmd_set_options |= CMD_SOCK;
|
||||||
|
pstrcpy(user_socket_options,optarg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'S':
|
||||||
|
{
|
||||||
|
cmd_set_options |= CMD_HOST;
|
||||||
|
pstrcpy(cli_info.dest_host,optarg);
|
||||||
|
strupper(cli_info.dest_host);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'B':
|
||||||
|
{
|
||||||
|
cmd_set_options |= CMD_IFACE;
|
||||||
|
iface_set_default(NULL,optarg,NULL);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'i':
|
||||||
|
{
|
||||||
|
cmd_set_options |= CMD_SCOPE;
|
||||||
|
pstrcpy(scope, optarg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'U':
|
||||||
|
{
|
||||||
|
char *lp;
|
||||||
|
cmd_set_options |= CMD_USER;
|
||||||
|
pstrcpy(usr.user_name,optarg);
|
||||||
|
if ((lp=strchr(usr.user_name,'%')))
|
||||||
|
{
|
||||||
|
*lp = 0;
|
||||||
|
pstrcpy(password,lp+1);
|
||||||
|
cmd_set_options |= CMD_PASS;
|
||||||
|
memset(strchr(optarg,'%')+1,'X',strlen(password));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'W':
|
||||||
|
{
|
||||||
|
cmd_set_options |= CMD_DOM;
|
||||||
|
pstrcpy(usr.domain,optarg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'E':
|
||||||
|
{
|
||||||
|
cmd_set_options |= CMD_DBG;
|
||||||
|
dbf = stderr;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'I':
|
||||||
|
{
|
||||||
|
cmd_set_options |= CMD_IP;
|
||||||
|
cli_info.dest_ip = *interpret_addr2(optarg);
|
||||||
|
if (zero_ip(cli_info.dest_ip))
|
||||||
|
{
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'n':
|
||||||
|
{
|
||||||
|
cmd_set_options |= CMD_NAME;
|
||||||
|
fstrcpy(global_myname, optarg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'N':
|
||||||
|
{
|
||||||
|
cmd_set_options |= CMD_NOPW | CMD_PASS;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'd':
|
||||||
|
{
|
||||||
|
cmd_set_options |= CMD_DBLV;
|
||||||
|
if (*optarg == 'A')
|
||||||
|
DEBUGLEVEL = 10000;
|
||||||
|
else
|
||||||
|
DEBUGLEVEL = atoi(optarg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'l':
|
||||||
|
{
|
||||||
|
cmd_set_options |= CMD_INTER;
|
||||||
|
slprintf(debugf, sizeof(debugf)-1,
|
||||||
|
"%s.client", optarg);
|
||||||
|
interactive = False;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'c':
|
||||||
|
{
|
||||||
|
cmd_set_options |= CMD_STR | CMD_PASS;
|
||||||
|
cmd_str = optarg;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 'h':
|
||||||
|
{
|
||||||
|
cmd_set_options |= CMD_HELP;
|
||||||
|
usage(argv[0]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 's':
|
||||||
|
{
|
||||||
|
cmd_set_options |= CMD_SVC;
|
||||||
|
pstrcpy(servicesf, optarg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 't':
|
||||||
|
{
|
||||||
|
cmd_set_options |= CMD_TERM;
|
||||||
|
pstrcpy(term_code, optarg);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
cmd_set_options |= CMD_HELP;
|
||||||
|
usage(argv[0]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IS_BITS_SET_ALL(cmd_set_options, CMD_HELP))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_logging(debugf, interactive);
|
||||||
|
reopen_logs();
|
||||||
|
|
||||||
|
if (IS_BITS_SET_ALL(cmd_set_options, CMD_NOPW))
|
||||||
|
{
|
||||||
|
set_user_password(&usr, True, NULL);
|
||||||
|
}
|
||||||
|
else if (IS_BITS_SET_ALL(cmd_set_options, CMD_PASS))
|
||||||
|
{
|
||||||
|
set_user_password(&usr, True, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* paranoia: destroy the local copy of the password */
|
||||||
|
bzero(password, sizeof(password));
|
||||||
|
|
||||||
|
strupper(global_myname);
|
||||||
|
fstrcpy(cli_info.myhostname, global_myname);
|
||||||
|
|
||||||
|
if (!lp_load(servicesf,True, False, False))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Can't load %s - run testparm to debug it\n", servicesf);
|
||||||
|
}
|
||||||
|
|
||||||
|
load_interfaces();
|
||||||
|
|
||||||
|
fstrcpy(cli_info.mach_acct, cli_info.myhostname);
|
||||||
|
strupper(cli_info.mach_acct);
|
||||||
|
fstrcat(cli_info.mach_acct, "$");
|
||||||
|
|
||||||
|
if (cmd_str != NULL)
|
||||||
|
{
|
||||||
|
process(&cli_info, cmd_str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void read_user_env(struct user_credentials *u)
|
||||||
|
{
|
||||||
|
pstring password;
|
||||||
|
|
||||||
|
password[0] = 0;
|
||||||
|
|
||||||
|
if (getenv("USER"))
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
|
pstrcpy(u->user_name,getenv("USER"));
|
||||||
|
|
||||||
|
/* modification to support userid%passwd syntax in the USER var
|
||||||
|
25.Aug.97, jdblair@uab.edu */
|
||||||
|
|
||||||
|
if ((p=strchr(u->user_name,'%')))
|
||||||
|
{
|
||||||
|
*p = 0;
|
||||||
|
pstrcpy(password,p+1);
|
||||||
|
memset(strchr(getenv("USER"),'%')+1,'X',strlen(password));
|
||||||
|
}
|
||||||
|
strupper(u->user_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* modification to support PASSWD environmental var
|
||||||
|
25.Aug.97, jdblair@uab.edu */
|
||||||
|
if (getenv("PASSWD"))
|
||||||
|
{
|
||||||
|
pstrcpy(password,getenv("PASSWD"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*u->user_name == 0 && getenv("LOGNAME"))
|
||||||
|
{
|
||||||
|
pstrcpy(u->user_name,getenv("LOGNAME"));
|
||||||
|
strupper(u->user_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
set_user_password(u, True, password);
|
||||||
|
|
||||||
|
/* paranoia: destroy the local copy of the password */
|
||||||
|
bzero(password, sizeof(password));
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
main program
|
main program
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
int main(int argc,char *argv[])
|
int main(int argc,char *argv[])
|
||||||
{
|
{
|
||||||
BOOL interactive = True;
|
|
||||||
|
|
||||||
int opt;
|
|
||||||
extern FILE *dbf;
|
|
||||||
extern char *optarg;
|
|
||||||
extern int optind;
|
|
||||||
static pstring servicesf = CONFIGFILE;
|
|
||||||
pstring term_code;
|
|
||||||
char *p;
|
|
||||||
BOOL got_pass = False;
|
|
||||||
char *cmd_str="";
|
|
||||||
mode_t myumask = 0755;
|
|
||||||
enum client_action cli_action = CLIENT_NONE;
|
|
||||||
extern struct user_credentials *usr_creds;
|
extern struct user_credentials *usr_creds;
|
||||||
|
mode_t myumask = 0755;
|
||||||
|
|
||||||
pstring password; /* local copy only, if one is entered */
|
DEBUGLEVEL = 2;
|
||||||
|
|
||||||
usr.ntlmssp_flags = 0x0;
|
usr.ntlmssp_flags = 0x0;
|
||||||
|
|
||||||
@ -1350,44 +1654,12 @@ static char *complete_cmd_null(char *text, int state)
|
|||||||
|
|
||||||
init_policy_hnd(64);
|
init_policy_hnd(64);
|
||||||
|
|
||||||
#ifdef KANJI
|
|
||||||
pstrcpy(term_code, KANJI);
|
|
||||||
#else /* KANJI */
|
|
||||||
*term_code = 0;
|
|
||||||
#endif /* KANJI */
|
|
||||||
|
|
||||||
DEBUGLEVEL = 2;
|
|
||||||
|
|
||||||
cli_info.put_total_size = 0;
|
|
||||||
cli_info.put_total_time_ms = 0;
|
|
||||||
cli_info.get_total_size = 0;
|
|
||||||
cli_info.get_total_time_ms = 0;
|
|
||||||
|
|
||||||
cli_info.dir_total = 0;
|
|
||||||
cli_info.newer_than = 0;
|
|
||||||
cli_info.archive_level = 0;
|
|
||||||
cli_info.print_mode = 1;
|
|
||||||
|
|
||||||
cli_info.translation = False;
|
|
||||||
cli_info.recurse_dir = False;
|
|
||||||
cli_info.lowercase = False;
|
|
||||||
cli_info.prompt = True;
|
|
||||||
cli_info.abort_mget = True;
|
|
||||||
|
|
||||||
cli_info.dest_ip.s_addr = 0;
|
|
||||||
cli_info.name_type = 0x20;
|
|
||||||
|
|
||||||
pstrcpy(cli_info.cur_dir , "\\");
|
|
||||||
pstrcpy(cli_info.file_sel, "");
|
|
||||||
pstrcpy(cli_info.base_dir, "");
|
|
||||||
pstrcpy(usr.domain, "");
|
pstrcpy(usr.domain, "");
|
||||||
pstrcpy(usr.user_name, "");
|
pstrcpy(usr.user_name, "");
|
||||||
|
|
||||||
pstrcpy(cli_info.myhostname, "");
|
pstrcpy(cli_info.myhostname, "");
|
||||||
pstrcpy(cli_info.dest_host, "");
|
pstrcpy(cli_info.dest_host, "");
|
||||||
|
cli_info.dest_ip.s_addr = 0;
|
||||||
pstrcpy(cli_info.svc_type, "A:");
|
|
||||||
pstrcpy(cli_info.share, "");
|
|
||||||
pstrcpy(cli_info.service, "");
|
|
||||||
|
|
||||||
ZERO_STRUCT(cli_info.dom.level3_sid);
|
ZERO_STRUCT(cli_info.dom.level3_sid);
|
||||||
ZERO_STRUCT(cli_info.dom.level5_sid);
|
ZERO_STRUCT(cli_info.dom.level5_sid);
|
||||||
@ -1419,290 +1691,29 @@ static char *complete_cmd_null(char *text, int state)
|
|||||||
fprintf(stderr, "Failed to get my hostname.\n");
|
fprintf(stderr, "Failed to get my hostname.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getenv("USER"))
|
|
||||||
{
|
|
||||||
pstrcpy(usr.user_name,getenv("USER"));
|
|
||||||
|
|
||||||
/* modification to support userid%passwd syntax in the USER var
|
|
||||||
25.Aug.97, jdblair@uab.edu */
|
|
||||||
|
|
||||||
if ((p=strchr(usr.user_name,'%')))
|
|
||||||
{
|
|
||||||
*p = 0;
|
|
||||||
pstrcpy(password,p+1);
|
|
||||||
got_pass = True;
|
|
||||||
memset(strchr(getenv("USER"),'%')+1,'X',strlen(password));
|
|
||||||
}
|
|
||||||
strupper(usr.user_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
password[0] = 0;
|
|
||||||
|
|
||||||
/* modification to support PASSWD environmental var
|
|
||||||
25.Aug.97, jdblair@uab.edu */
|
|
||||||
if (getenv("PASSWD"))
|
|
||||||
{
|
|
||||||
pstrcpy(password,getenv("PASSWD"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (*usr.user_name == 0 && getenv("LOGNAME"))
|
|
||||||
{
|
|
||||||
pstrcpy(usr.user_name,getenv("LOGNAME"));
|
|
||||||
strupper(usr.user_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
{
|
{
|
||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*argv[1] != '-')
|
read_user_env(&usr);
|
||||||
|
|
||||||
|
cmd_set_options &= ~CMD_HELP;
|
||||||
|
cmd_set_options &= ~CMD_NOPW;
|
||||||
|
|
||||||
|
cmd_set(&cli_info, argc, argv);
|
||||||
|
|
||||||
|
if (IS_BITS_SET_ALL(cmd_set_options, CMD_HELP))
|
||||||
{
|
{
|
||||||
|
exit(0);
|
||||||
pstrcpy(cli_info.service, argv[1]);
|
|
||||||
/* Convert any '/' characters in the service name to '\' characters */
|
|
||||||
string_replace( cli_info.service, '/','\\');
|
|
||||||
argc--;
|
|
||||||
argv++;
|
|
||||||
|
|
||||||
fprintf(out_hnd, "service: %s\n", cli_info.service);
|
|
||||||
|
|
||||||
if (count_chars(cli_info.service,'\\') < 3)
|
|
||||||
{
|
|
||||||
usage(argv[0]);
|
|
||||||
printf("\n%s: Not enough '\\' characters in service\n", cli_info.service);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (count_chars(cli_info.service,'\\') > 3)
|
|
||||||
{
|
|
||||||
usage(pname);
|
|
||||||
printf("\n%s: Too many '\\' characters in service\n", cli_info.service);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (argc > 1 && (*argv[1] != '-'))
|
|
||||||
{
|
|
||||||
got_pass = True;
|
|
||||||
pstrcpy(password,argv[1]);
|
|
||||||
memset(argv[1],'X',strlen(argv[1]));
|
|
||||||
argc--;
|
|
||||||
argv++;
|
|
||||||
}
|
|
||||||
|
|
||||||
cli_action = CLIENT_SVC;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv,"s:B:O:M:S:i:N:n:d:l:hI:EB:U:L:t:m:W:T:D:c:")) != EOF)
|
|
||||||
{
|
|
||||||
switch (opt)
|
|
||||||
{
|
|
||||||
case 'm':
|
|
||||||
{
|
|
||||||
/* FIXME ... max_protocol seems to be funny here */
|
|
||||||
|
|
||||||
int max_protocol = 0;
|
|
||||||
max_protocol = interpret_protocol(optarg,max_protocol);
|
|
||||||
fprintf(stderr, "max protocol not currently supported\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'O':
|
|
||||||
{
|
|
||||||
pstrcpy(user_socket_options,optarg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'S':
|
|
||||||
{
|
|
||||||
pstrcpy(cli_info.dest_host,optarg);
|
|
||||||
strupper(cli_info.dest_host);
|
|
||||||
cli_action = CLIENT_IPC;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'B':
|
|
||||||
{
|
|
||||||
iface_set_default(NULL,optarg,NULL);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'i':
|
|
||||||
{
|
|
||||||
pstrcpy(scope, optarg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'U':
|
|
||||||
{
|
|
||||||
char *lp;
|
|
||||||
pstrcpy(usr.user_name,optarg);
|
|
||||||
if ((lp=strchr(usr.user_name,'%')))
|
|
||||||
{
|
|
||||||
*lp = 0;
|
|
||||||
pstrcpy(password,lp+1);
|
|
||||||
got_pass = True;
|
|
||||||
memset(strchr(optarg,'%')+1,'X',strlen(password));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'W':
|
|
||||||
{
|
|
||||||
pstrcpy(usr.domain,optarg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'E':
|
|
||||||
{
|
|
||||||
dbf = stderr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'I':
|
|
||||||
{
|
|
||||||
cli_info.dest_ip = *interpret_addr2(optarg);
|
|
||||||
if (zero_ip(cli_info.dest_ip))
|
|
||||||
{
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'n':
|
|
||||||
{
|
|
||||||
fstrcpy(global_myname, optarg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'N':
|
|
||||||
{
|
|
||||||
got_pass = True;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'd':
|
|
||||||
{
|
|
||||||
if (*optarg == 'A')
|
|
||||||
DEBUGLEVEL = 10000;
|
|
||||||
else
|
|
||||||
DEBUGLEVEL = atoi(optarg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'l':
|
|
||||||
{
|
|
||||||
slprintf(debugf, sizeof(debugf)-1,
|
|
||||||
"%s.client", optarg);
|
|
||||||
interactive = False;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'c':
|
|
||||||
{
|
|
||||||
cmd_str = optarg;
|
|
||||||
got_pass = True;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 'h':
|
|
||||||
{
|
|
||||||
usage(argv[0]);
|
|
||||||
exit(0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 's':
|
|
||||||
{
|
|
||||||
pstrcpy(servicesf, optarg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 't':
|
|
||||||
{
|
|
||||||
pstrcpy(term_code, optarg);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
usage(argv[0]);
|
|
||||||
exit(1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setup_logging(debugf, interactive);
|
|
||||||
|
|
||||||
if (cli_action == CLIENT_NONE)
|
|
||||||
{
|
|
||||||
usage(argv[0]);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
strupper(global_myname);
|
|
||||||
fstrcpy(cli_info.myhostname, global_myname);
|
|
||||||
|
|
||||||
DEBUG(3,("%s client started (version %s)\n",timestring(),VERSION));
|
|
||||||
|
|
||||||
if (!lp_load(servicesf,True, False, False))
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Can't load %s - run testparm to debug it\n", servicesf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
codepage_initialise(lp_client_code_page());
|
codepage_initialise(lp_client_code_page());
|
||||||
|
|
||||||
load_interfaces();
|
DEBUG(3,("%s client started (version %s)\n",timestring(),VERSION));
|
||||||
|
|
||||||
if (cli_action == CLIENT_IPC)
|
process(&cli_info, NULL);
|
||||||
{
|
|
||||||
pstrcpy(cli_info.share, "IPC$");
|
|
||||||
pstrcpy(cli_info.svc_type, "IPC");
|
|
||||||
}
|
|
||||||
|
|
||||||
fstrcpy(cli_info.mach_acct, cli_info.myhostname);
|
|
||||||
strupper(cli_info.mach_acct);
|
|
||||||
fstrcat(cli_info.mach_acct, "$");
|
|
||||||
|
|
||||||
/* set the password cache info */
|
|
||||||
if (got_pass)
|
|
||||||
{
|
|
||||||
if (password[0] == 0)
|
|
||||||
{
|
|
||||||
pwd_set_nullpwd(&(usr.pwd));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* generate 16 byte hashes */
|
|
||||||
pwd_make_lm_nt_16(&(usr.pwd), password);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pwd_read(&(usr.pwd), "Enter Password:", True);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* paranoia: destroy the local copy of the password */
|
|
||||||
bzero(password, sizeof(password));
|
|
||||||
|
|
||||||
switch (cli_action)
|
|
||||||
{
|
|
||||||
case CLIENT_IPC:
|
|
||||||
{
|
|
||||||
process(&cli_info, cmd_str);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
fprintf(stderr, "unknown client action requested\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user