summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/include/proto.h122
-rw-r--r--source3/rpcclient/cmd_atsvc.c2
-rw-r--r--source3/rpcclient/cmd_brs.c2
-rw-r--r--source3/rpcclient/cmd_eventlog.c2
-rw-r--r--source3/rpcclient/cmd_lsarpc.c10
-rw-r--r--source3/rpcclient/cmd_netlogon.c6
-rw-r--r--source3/rpcclient/cmd_reg.c20
-rw-r--r--source3/rpcclient/cmd_samr.c415
-rw-r--r--source3/rpcclient/cmd_spoolss.c6
-rw-r--r--source3/rpcclient/cmd_srvsvc.c14
-rw-r--r--source3/rpcclient/cmd_svcctl.c8
-rw-r--r--source3/rpcclient/cmd_wkssvc.c2
-rw-r--r--source3/rpcclient/rpcclient.c87
13 files changed, 368 insertions, 328 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index a8be8bad97..153f301f31 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -3531,29 +3531,29 @@ BOOL api_wkssvc_rpc(pipes_struct *p, prs_struct *data);
/*The following definitions come from rpcclient/cmd_atsvc.c */
-void cmd_at(struct client_info *info);
+void cmd_at(struct client_info *info, int argc, char *argv[]);
/*The following definitions come from rpcclient/cmd_brs.c */
-void cmd_brs_query_info(struct client_info *info);
+void cmd_brs_query_info(struct client_info *info, int argc, char *argv[]);
/*The following definitions come from rpcclient/cmd_eventlog.c */
-void cmd_eventlog(struct client_info *info);
+void cmd_eventlog(struct client_info *info, int argc, char *argv[]);
/*The following definitions come from rpcclient/cmd_lsarpc.c */
-void cmd_lsa_enum_trust_dom(struct client_info *info);
-void cmd_lsa_query_info(struct client_info *info);
-void cmd_lsa_lookup_names(struct client_info *info);
-void cmd_lsa_lookup_sids(struct client_info *info);
-void cmd_lsa_query_secret(struct client_info *info);
+void cmd_lsa_enum_trust_dom(struct client_info *info, int argc, char *argv[]);
+void cmd_lsa_query_info(struct client_info *info, int argc, char *argv[]);
+void cmd_lsa_lookup_names(struct client_info *info, int argc, char *argv[]);
+void cmd_lsa_lookup_sids(struct client_info *info, int argc, char *argv[]);
+void cmd_lsa_query_secret(struct client_info *info, int argc, char *argv[]);
/*The following definitions come from rpcclient/cmd_netlogon.c */
-void cmd_netlogon_login_test(struct client_info *info);
-void cmd_netlogon_domain_test(struct client_info *info);
-void cmd_sam_sync(struct client_info *info);
+void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[]);
+void cmd_netlogon_domain_test(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_sync(struct client_info *info, int argc, char *argv[]);
/*The following definitions come from rpcclient/cmd_reg.c */
@@ -3561,44 +3561,44 @@ BOOL msrpc_reg_enum_key(struct cli_state *cli, const char* full_keyname,
REG_FN(reg_fn),
REG_KEY_FN(reg_key_fn),
REG_VAL_FN(reg_val_fn));
-void cmd_reg_enum(struct client_info *info);
-void cmd_reg_query_info(struct client_info *info);
-void cmd_reg_query_key(struct client_info *info);
-void cmd_reg_create_val(struct client_info *info);
-void cmd_reg_delete_val(struct client_info *info);
-void cmd_reg_delete_key(struct client_info *info);
-void cmd_reg_create_key(struct client_info *info);
-void cmd_reg_test_key_sec(struct client_info *info);
-void cmd_reg_get_key_sec(struct client_info *info);
-void cmd_reg_shutdown(struct client_info *info);
+void cmd_reg_enum(struct client_info *info, int argc, char *argv[]);
+void cmd_reg_query_info(struct client_info *info, int argc, char *argv[]);
+void cmd_reg_query_key(struct client_info *info, int argc, char *argv[]);
+void cmd_reg_create_val(struct client_info *info, int argc, char *argv[]);
+void cmd_reg_delete_val(struct client_info *info, int argc, char *argv[]);
+void cmd_reg_delete_key(struct client_info *info, int argc, char *argv[]);
+void cmd_reg_create_key(struct client_info *info, int argc, char *argv[]);
+void cmd_reg_test_key_sec(struct client_info *info, int argc, char *argv[]);
+void cmd_reg_get_key_sec(struct client_info *info, int argc, char *argv[]);
+void cmd_reg_shutdown(struct client_info *info, int argc, char *argv[]);
/*The following definitions come from rpcclient/cmd_samr.c */
-void cmd_sam_ntchange_pwd(struct client_info *info);
-void cmd_sam_test(struct client_info *info);
-void cmd_sam_lookup_domain(struct client_info *info);
-void cmd_sam_del_aliasmem(struct client_info *info);
-void cmd_sam_delete_dom_alias(struct client_info *info);
-void cmd_sam_add_aliasmem(struct client_info *info);
-void cmd_sam_create_dom_user(struct client_info *info);
-void cmd_sam_create_dom_alias(struct client_info *info);
-void cmd_sam_del_groupmem(struct client_info *info);
-void cmd_sam_delete_dom_group(struct client_info *info);
-void cmd_sam_add_groupmem(struct client_info *info);
-void cmd_sam_create_dom_group(struct client_info *info);
-void cmd_sam_enum_users(struct client_info *info);
-void cmd_sam_query_groupmem(struct client_info *info);
-void cmd_sam_query_group(struct client_info *info);
-void cmd_sam_query_user(struct client_info *info);
-void cmd_sam_set_userinfo2(struct client_info *info);
-void cmd_sam_set_userinfo(struct client_info *info);
-void cmd_sam_query_dispinfo(struct client_info *info);
-void cmd_sam_query_dominfo(struct client_info *info);
-void cmd_sam_query_aliasmem(struct client_info *info);
-void cmd_sam_query_alias(struct client_info *info);
-void cmd_sam_enum_aliases(struct client_info *info);
-void cmd_sam_enum_groups(struct client_info *info);
-void cmd_sam_enum_domains(struct client_info *info);
+void cmd_sam_ntchange_pwd(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_test(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_lookup_domain(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_del_aliasmem(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_delete_dom_alias(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_add_aliasmem(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_create_dom_user(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_create_dom_alias(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_del_groupmem(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_delete_dom_group(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_add_groupmem(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_create_dom_group(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_enum_users(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_query_groupmem(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_query_group(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_query_user(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_set_userinfo2(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_set_userinfo(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_query_dispinfo(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_query_dominfo(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_query_aliasmem(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_query_alias(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_enum_aliases(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_enum_groups(struct client_info *info, int argc, char *argv[]);
+void cmd_sam_enum_domains(struct client_info *info, int argc, char *argv[]);
/*The following definitions come from rpcclient/cmd_spoolss.c */
@@ -3608,8 +3608,8 @@ BOOL msrpc_spoolss_enum_printers(struct cli_state *cli,
uint32 *num,
void ***ctr,
PRINT_INFO_FN(fn));
-void cmd_spoolss_enum_printers(struct client_info *info);
-void cmd_spoolss_open_printer_ex(struct client_info *info);
+void cmd_spoolss_enum_printers(struct client_info *info, int argc, char *argv[]);
+void cmd_spoolss_open_printer_ex(struct client_info *info, int argc, char *argv[]);
BOOL msrpc_spoolss_enum_jobs(struct cli_state *cli,
const char* srv_name,
const char* user_name,
@@ -3618,25 +3618,25 @@ BOOL msrpc_spoolss_enum_jobs(struct cli_state *cli,
uint32 *num,
void ***ctr,
JOB_INFO_FN(fn));
-void cmd_spoolss_enum_jobs(struct client_info *info);
+void cmd_spoolss_enum_jobs(struct client_info *info, int argc, char *argv[]);
/*The following definitions come from rpcclient/cmd_srvsvc.c */
BOOL net_srv_get_info(struct client_info *info,
uint32 info_level,
SRV_INFO_CTR *ctr);
-void cmd_srv_query_info(struct client_info *info);
+void cmd_srv_query_info(struct client_info *info, int argc, char *argv[]);
BOOL msrpc_srv_enum_tprt(struct cli_state *cli,
const char* dest_srv,
uint32 info_level,
SRV_TPRT_INFO_CTR *ctr,
TPRT_INFO_FN(tprt_fn));
-void cmd_srv_enum_tprt(struct client_info *info);
-void cmd_srv_enum_conn(struct client_info *info);
-void cmd_srv_enum_shares(struct client_info *info);
-void cmd_srv_enum_sess(struct client_info *info);
-void cmd_srv_enum_files(struct client_info *info);
-void cmd_time(struct client_info *info);
+void cmd_srv_enum_tprt(struct client_info *info, int argc, char *argv[]);
+void cmd_srv_enum_conn(struct client_info *info, int argc, char *argv[]);
+void cmd_srv_enum_shares(struct client_info *info, int argc, char *argv[]);
+void cmd_srv_enum_sess(struct client_info *info, int argc, char *argv[]);
+void cmd_srv_enum_files(struct client_info *info, int argc, char *argv[]);
+void cmd_time(struct client_info *info, int argc, char *argv[]);
/*The following definitions come from rpcclient/cmd_svcctl.c */
@@ -3645,19 +3645,19 @@ BOOL svc_query_service(struct cli_state *cli, uint16 fnum,
POLICY_HND *pol_scm,
const char *svc_name,
SVC_QUERY_FN(svc_query_fn));
-void cmd_svc_info(struct client_info *info);
+void cmd_svc_info(struct client_info *info, int argc, char *argv[]);
BOOL msrpc_svc_enum(struct client_info *info,
ENUM_SRVC_STATUS **svcs,
uint32 *num_svcs,
SVC_INFO_FN(info_fn),
SVC_QUERY_FN(query_fn));
-void cmd_svc_enum(struct client_info *info);
-void cmd_svc_stop(struct client_info *info);
-void cmd_svc_start(struct client_info *info);
+void cmd_svc_enum(struct client_info *info, int argc, char *argv[]);
+void cmd_svc_stop(struct client_info *info, int argc, char *argv[]);
+void cmd_svc_start(struct client_info *info, int argc, char *argv[]);
/*The following definitions come from rpcclient/cmd_wkssvc.c */
-void cmd_wks_query_info(struct client_info *info);
+void cmd_wks_query_info(struct client_info *info, int argc, char *argv[]);
/*The following definitions come from rpcclient/display.c */
diff --git a/source3/rpcclient/cmd_atsvc.c b/source3/rpcclient/cmd_atsvc.c
index 64f045a2a0..b10c55ad8a 100644
--- a/source3/rpcclient/cmd_atsvc.c
+++ b/source3/rpcclient/cmd_atsvc.c
@@ -166,7 +166,7 @@ static BOOL at_soon(char *dest_srv, uint32 *hours, uint32 *minutes, uint32 *seco
/****************************************************************************
scheduler add job
****************************************************************************/
-void cmd_at(struct client_info *info)
+void cmd_at(struct client_info *info, int argc, char *argv[])
{
uint16 nt_pipe_fnum;
pstring temp;
diff --git a/source3/rpcclient/cmd_brs.c b/source3/rpcclient/cmd_brs.c
index f01ebc8f95..428a5c93ba 100644
--- a/source3/rpcclient/cmd_brs.c
+++ b/source3/rpcclient/cmd_brs.c
@@ -41,7 +41,7 @@ extern FILE* out_hnd;
/****************************************************************************
Browser get info query
****************************************************************************/
-void cmd_brs_query_info(struct client_info *info)
+void cmd_brs_query_info(struct client_info *info, int argc, char *argv[])
{
uint16 nt_pipe_fnum;
fstring dest_brs;
diff --git a/source3/rpcclient/cmd_eventlog.c b/source3/rpcclient/cmd_eventlog.c
index e3179ee043..c836564007 100644
--- a/source3/rpcclient/cmd_eventlog.c
+++ b/source3/rpcclient/cmd_eventlog.c
@@ -38,7 +38,7 @@ extern FILE* out_hnd;
/****************************************************************************
****************************************************************************/
-void cmd_eventlog(struct client_info *info)
+void cmd_eventlog(struct client_info *info, int argc, char *argv[])
{
uint16 nt_pipe_fnum;
BOOL res = True;
diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c
index 53ffb24cfd..079cd803ea 100644
--- a/source3/rpcclient/cmd_lsarpc.c
+++ b/source3/rpcclient/cmd_lsarpc.c
@@ -40,7 +40,7 @@ extern int smb_tidx;
/****************************************************************************
nt enumerate trusted domains
****************************************************************************/
-void cmd_lsa_enum_trust_dom(struct client_info *info)
+void cmd_lsa_enum_trust_dom(struct client_info *info, int argc, char *argv[])
{
uint16 nt_pipe_fnum;
fstring srv_name;
@@ -106,7 +106,7 @@ void cmd_lsa_enum_trust_dom(struct client_info *info)
/****************************************************************************
nt lsa query
****************************************************************************/
-void cmd_lsa_query_info(struct client_info *info)
+void cmd_lsa_query_info(struct client_info *info, int argc, char *argv[])
{
uint16 nt_pipe_fnum;
fstring srv_name;
@@ -188,7 +188,7 @@ void cmd_lsa_query_info(struct client_info *info)
/****************************************************************************
lookup names
****************************************************************************/
-void cmd_lsa_lookup_names(struct client_info *info)
+void cmd_lsa_lookup_names(struct client_info *info, int argc, char *argv[])
{
uint16 nt_pipe_fnum;
fstring temp;
@@ -279,7 +279,7 @@ void cmd_lsa_lookup_names(struct client_info *info)
/****************************************************************************
lookup sids
****************************************************************************/
-void cmd_lsa_lookup_sids(struct client_info *info)
+void cmd_lsa_lookup_sids(struct client_info *info, int argc, char *argv[])
{
uint16 nt_pipe_fnum;
fstring temp;
@@ -376,7 +376,7 @@ void cmd_lsa_lookup_sids(struct client_info *info)
/****************************************************************************
nt lsa query
****************************************************************************/
-void cmd_lsa_query_secret(struct client_info *info)
+void cmd_lsa_query_secret(struct client_info *info, int argc, char *argv[])
{
uint16 nt_pipe_fnum;
fstring srv_name;
diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c
index 5c17e5c3da..ed30a3122a 100644
--- a/source3/rpcclient/cmd_netlogon.c
+++ b/source3/rpcclient/cmd_netlogon.c
@@ -42,7 +42,7 @@ extern pstring global_myname;
/****************************************************************************
experimental nt login.
****************************************************************************/
-void cmd_netlogon_login_test(struct client_info *info)
+void cmd_netlogon_login_test(struct client_info *info, int argc, char *argv[])
{
uint16 nt_pipe_fnum;
#if 0
@@ -142,7 +142,7 @@ void cmd_netlogon_login_test(struct client_info *info)
/****************************************************************************
experimental nt login.
****************************************************************************/
-void cmd_netlogon_domain_test(struct client_info *info)
+void cmd_netlogon_domain_test(struct client_info *info, int argc, char *argv[])
{
uint16 nt_pipe_fnum;
@@ -183,7 +183,7 @@ void cmd_netlogon_domain_test(struct client_info *info)
/****************************************************************************
experimental SAM synchronisation.
****************************************************************************/
-void cmd_sam_sync(struct client_info *info)
+void cmd_sam_sync(struct client_info *info, int argc, char *argv[])
{
SAM_DELTA_HDR hdr_deltas[MAX_SAM_DELTAS];
SAM_DELTA_CTR deltas[MAX_SAM_DELTAS];
diff --git a/source3/rpcclient/cmd_reg.c b/source3/rpcclient/cmd_reg.c
index 02544987ec..305440c3c5 100644
--- a/source3/rpcclient/cmd_reg.c
+++ b/source3/rpcclient/cmd_reg.c
@@ -286,7 +286,7 @@ static void reg_display_val_info(const char *full_name,
/****************************************************************************
nt registry enum
****************************************************************************/
-void cmd_reg_enum(struct client_info *info)
+void cmd_reg_enum(struct client_info *info, int argc, char *argv[])
{
fstring full_keyname;
@@ -308,7 +308,7 @@ void cmd_reg_enum(struct client_info *info)
/****************************************************************************
nt registry query value info
****************************************************************************/
-void cmd_reg_query_info(struct client_info *info)
+void cmd_reg_query_info(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
BOOL res = True;
@@ -394,7 +394,7 @@ void cmd_reg_query_info(struct client_info *info)
/****************************************************************************
nt registry query key
****************************************************************************/
-void cmd_reg_query_key(struct client_info *info)
+void cmd_reg_query_key(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
BOOL res = True;
@@ -496,7 +496,7 @@ void cmd_reg_query_key(struct client_info *info)
/****************************************************************************
nt registry create value
****************************************************************************/
-void cmd_reg_create_val(struct client_info *info)
+void cmd_reg_create_val(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
BOOL res = True;
@@ -644,7 +644,7 @@ void cmd_reg_create_val(struct client_info *info)
/****************************************************************************
nt registry delete value
****************************************************************************/
-void cmd_reg_delete_val(struct client_info *info)
+void cmd_reg_delete_val(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
BOOL res = True;
@@ -721,7 +721,7 @@ void cmd_reg_delete_val(struct client_info *info)
/****************************************************************************
nt registry delete key
****************************************************************************/
-void cmd_reg_delete_key(struct client_info *info)
+void cmd_reg_delete_key(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
BOOL res = True;
@@ -801,7 +801,7 @@ void cmd_reg_delete_key(struct client_info *info)
/****************************************************************************
nt registry create key
****************************************************************************/
-void cmd_reg_create_key(struct client_info *info)
+void cmd_reg_create_key(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
BOOL res = True;
@@ -896,7 +896,7 @@ void cmd_reg_create_key(struct client_info *info)
/****************************************************************************
nt registry security info
****************************************************************************/
-void cmd_reg_test_key_sec(struct client_info *info)
+void cmd_reg_test_key_sec(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
BOOL res = True;
@@ -998,7 +998,7 @@ void cmd_reg_test_key_sec(struct client_info *info)
/****************************************************************************
nt registry security info
****************************************************************************/
-void cmd_reg_get_key_sec(struct client_info *info)
+void cmd_reg_get_key_sec(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
BOOL res = True;
@@ -1096,7 +1096,7 @@ void cmd_reg_get_key_sec(struct client_info *info)
/****************************************************************************
nt registry shutdown
****************************************************************************/
-void cmd_reg_shutdown(struct client_info *info)
+void cmd_reg_shutdown(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
BOOL res = True;
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index 0f0a19f2d1..fd1e3595cb 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -118,7 +118,7 @@ static void sam_display_user(const char *domain, const DOM_SID *sid,
/****************************************************************************
SAM password change
****************************************************************************/
-void cmd_sam_ntchange_pwd(struct client_info *info)
+void cmd_sam_ntchange_pwd(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
fstring srv_name;
@@ -196,7 +196,7 @@ void cmd_sam_ntchange_pwd(struct client_info *info)
/****************************************************************************
experimental SAM encryted rpc test connection
****************************************************************************/
-void cmd_sam_test(struct client_info *info)
+void cmd_sam_test(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
fstring srv_name;
@@ -253,11 +253,11 @@ void cmd_sam_test(struct client_info *info)
/****************************************************************************
Lookup domain in SAM server.
****************************************************************************/
-void cmd_sam_lookup_domain(struct client_info *info)
+void cmd_sam_lookup_domain(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
fstring srv_name;
- fstring domain;
+ char *domain;
fstring str_sid;
DOM_SID dom_sid;
BOOL res = True;
@@ -267,12 +267,14 @@ void cmd_sam_lookup_domain(struct client_info *info)
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
- if (!next_token(NULL, domain, NULL, sizeof(domain)))
+ if (argc < 2)
{
report(out_hnd, "lookupdomain: <name>\n");
return;
}
+ domain = argv[1];
+
report(out_hnd, "Lookup Domain in SAM Server\n");
/* open SAMR session. negotiate credentials */
@@ -310,12 +312,11 @@ void cmd_sam_lookup_domain(struct client_info *info)
/****************************************************************************
SAM delete alias member.
****************************************************************************/
-void cmd_sam_del_aliasmem(struct client_info *info)
+void cmd_sam_del_aliasmem(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
fstring srv_name;
fstring domain;
- fstring tmp;
fstring sid;
DOM_SID sid1;
POLICY_HND alias_pol;
@@ -342,12 +343,16 @@ void cmd_sam_del_aliasmem(struct client_info *info)
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
- if (!next_token(NULL, tmp, NULL, sizeof(tmp)))
+ if (argc < 2)
{
report(out_hnd, "delaliasmem: <alias rid> [member sid1] [member sid2] ...\n");
return;
}
- alias_rid = get_number(tmp);
+
+ argc--;
+ argv++;
+
+ alias_rid = get_number(argv[0]);
report(out_hnd, "SAM Domain Alias Member\n");
@@ -369,15 +374,17 @@ void cmd_sam_del_aliasmem(struct client_info *info)
&pol_dom,
0x000f001f, alias_rid, &alias_pol) : False;
- while (next_token(NULL, tmp, NULL, sizeof(tmp)) && res2 && res1)
+ while (argc > 0 && res2 && res1)
{
+ argc--;
+ argv++;
/* get a sid, delete a member from the alias */
- res2 = res2 ? string_to_sid(&member_sid, tmp) : False;
+ res2 = res2 ? string_to_sid(&member_sid, argv[0]) : False;
res2 = res2 ? samr_del_aliasmem(smb_cli, fnum, &alias_pol, &member_sid) : False;
if (res2)
{
- report(out_hnd, "SID deleted from Alias 0x%x: %s\n", alias_rid, tmp);
+ report(out_hnd, "SID deleted from Alias 0x%x: %s\n", alias_rid, argv[0]);
}
}
@@ -403,12 +410,12 @@ void cmd_sam_del_aliasmem(struct client_info *info)
/****************************************************************************
SAM delete alias.
****************************************************************************/
-void cmd_sam_delete_dom_alias(struct client_info *info)
+void cmd_sam_delete_dom_alias(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
fstring srv_name;
fstring domain;
- fstring name;
+ char *name;
fstring sid;
DOM_SID sid1;
POLICY_HND alias_pol;
@@ -438,12 +445,14 @@ void cmd_sam_delete_dom_alias(struct client_info *info)
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
- if (!next_token(NULL, name, NULL, sizeof(name)))
+ if (argc < 2)
{
report(out_hnd, "delalias <alias name>\n");
return;
}
+ name = argv[1];
+
report(out_hnd, "SAM Delete Domain Alias\n");
/* open SAMR session. negotiate credentials */
@@ -500,7 +509,7 @@ void cmd_sam_delete_dom_alias(struct client_info *info)
/****************************************************************************
SAM add alias member.
****************************************************************************/
-void cmd_sam_add_aliasmem(struct client_info *info)
+void cmd_sam_add_aliasmem(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
uint16 fnum_lsa;
@@ -540,20 +549,15 @@ void cmd_sam_add_aliasmem(struct client_info *info)
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
- while (next_token(NULL, tmp, NULL, sizeof(tmp)))
- {
- if (add_chars_to_array(&num_names, &names, tmp) == NULL)
- {
- return;
- }
- }
-
- if (num_names < 2)
+ if (argc < 2)
{
report(out_hnd, "addaliasmem <group name> [member name1] [member name2] ...\n");
return;
}
+ num_names = argc+1;
+ names = argv+1;
+
report(out_hnd, "SAM Domain Alias Member\n");
/* open LSARPC session. */
@@ -656,14 +660,15 @@ void cmd_sam_add_aliasmem(struct client_info *info)
/****************************************************************************
SAM create domain user.
****************************************************************************/
-void cmd_sam_create_dom_user(struct client_info *info)
+void cmd_sam_create_dom_user(struct client_info *info, int argc, char *argv[])
{
fstring domain;
fstring acct_name;
fstring sid;
DOM_SID sid1;
uint32 user_rid;
- uint16 acb_info;
+ uint16 acb_info = ACB_NORMAL;
+ int opt;
sid_copy(&sid1, &info->dom.level5_sid);
sid_to_string(sid, &sid1);
@@ -675,23 +680,45 @@ void cmd_sam_create_dom_user(struct client_info *info)
return;
}
-
- if (!next_token(NULL, acct_name, NULL, sizeof(acct_name)))
+ if (argc < 2)
{
- report(out_hnd, "createuser: <acct name>\n");
+ report(out_hnd, "createuser: <acct name> [-i] [-s]\n");
+ return;
}
+ argc--;
+ argv++;
+
+ safe_strcpy(acct_name, argv[0], sizeof(acct_name));
if (acct_name[strlen(acct_name)-1] == '$')
{
acb_info = ACB_WSTRUST;
}
- else
+
+ argc--;
+ argv++;
+
+ while ((opt = getopt(argc, argv,"is")) != EOF)
{
- acb_info = ACB_NORMAL;
+ switch (opt)
+ {
+ case 'i':
+ {
+ acb_info = ACB_DOMTRUST;
+ break;
+ }
+ case 's':
+ {
+ acb_info = ACB_SVRTRUST;
+ break;
+ }
+ }
}
+
report(out_hnd, "SAM Create Domain User\n");
- report(out_hnd, "Domain: %s Name: %s\n",
- domain, acct_name);
+ report(out_hnd, "Domain: %s Name: %s ACB: %s\n",
+ domain, acct_name,
+ pwdb_encode_acct_ctrl(acb_info, NEW_PW_FORMAT_SPACE_PADDED_LEN));
if (msrpc_sam_create_dom_user(smb_cli, &sid1,
acct_name, acb_info, &user_rid))
@@ -708,12 +735,12 @@ void cmd_sam_create_dom_user(struct client_info *info)
/****************************************************************************
SAM create domain alias.
****************************************************************************/
-void cmd_sam_create_dom_alias(struct client_info *info)
+void cmd_sam_create_dom_alias(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
fstring srv_name;
fstring domain;
- fstring acct_name;
+ char *acct_name;
fstring acct_desc;
fstring sid;
DOM_SID sid1;
@@ -739,16 +766,21 @@ void cmd_sam_create_dom_alias(struct client_info *info)
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
- if (!next_token(NULL, acct_name, NULL, sizeof(acct_name)))
+ if (argc < 2)
{
report(out_hnd, "createalias: <acct name> [acct description]\n");
}
- if (!next_token(NULL, acct_desc, NULL, sizeof(acct_desc)))
+ acct_name = argv[1];
+
+ if (argc < 3)
{
acct_desc[0] = 0;
}
-
+ else
+ {
+ safe_strcpy(acct_desc, argv[2], sizeof(acct_desc)-1);
+ }
report(out_hnd, "SAM Create Domain Alias\n");
report(out_hnd, "Domain: %s Name: %s Description: %s\n",
@@ -797,12 +829,11 @@ void cmd_sam_create_dom_alias(struct client_info *info)
/****************************************************************************
SAM delete group member.
****************************************************************************/
-void cmd_sam_del_groupmem(struct client_info *info)
+void cmd_sam_del_groupmem(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
fstring srv_name;
fstring domain;
- fstring tmp;
fstring sid;
DOM_SID sid1;
POLICY_HND pol_grp;
@@ -829,12 +860,16 @@ void cmd_sam_del_groupmem(struct client_info *info)
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
- if (!next_token(NULL, tmp, NULL, sizeof(tmp)))
+ if (argc < 2)
{
report(out_hnd, "delgroupmem: <group rid> [member rid1] [member rid2] ...\n");
return;
}
- group_rid = get_number(tmp);
+
+ argc--;
+ argv++;
+
+ group_rid = get_number(argv[0]);
report(out_hnd, "SAM Add Domain Group member\n");
@@ -856,10 +891,13 @@ void cmd_sam_del_groupmem(struct client_info *info)
&pol_dom,
0x0000001f, group_rid, &pol_grp) : False;
- while (next_token(NULL, tmp, NULL, sizeof(tmp)) && res2 && res1)
+ while (argc > 0 && res2 && res1)
{
+ argc--;
+ argv++;
+
/* get a rid, delete a member from the group */
- member_rid = get_number(tmp);
+ member_rid = get_number(argv[0]);
res2 = res2 ? samr_del_groupmem(smb_cli, fnum, &pol_grp, member_rid) : False;
if (res2)
@@ -891,12 +929,12 @@ void cmd_sam_del_groupmem(struct client_info *info)
/****************************************************************************
SAM delete group.
****************************************************************************/
-void cmd_sam_delete_dom_group(struct client_info *info)
+void cmd_sam_delete_dom_group(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
fstring srv_name;
fstring domain;
- fstring name;
+ char *name;
fstring sid;
DOM_SID sid1;
POLICY_HND pol_grp;
@@ -926,12 +964,14 @@ void cmd_sam_delete_dom_group(struct client_info *info)
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
- if (!next_token(NULL, name, NULL, sizeof(name)))
+ if (argc < 2)
{
report(out_hnd, "delgroup <group name>\n");
return;
}
+ name = argv[1];
+
report(out_hnd, "SAM Delete Domain Group\n");
/* open SAMR session. negotiate credentials */
@@ -989,12 +1029,11 @@ void cmd_sam_delete_dom_group(struct client_info *info)
/****************************************************************************
SAM add group member.
****************************************************************************/
-void cmd_sam_add_groupmem(struct client_info *info)
+void cmd_sam_add_groupmem(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
fstring srv_name;
fstring domain;
- fstring tmp;
fstring sid;
DOM_SID sid1;
POLICY_HND pol_grp;
@@ -1036,23 +1075,23 @@ void cmd_sam_add_groupmem(struct client_info *info)
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
- res = next_token(NULL, group_name, NULL, sizeof(group_name));
- group_names[0] = group_name;
-
- while (res && next_token(NULL, tmp, NULL, sizeof(tmp)))
- {
- if (add_chars_to_array(&num_names, &names, tmp) == NULL)
- {
- return;
- }
- }
-
- if (num_names < 1)
+ if (argc < 3)
{
report(out_hnd, "addgroupmem <group name> [member name1] [member name2] ...\n");
return;
}
+ argc--;
+ argv++;
+
+ group_names[0] = argv[0];
+
+ argc--;
+ argv++;
+
+ num_names = argc;
+ names = argv;
+
report(out_hnd, "SAM Add Domain Group member\n");
/* open SAMR session. negotiate credentials */
@@ -1163,12 +1202,12 @@ void cmd_sam_add_groupmem(struct client_info *info)
/****************************************************************************
SAM create domain group.
****************************************************************************/
-void cmd_sam_create_dom_group(struct client_info *info)
+void cmd_sam_create_dom_group(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
fstring srv_name;
fstring domain;
- fstring acct_name;
+ char *acct_name;
fstring acct_desc;
fstring sid;
DOM_SID sid1;
@@ -1194,15 +1233,21 @@ void cmd_sam_create_dom_group(struct client_info *info)
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
- if (!next_token(NULL, acct_name, NULL, sizeof(acct_name)))
+ if (argc < 2)
{
report(out_hnd, "creategroup: <acct name> [acct description]\n");
}
- if (!next_token(NULL, acct_desc, NULL, sizeof(acct_desc)))
+ acct_name = argv[1];
+
+ if (argc < 3)
{
acct_desc[0] = 0;
}
+ else
+ {
+ safe_strcpy(acct_desc, argv[2], sizeof(acct_desc)-1);
+ }
report(out_hnd, "SAM Create Domain Group\n");
@@ -1251,15 +1296,14 @@ void cmd_sam_create_dom_group(struct client_info *info)
/****************************************************************************
experimental SAM users enum.
****************************************************************************/
-void cmd_sam_enum_users(struct client_info *info)
+void cmd_sam_enum_users(struct client_info *info, int argc, char *argv[])
{
BOOL request_user_info = False;
BOOL request_group_info = False;
BOOL request_alias_info = False;
- fstring tmp;
struct acct_info *sam = NULL;
uint32 num_sam_entries = 0;
- int i;
+ int opt;
fstring srv_name;
fstring domain;
@@ -1279,18 +1323,28 @@ void cmd_sam_enum_users(struct client_info *info)
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
- for (i = 0; i < 3; i++)
+ argc--;
+ argv++;
+
+ while ((opt = getopt(argc, argv, "uga")) != EOF)
{
- /* a bad way to do token parsing... */
- if (next_token(NULL, tmp, NULL, sizeof(tmp)))
- {
- request_user_info |= strequal(tmp, "-u");
- request_group_info |= strequal(tmp, "-g");
- request_alias_info |= strequal(tmp, "-a");
- }
- else
+ switch (opt)
{
- break;
+ case 'u':
+ {
+ request_user_info = True;
+ break;
+ }
+ case 'g':
+ {
+ request_group_info = True;
+ break;
+ }
+ case 'a':
+ {
+ request_alias_info = True;
+ break;
+ }
}
}
@@ -1313,7 +1367,7 @@ void cmd_sam_enum_users(struct client_info *info)
/****************************************************************************
experimental SAM group query members.
****************************************************************************/
-void cmd_sam_query_groupmem(struct client_info *info)
+void cmd_sam_query_groupmem(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
fstring srv_name;
@@ -1323,7 +1377,7 @@ void cmd_sam_query_groupmem(struct client_info *info)
BOOL res = True;
BOOL res1 = True;
- fstring group_name;
+ char *group_name;
char *names[1];
uint32 num_rids;
uint32 rid[MAX_LOOKUP_SIDS];
@@ -1340,12 +1394,14 @@ void cmd_sam_query_groupmem(struct client_info *info)
return;
}
- if (!next_token(NULL, group_name, NULL, sizeof(group_name)))
+ if (argc < 2)
{
- report(out_hnd, "samgroup <name>\n");
+ report(out_hnd, "samgroupmem <name>\n");
return;
}
+ group_name = argv[1];
+
fstrcpy(srv_name, "\\\\");
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
@@ -1410,7 +1466,7 @@ void cmd_sam_query_groupmem(struct client_info *info)
/****************************************************************************
experimental SAM group query.
****************************************************************************/
-void cmd_sam_query_group(struct client_info *info)
+void cmd_sam_query_group(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
fstring srv_name;
@@ -1420,7 +1476,7 @@ void cmd_sam_query_group(struct client_info *info)
BOOL res = True;
BOOL res1 = True;
- fstring group_name;
+ char *group_name;
char *names[1];
uint32 num_rids;
uint32 rid[MAX_LOOKUP_SIDS];
@@ -1437,12 +1493,14 @@ void cmd_sam_query_group(struct client_info *info)
return;
}
- if (!next_token(NULL, group_name, NULL, sizeof(group_name)))
+ if (argc < 2)
{
report(out_hnd, "samgroup <name>\n");
return;
}
+ group_name = argv[1];
+
fstrcpy(srv_name, "\\\\");
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
@@ -1506,7 +1564,7 @@ void cmd_sam_query_group(struct client_info *info)
/****************************************************************************
experimental SAM user query.
****************************************************************************/
-void cmd_sam_query_user(struct client_info *info)
+void cmd_sam_query_user(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
fstring srv_name;
@@ -1516,7 +1574,7 @@ void cmd_sam_query_user(struct client_info *info)
BOOL res = True;
BOOL res1 = True;
- fstring user_name;
+ char *user_name;
char *names[1];
uint32 num_rids;
uint32 rid[MAX_LOOKUP_SIDS];
@@ -1533,12 +1591,14 @@ void cmd_sam_query_user(struct client_info *info)
return;
}
- if (!next_token(NULL, user_name, NULL, sizeof(user_name)))
+ if (argc < 2)
{
report(out_hnd, "samuser <name>\n");
return;
}
+ user_name = argv[1];
+
fstrcpy(srv_name, "\\\\");
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
@@ -1602,7 +1662,7 @@ void cmd_sam_query_user(struct client_info *info)
/****************************************************************************
experimental SAM user set.
****************************************************************************/
-void cmd_sam_set_userinfo2(struct client_info *info)
+void cmd_sam_set_userinfo2(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
fstring srv_name;
@@ -1611,16 +1671,10 @@ void cmd_sam_set_userinfo2(struct client_info *info)
DOM_SID sid;
BOOL res = True;
BOOL res1 = True;
- uint32 argc = 0;
- char **argv = NULL;
- uint32 cp_argc = 0;
- char **cp_argv = NULL;
- extern int optind;
int opt;
BOOL set_acb_bits = False;
fstring user_name;
- fstring tmp;
char *names[1];
uint32 num_rids;
@@ -1640,28 +1694,21 @@ void cmd_sam_set_userinfo2(struct client_info *info)
return;
}
- /* create arguments array */
- while (next_token(NULL, tmp, NULL, sizeof(tmp)))
- {
- add_chars_to_array(&argc, &argv, tmp);
- }
-
- cp_argc = argc;
- cp_argv = argv;
-
- if (cp_argc < 2)
+ if (argc < 2)
{
report(out_hnd, "samuserset2 <name> [-s <acb_bits>]\n");
return;
}
- safe_strcpy(user_name, cp_argv[0], sizeof(user_name));
+ argc--;
+ argv++;
+
+ safe_strcpy(user_name, argv[0], sizeof(user_name));
- cp_argc--;
- cp_argv++;
+ argc--;
+ argv++;
- optind = -1;
- while ((opt = getopt(cp_argc, cp_argv,"s:")) != EOF)
+ while ((opt = getopt(argc, argv,"s:")) != EOF)
{
switch (opt)
{
@@ -1751,14 +1798,12 @@ void cmd_sam_set_userinfo2(struct client_info *info)
report(out_hnd, "Set User Info: Failed\n");
DEBUG(5,("cmd_sam_query_user: failed\n"));
}
-
- free_char_array(argc, argv);
}
/****************************************************************************
experimental SAM user set.
****************************************************************************/
-void cmd_sam_set_userinfo(struct client_info *info)
+void cmd_sam_set_userinfo(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
fstring srv_name;
@@ -1767,17 +1812,11 @@ void cmd_sam_set_userinfo(struct client_info *info)
DOM_SID sid;
BOOL res = True;
BOOL res1 = True;
- uint32 argc = 0;
- char **argv = NULL;
- uint32 cp_argc = 0;
- char **cp_argv = NULL;
- extern int optind;
int opt;
BOOL set_passwd = False;
fstring user_name;
fstring password;
- fstring tmp;
char *names[1];
uint32 num_rids;
@@ -1796,27 +1835,21 @@ void cmd_sam_set_userinfo(struct client_info *info)
return;
}
- /* create arguments array */
- while (next_token(NULL, tmp, NULL, sizeof(tmp)))
- {
- add_chars_to_array(&argc, &argv, tmp);
- }
+ argc--;
+ argv++;
- cp_argc = argc;
- cp_argv = argv;
-
- if (cp_argc == 0)
+ if (argc == 0)
{
report(out_hnd, "samuserset <name> [-p password]\n");
return;
}
- safe_strcpy(user_name, cp_argv[0], sizeof(user_name));
+ safe_strcpy(user_name, argv[0], sizeof(user_name));
- cp_argc--;
- cp_argv++;
+ argc--;
+ argv++;
- if (cp_argc == 0)
+ if (argc == 0)
{
fstring pass_str;
char *pass;
@@ -1833,8 +1866,7 @@ void cmd_sam_set_userinfo(struct client_info *info)
}
else
{
- optind = -1;
- while ((opt = getopt(cp_argc, cp_argv,"p:")) != EOF)
+ while ((opt = getopt(argc, argv,"p:")) != EOF)
{
switch (opt)
{
@@ -1977,7 +2009,7 @@ void cmd_sam_set_userinfo(struct client_info *info)
/****************************************************************************
experimental SAM query display info.
****************************************************************************/
-void cmd_sam_query_dispinfo(struct client_info *info)
+void cmd_sam_query_dispinfo(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
fstring srv_name;
@@ -1985,7 +2017,6 @@ void cmd_sam_query_dispinfo(struct client_info *info)
fstring sid;
DOM_SID sid1;
BOOL res = True;
- fstring info_str;
uint16 switch_value = 1;
uint32 ace_perms = 0x304; /* absolutely no idea. */
SAM_DISPINFO_CTR ctr;
@@ -2009,9 +2040,9 @@ void cmd_sam_query_dispinfo(struct client_info *info)
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
- if (next_token(NULL, info_str, NULL, sizeof(info_str)))
+ if (argc > 1)
{
- switch_value = strtoul(info_str, (char**)NULL, 10);
+ switch_value = strtoul(argv[1], (char**)NULL, 10);
}
fprintf(out_hnd, "SAM Query Domain Info: info level %d\n", switch_value);
@@ -2065,12 +2096,11 @@ void cmd_sam_query_dispinfo(struct client_info *info)
/****************************************************************************
experimental SAM domain info query.
****************************************************************************/
-void cmd_sam_query_dominfo(struct client_info *info)
+void cmd_sam_query_dominfo(struct client_info *info, int argc, char *argv[])
{
fstring domain;
fstring sid;
DOM_SID sid1;
- fstring info_str;
uint32 switch_value = 2;
SAM_UNK_CTR ctr;
@@ -2085,9 +2115,9 @@ void cmd_sam_query_dominfo(struct client_info *info)
string_to_sid(&sid1, sid);
- if (next_token(NULL, info_str, NULL, sizeof(info_str)))
+ if (argc > 1)
{
- switch_value = strtoul(info_str, (char**)NULL, 10);
+ switch_value = strtoul(argv[1], (char**)NULL, 10);
}
report(out_hnd, "SAM Query Domain Info: info level %d\n", switch_value);
@@ -2110,7 +2140,7 @@ void cmd_sam_query_dominfo(struct client_info *info)
/****************************************************************************
experimental SAM alias query members.
****************************************************************************/
-void cmd_sam_query_aliasmem(struct client_info *info)
+void cmd_sam_query_aliasmem(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
fstring srv_name;
@@ -2120,7 +2150,7 @@ void cmd_sam_query_aliasmem(struct client_info *info)
BOOL res = True;
BOOL res1 = True;
- fstring alias_name;
+ char *alias_name;
char *names[1];
uint32 num_rids;
uint32 rid[MAX_LOOKUP_SIDS];
@@ -2137,12 +2167,14 @@ void cmd_sam_query_aliasmem(struct client_info *info)
return;
}
- if (!next_token(NULL, alias_name, NULL, sizeof(alias_name)))
+ if (argc < 2)
{
- report(out_hnd, "samalias <name>\n");
+ report(out_hnd, "samaliasmem <name>\n");
return;
}
+ alias_name = argv[1];
+
fstrcpy(srv_name, "\\\\");
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
@@ -2207,7 +2239,7 @@ void cmd_sam_query_aliasmem(struct client_info *info)
/****************************************************************************
experimental SAM alias query.
****************************************************************************/
-void cmd_sam_query_alias(struct client_info *info)
+void cmd_sam_query_alias(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
fstring srv_name;
@@ -2217,7 +2249,7 @@ void cmd_sam_query_alias(struct client_info *info)
BOOL res = True;
BOOL res1 = True;
- fstring alias_name;
+ char *alias_name;
char *names[1];
uint32 num_rids;
uint32 rid[MAX_LOOKUP_SIDS];
@@ -2234,12 +2266,14 @@ void cmd_sam_query_alias(struct client_info *info)
return;
}
- if (!next_token(NULL, alias_name, NULL, sizeof(alias_name)))
+ if (argc < 2)
{
report(out_hnd, "samalias <name>\n");
return;
}
+ alias_name = argv[1];
+
fstrcpy(srv_name, "\\\\");
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
@@ -2303,14 +2337,13 @@ void cmd_sam_query_alias(struct client_info *info)
/****************************************************************************
SAM aliases query.
****************************************************************************/
-void cmd_sam_enum_aliases(struct client_info *info)
+void cmd_sam_enum_aliases(struct client_info *info, int argc, char *argv[])
{
BOOL request_member_info = False;
BOOL request_alias_info = False;
- fstring tmp;
- int i;
struct acct_info *sam = NULL;
uint32 num_sam_entries = 0;
+ int opt;
fstring domain;
fstring srv_name;
@@ -2330,17 +2363,23 @@ void cmd_sam_enum_aliases(struct client_info *info)
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
- for (i = 0; i < 2; i++)
+ argc--;
+ argv++;
+
+ while ((opt = getopt(argc, argv, "ma")) != EOF)
{
- /* a bad way to do token parsing... */
- if (next_token(NULL, tmp, NULL, sizeof(tmp)))
- {
- request_member_info |= strequal(tmp, "-m");
- request_alias_info |= strequal(tmp, "-a");
- }
- else
+ switch (opt)
{
- break;
+ case 'm':
+ {
+ request_member_info = True;
+ break;
+ }
+ case 'a':
+ {
+ request_alias_info = True;
+ break;
+ }
}
}
@@ -2361,14 +2400,13 @@ void cmd_sam_enum_aliases(struct client_info *info)
/****************************************************************************
experimental SAM groups enum.
****************************************************************************/
-void cmd_sam_enum_groups(struct client_info *info)
+void cmd_sam_enum_groups(struct client_info *info, int argc, char *argv[])
{
BOOL request_member_info = False;
BOOL request_group_info = False;
- fstring tmp;
- int i;
struct acct_info *sam = NULL;
uint32 num_sam_entries = 0;
+ int opt;
fstring srv_name;
fstring domain;
@@ -2388,17 +2426,23 @@ void cmd_sam_enum_groups(struct client_info *info)
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
- for (i = 0; i < 3; i++)
+ argc--;
+ argv++;
+
+ while ((opt = getopt(argc, argv, "mg")) != EOF)
{
- /* a bad way to do token parsing... */
- if (next_token(NULL, tmp, NULL, sizeof(tmp)))
- {
- request_member_info |= strequal(tmp, "-m");
- request_group_info |= strequal(tmp, "-g");
- }
- else
+ switch (opt)
{
- break;
+ case 'm':
+ {
+ request_member_info = True;
+ break;
+ }
+ case 'g':
+ {
+ request_group_info = True;
+ break;
+ }
}
}
@@ -2419,13 +2463,12 @@ void cmd_sam_enum_groups(struct client_info *info)
/****************************************************************************
experimental SAM domains enum.
****************************************************************************/
-void cmd_sam_enum_domains(struct client_info *info)
+void cmd_sam_enum_domains(struct client_info *info, int argc, char *argv[])
{
BOOL request_domain_info = False;
- fstring tmp;
- int i;
struct acct_info *sam = NULL;
uint32 num_sam_entries = 0;
+ int opt;
fstring srv_name;
@@ -2433,16 +2476,18 @@ void cmd_sam_enum_domains(struct client_info *info)
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
- for (i = 0; i < 3; i++)
+ argc--;
+ argv++;
+
+ while ((opt = getopt(argc, argv, "i")) != EOF)
{
- /* a bad way to do token parsing... */
- if (next_token(NULL, tmp, NULL, sizeof(tmp)))
- {
- request_domain_info |= strequal(tmp, "-i");
- }
- else
+ switch (opt)
{
- break;
+ case 'i':
+ {
+ request_domain_info= True;
+ break;
+ }
}
}
diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c
index 9b5aa5b3e0..91a6ff0966 100644
--- a/source3/rpcclient/cmd_spoolss.c
+++ b/source3/rpcclient/cmd_spoolss.c
@@ -78,7 +78,7 @@ static void spool_print_info_ctr(const char* srv_name, uint32 level,
/****************************************************************************
nt spoolss query
****************************************************************************/
-void cmd_spoolss_enum_printers(struct client_info *info)
+void cmd_spoolss_enum_printers(struct client_info *info, int argc, char *argv[])
{
void **ctr = NULL;
uint32 num = 0;
@@ -105,7 +105,7 @@ void cmd_spoolss_enum_printers(struct client_info *info)
/****************************************************************************
nt spoolss query
****************************************************************************/
-void cmd_spoolss_open_printer_ex(struct client_info *info)
+void cmd_spoolss_open_printer_ex(struct client_info *info, int argc, char *argv[])
{
uint16 nt_pipe_fnum;
fstring srv_name;
@@ -231,7 +231,7 @@ static void spool_job_info_ctr(const char* srv_name, const char* printer_name,
/****************************************************************************
nt spoolss query
****************************************************************************/
-void cmd_spoolss_enum_jobs(struct client_info *info)
+void cmd_spoolss_enum_jobs(struct client_info *info, int argc, char *argv[])
{
fstring srv_name;
fstring printer_name;
diff --git a/source3/rpcclient/cmd_srvsvc.c b/source3/rpcclient/cmd_srvsvc.c
index c0cf56de51..ca2a8f4dc3 100644
--- a/source3/rpcclient/cmd_srvsvc.c
+++ b/source3/rpcclient/cmd_srvsvc.c
@@ -73,7 +73,7 @@ BOOL net_srv_get_info(struct client_info *info,
/****************************************************************************
server get info query
****************************************************************************/
-void cmd_srv_query_info(struct client_info *info)
+void cmd_srv_query_info(struct client_info *info, int argc, char *argv[])
{
uint32 info_level = 101;
SRV_INFO_CTR ctr;
@@ -149,7 +149,7 @@ static void srv_display_tprt_ctr(const SRV_TPRT_INFO_CTR *ctr)
/****************************************************************************
server enum transports
****************************************************************************/
-void cmd_srv_enum_tprt(struct client_info *info)
+void cmd_srv_enum_tprt(struct client_info *info, int argc, char *argv[])
{
fstring dest_srv;
fstring tmp;
@@ -181,7 +181,7 @@ void cmd_srv_enum_tprt(struct client_info *info)
/****************************************************************************
server enum connections
****************************************************************************/
-void cmd_srv_enum_conn(struct client_info *info)
+void cmd_srv_enum_conn(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
fstring dest_srv;
@@ -247,7 +247,7 @@ void cmd_srv_enum_conn(struct client_info *info)
/****************************************************************************
server enum shares
****************************************************************************/
-void cmd_srv_enum_shares(struct client_info *info)
+void cmd_srv_enum_shares(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
fstring dest_srv;
@@ -308,7 +308,7 @@ void cmd_srv_enum_shares(struct client_info *info)
/****************************************************************************
server enum sessions
****************************************************************************/
-void cmd_srv_enum_sess(struct client_info *info)
+void cmd_srv_enum_sess(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
fstring dest_srv;
@@ -368,7 +368,7 @@ void cmd_srv_enum_sess(struct client_info *info)
/****************************************************************************
server enum files
****************************************************************************/
-void cmd_srv_enum_files(struct client_info *info)
+void cmd_srv_enum_files(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
fstring dest_srv;
@@ -428,7 +428,7 @@ void cmd_srv_enum_files(struct client_info *info)
/****************************************************************************
display remote time
****************************************************************************/
-void cmd_time(struct client_info *info)
+void cmd_time(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
fstring dest_srv;
diff --git a/source3/rpcclient/cmd_svcctl.c b/source3/rpcclient/cmd_svcctl.c
index 07bebe2bda..f20d8e30d6 100644
--- a/source3/rpcclient/cmd_svcctl.c
+++ b/source3/rpcclient/cmd_svcctl.c
@@ -75,7 +75,7 @@ BOOL svc_query_service(struct cli_state *cli, uint16 fnum,
/****************************************************************************
nt service info
****************************************************************************/
-void cmd_svc_info(struct client_info *info)
+void cmd_svc_info(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
BOOL res = True;
@@ -216,7 +216,7 @@ BOOL msrpc_svc_enum(struct client_info *info,
/****************************************************************************
nt service enum
****************************************************************************/
-void cmd_svc_enum(struct client_info *info)
+void cmd_svc_enum(struct client_info *info, int argc, char *argv[])
{
ENUM_SRVC_STATUS *svcs = NULL;
uint32 num_svcs = 0;
@@ -244,7 +244,7 @@ void cmd_svc_enum(struct client_info *info)
/****************************************************************************
nt stop service
****************************************************************************/
-void cmd_svc_stop(struct client_info *info)
+void cmd_svc_stop(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
BOOL res = True;
@@ -303,7 +303,7 @@ void cmd_svc_stop(struct client_info *info)
/****************************************************************************
nt start service
****************************************************************************/
-void cmd_svc_start(struct client_info *info)
+void cmd_svc_start(struct client_info *info, int argc, char *argv[])
{
uint16 fnum;
BOOL res = True;
diff --git a/source3/rpcclient/cmd_wkssvc.c b/source3/rpcclient/cmd_wkssvc.c
index 7915036609..426e6690a0 100644
--- a/source3/rpcclient/cmd_wkssvc.c
+++ b/source3/rpcclient/cmd_wkssvc.c
@@ -41,7 +41,7 @@ extern FILE* out_hnd;
/****************************************************************************
workstation get info query
****************************************************************************/
-void cmd_wks_query_info(struct client_info *info)
+void cmd_wks_query_info(struct client_info *info, int argc, char *argv[])
{
uint16 nt_pipe_fnum;
fstring dest_wks;
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index 7e246b1bfc..4888e720b1 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -43,14 +43,16 @@ extern int DEBUGLEVEL;
#define CNV_INPUT(s) unix2dos_format(s,True)
static int process_tok(fstring tok);
-static void cmd_help(struct client_info *info);
-static void cmd_quit(struct client_info *info);
+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 struct cli_state smbcli;
struct cli_state *smb_cli = &smbcli;
static struct client_info cli_info;
+static char **cmd_argv = NULL;
+static uint32 cmd_argc = 0;
FILE *out_hnd;
@@ -113,7 +115,7 @@ static void rpcclient_stop(void)
struct
{
char *name;
- void (*fn)(struct client_info*);
+ void (*fn)(struct client_info*, int, char*[]);
char *description;
char compl_args[2];
}
@@ -605,7 +607,7 @@ commands[] =
/****************************************************************************
do a (presumably graceful) quit...
****************************************************************************/
-static void cmd_quit(struct client_info *info)
+static void cmd_quit(struct client_info *info, int argc, char *argv[])
{
rpcclient_stop();
#ifdef MEM_MAN
@@ -623,14 +625,13 @@ static void cmd_quit(struct client_info *info)
/****************************************************************************
help
****************************************************************************/
-static void cmd_help(struct client_info *info)
+static void cmd_help(struct client_info *info, int argc, char *argv[])
{
int i=0,j;
- fstring buf;
- if (next_token(NULL,buf,NULL, sizeof(buf)))
+ if (argc > 1)
{
- if ((i = process_tok(buf)) >= 0)
+ if ((i = process_tok(argv[1])) >= 0)
fprintf(out_hnd, "HELP %s:\n\t%s\n\n",commands[i].name,commands[i].description);
}
else
@@ -648,7 +649,7 @@ static void cmd_help(struct client_info *info)
lookup a command string in the list of commands, including
abbreviations
******************************************************************/
-static int process_tok(fstring tok)
+static int process_tok(char *tok)
{
int i = 0, matches = 0;
int cmd=0;
@@ -681,13 +682,33 @@ static int process_tok(fstring tok)
/****************************************************************************
process commands from the client
****************************************************************************/
-static void do_command(struct client_info *info, char *tok, char *line)
+static BOOL do_command(struct client_info *info, char *line)
{
int i;
+ char *ptr = line;
+ pstring tok;
- if ((i = process_tok(tok)) >= 0)
+ /* get the first part of the command */
+ if (!next_token(&ptr,tok,NULL, sizeof(tok)))
{
- commands[i].fn(info);
+ return False;
+ }
+
+ do
+ {
+ add_chars_to_array(&cmd_argc, &cmd_argv, tok);
+
+ } while (next_token(NULL, tok, NULL, sizeof(tok)));
+
+ if (cmd_argc == 0)
+ {
+ return False;
+ }
+
+ if ((i = process_tok(cmd_argv[0])) >= 0)
+ {
+ optind = -1;
+ commands[i].fn(info, (uint32)cmd_argc, cmd_argv);
}
else if (i == -2)
{
@@ -697,6 +718,12 @@ static void do_command(struct client_info *info, char *tok, char *line)
{
fprintf(out_hnd, "%s: command not found\n", CNV_LANG(tok));
}
+
+ free_char_array(cmd_argc, cmd_argv);
+ cmd_argc = 0;
+ cmd_argv = NULL;
+
+ return True;
}
#ifndef HAVE_LIBREADLINE
@@ -741,7 +768,6 @@ static BOOL process( struct client_info *info, char *cmd_str)
if (cmd[0] != '\0') while (cmd[0] != '\0')
{
char *p;
- fstring tok;
if ((p = strchr(cmd, ';')) == 0)
{
@@ -760,20 +786,13 @@ static BOOL process( struct client_info *info, char *cmd_str)
/* input language code to internal one */
CNV_INPUT (line);
- /* get the first part of the command */
- {
- char *ptr = line;
- if (!next_token(&ptr,tok,NULL, sizeof(tok))) continue;
- }
-
- do_command(info, tok, line);
+ if (!do_command(info, line)) continue;
}
else while (!feof(stdin))
{
#ifdef HAVE_LIBREADLINE
pstring promptline;
#endif
- fstring tok;
#ifndef HAVE_LIBREADLINE
@@ -831,13 +850,7 @@ static BOOL process( struct client_info *info, char *cmd_str)
fprintf(out_hnd, "%s\n", line);
- /* get the first part of the command */
- {
- char *ptr = line;
- if (!next_token(&ptr,tok,NULL, sizeof(tok))) continue;
- }
-
- do_command(info, tok, line);
+ if (!do_command(info, line)) continue;
}
return(True);
@@ -920,9 +933,6 @@ static void reg_val_list(const char *full_name,
add_chars_to_array(&reg_list_len, &reg_name, name);
}
-static char **cmd_argv;
-static uint32 cmd_argc;
-
static char *complete_regenum(char *text, int state)
{
pstring full_keyname;
@@ -1248,27 +1258,16 @@ static char *complete_cmd(char *text, int state)
static char **completion_fn(char *text, int start, int end)
{
- pstring tmp;
pstring cmd_partial;
int cmd_index;
int num_words;
- char *ptr = cmd_partial;
int i;
char lastch = ' ';
- free_char_array(cmd_argc, cmd_argv);
- cmd_argc = 0;
- cmd_argv = NULL;
-
safe_strcpy(cmd_partial, rl_line_buffer,
MAX(sizeof(cmd_partial),end)-1);
- if (next_token(&ptr, tmp, NULL, sizeof(tmp)))
- {
- add_chars_to_array(&cmd_argc, &cmd_argv, tmp);
- }
-
/* Complete rpcclient command */
if (start == 0)
@@ -1282,10 +1281,6 @@ static char **completion_fn(char *text, int start, int end)
for (i = 0; i <= end; i++) {
if ((rl_line_buffer[i] != ' ') && (lastch == ' '))
{
- if (next_token(NULL, tmp, NULL, sizeof(tmp)))
- {
- add_chars_to_array(&cmd_argc, &cmd_argv, tmp);
- }
num_words++;
}
lastch = rl_line_buffer[i];