summaryrefslogtreecommitdiff
path: root/source3/rpcclient
diff options
context:
space:
mode:
authorLuke Leighton <lkcl@samba.org>1999-11-26 23:04:19 +0000
committerLuke Leighton <lkcl@samba.org>1999-11-26 23:04:19 +0000
commit9b683054751866af4fb2ac79c092392e31effaff (patch)
treee9648db6efbff69ff731c1df466f59fd21cc853e /source3/rpcclient
parent5e3bc7875656362770b0c9a2a45d2f83c985c6e5 (diff)
downloadsamba-9b683054751866af4fb2ac79c092392e31effaff.tar.gz
samba-9b683054751866af4fb2ac79c092392e31effaff.tar.bz2
samba-9b683054751866af4fb2ac79c092392e31effaff.zip
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 used to be commit 29c480085e786905bfd92ea3cd93658f94e96e47)
Diffstat (limited to 'source3/rpcclient')
-rw-r--r--source3/rpcclient/cmd_atsvc.c6
-rw-r--r--source3/rpcclient/cmd_reg.c10
-rw-r--r--source3/rpcclient/cmd_samr.c375
-rw-r--r--source3/rpcclient/cmd_svcctl.c3
-rw-r--r--source3/rpcclient/display.c692
-rw-r--r--source3/rpcclient/rpcclient.c467
6 files changed, 775 insertions, 778 deletions
diff --git a/source3/rpcclient/cmd_atsvc.c b/source3/rpcclient/cmd_atsvc.c
index 5c5986eaa0..e07a89f4d9 100644
--- a/source3/rpcclient/cmd_atsvc.c
+++ b/source3/rpcclient/cmd_atsvc.c
@@ -344,16 +344,18 @@ void cmd_at(struct client_info *info, int argc, char *argv[])
else if (jobid == -1) /* enumerate */
{
AT_ENUM_INFO jobs[AT_MAX_JOBS];
- fstring commands[AT_MAX_JOBS];
+ char **commands;
uint32 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_ENUMERATE, 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 */
{
diff --git a/source3/rpcclient/cmd_reg.c b/source3/rpcclient/cmd_reg.c
index cae24faf9f..38c14ea96b 100644
--- a/source3/rpcclient/cmd_reg.c
+++ b/source3/rpcclient/cmd_reg.c
@@ -294,13 +294,10 @@ void cmd_reg_enum(struct client_info *info, int argc, char *argv[])
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_info,
- reg_display_val_info))
- {
- pstrcpy(info->cur_dir, full_keyname);
- }
+ reg_display_val_info));
}
/****************************************************************************
@@ -1104,9 +1101,6 @@ void cmd_reg_shutdown(struct client_info *info, int argc, char *argv[])
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
- argc--;
- argv++;
-
while ((opt = getopt(argc, argv,"fim:t:r-")) != EOF)
{
switch (opt)
diff --git a/source3/rpcclient/cmd_samr.c b/source3/rpcclient/cmd_samr.c
index cdb56e0a32..fbfde7c9a4 100644
--- a/source3/rpcclient/cmd_samr.c
+++ b/source3/rpcclient/cmd_samr.c
@@ -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");
/* establish a connection. */
- res = res ? samr_connect(
- srv_name, 0x02000000,
+ res = res ? samr_connect( srv_name, 0x02000000,
&sam_pol) : False;
/* connect to the domain */
- res = res ? samr_query_lookup_domain(
- &sam_pol, domain, &dom_sid) : False;
+ res = res ? samr_query_lookup_domain( &sam_pol, domain, &dom_sid) : False;
- res = res ? samr_close( &sam_pol) : False;
+ res = res ? samr_close(&sam_pol) : False;
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");
/* establish a connection. */
- res = res ? samr_connect(
- srv_name, 0x02000000,
+ res = res ? samr_connect( srv_name, 0x02000000,
&sam_pol) : False;
/* connect to the domain */
- res = res ? samr_open_domain(
- &sam_pol, ace_perms, &sid1,
+ res = res ? samr_open_domain( &sam_pol, ace_perms, &sid1,
&pol_dom) : False;
/* connect to the domain */
- res1 = res ? samr_open_alias(
- &pol_dom,
+ res1 = res ? samr_open_alias( &pol_dom,
0x000f001f, alias_rid, &alias_pol) : False;
while (argc > 0 && res2 && res1)
@@ -370,7 +365,7 @@ void cmd_sam_del_aliasmem(struct client_info *info, int argc, char *argv[])
argv++;
/* get a sid, delete a member from the alias */
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)
{
@@ -378,9 +373,9 @@ void cmd_sam_del_aliasmem(struct client_info *info, int argc, char *argv[])
}
}
- res1 = res1 ? samr_close( &alias_pol) : False;
- res = res ? samr_close( &pol_dom) : False;
- res = res ? samr_close( &sam_pol) : False;
+ res1 = res1 ? samr_close(&alias_pol) : False;
+ res = res ? samr_close(&pol_dom) : False;
+ res = res ? samr_close(&sam_pol) : False;
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");
/* establish a connection. */
- res = res ? samr_connect(
- srv_name, 0x02000000,
+ res = res ? samr_connect( srv_name, 0x02000000,
&sam_pol) : False;
/* connect to the domain */
- res = res ? samr_open_domain(
- &sam_pol, ace_perms, &sid1,
+ res = res ? samr_open_domain( &sam_pol, ace_perms, &sid1,
&pol_dom) : False;
names[0] = name;
- res1 = res ? samr_query_lookup_names(
- &pol_dom, 0x000003e8,
+ res1 = res ? samr_query_lookup_names( &pol_dom, 0x000003e8,
1, names,
&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 */
- res1 = res1 ? samr_open_alias(
- &pol_dom,
+ res1 = res1 ? samr_open_alias( &pol_dom,
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;
- res = res ? samr_close( &pol_dom) : False;
- res = res ? samr_close( &sam_pol) : False;
+ res1 = res1 ? samr_close(&alias_pol) : False;
+ res = res ? samr_close(&pol_dom) : False;
+ res = res ? samr_close(&sam_pol) : False;
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");
/* 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;
/* send lsa lookup sids call */
- res4 = res3 ? lsa_lookup_names( &lsa_pol,
+ res4 = res3 ? lsa_lookup_names(&lsa_pol,
num_names, names,
&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. */
- res = res ? samr_connect(
- srv_name, 0x02000000,
+ res = res ? samr_connect( srv_name, 0x02000000,
&sam_pol) : False;
/* connect to the domain */
- res = res ? samr_open_domain(
- &sam_pol, ace_perms, &sid1,
+ res = res ? samr_open_domain( &sam_pol, ace_perms, &sid1,
&pol_dom) : False;
/* connect to the domain */
- res1 = res ? samr_open_alias(
- &pol_dom,
+ res1 = res ? samr_open_alias( &pol_dom,
0x000f001f, alias_rid, &alias_pol) : False;
for (i = 1; i < num_sids && res2 && res1; i++)
{
/* 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)
{
@@ -598,9 +586,9 @@ void cmd_sam_add_aliasmem(struct client_info *info, int argc, char *argv[])
}
}
- res1 = res1 ? samr_close( &alias_pol) : False;
- res = res ? samr_close( &pol_dom) : False;
- res = res ? samr_close( &sam_pol) : False;
+ res1 = res1 ? samr_close(&alias_pol) : False;
+ res = res ? samr_close(&pol_dom) : False;
+ res = res ? samr_close(&sam_pol) : False;
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;
}
- argc--;
- argv++;
-
while ((opt = getopt(argc, argv,"is")) != EOF)
{
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);
/* establish a connection. */
- res = res ? samr_connect(
- srv_name, 0x02000000,
+ res = res ? samr_connect( srv_name, 0x02000000,
&sam_pol) : False;
/* connect to the domain */
- res = res ? samr_open_domain(
- &sam_pol, ace_perms, &sid1,
+ res = res ? samr_open_domain( &sam_pol, ace_perms, &sid1,
&pol_dom) : False;
/* create a domain alias */
- res1 = res ? create_samr_domain_alias(
- &pol_dom,
+ res1 = res ? create_samr_domain_alias( &pol_dom,
acct_name, acct_desc, &alias_rid) : 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)
{
@@ -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");
/* establish a connection. */
- res = res ? samr_connect(
- srv_name, 0x02000000,
+ res = res ? samr_connect( srv_name, 0x02000000,
&sam_pol) : False;
/* connect to the domain */
- res = res ? samr_open_domain(
- &sam_pol, ace_perms, &sid1,
+ res = res ? samr_open_domain( &sam_pol, ace_perms, &sid1,
&pol_dom) : False;
/* connect to the domain */
- res1 = res ? samr_open_group(
- &pol_dom,
+ res1 = res ? samr_open_group( &pol_dom,
0x0000001f, group_rid, &pol_grp) : False;
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 */
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)
{
@@ -943,9 +920,9 @@ void cmd_sam_del_groupmem(struct client_info *info, int argc, char *argv[])
}
}
- res1 = res1 ? samr_close( &pol_grp) : False;
- res = res ? samr_close( &pol_dom) : False;
- res = res ? samr_close( &sam_pol) : False;
+ res1 = res1 ? samr_close(&pol_grp) : False;
+ res = res ? samr_close(&pol_dom) : False;
+ res = res ? samr_close(&sam_pol) : False;
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");
/* establish a connection. */
- res = res ? samr_connect(
- srv_name, 0x02000000,
+ res = res ? samr_connect( srv_name, 0x02000000,
&sam_pol) : False;
/* connect to the domain */
- res = res ? samr_open_domain(
- &sam_pol, ace_perms, &sid1,
+ res = res ? samr_open_domain( &sam_pol, ace_perms, &sid1,
&pol_dom) : False;
names[0] = name;
- res1 = res ? samr_query_lookup_names(
- &pol_dom, 0x000003e8,
+ res1 = res ? samr_query_lookup_names( &pol_dom, 0x000003e8,
1, names,
&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 */
- res1 = res1 ? samr_open_group(
- &pol_dom,
+ res1 = res1 ? samr_open_group( &pol_dom,
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;
- res = res ? samr_close( &pol_dom) : False;
- res = res ? samr_close( &sam_pol) : False;
+ res1 = res1 ? samr_close(&pol_grp) : False;
+ res = res ? samr_close(&pol_dom) : False;
+ res = res ? samr_close(&sam_pol) : False;
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");
/* establish a connection. */
- res = res ? samr_connect(
- srv_name, 0x02000000,
+ res = res ? samr_connect( srv_name, 0x02000000,
&sam_pol) : False;
/* connect to the domain */
- res4 = res ? samr_open_domain(
- &sam_pol, ace_perms, &sid1,
+ res4 = res ? samr_open_domain( &sam_pol, ace_perms, &sid1,
&pol_dom) : False;
/* connect to the domain */
- res3 = res ? samr_open_domain(
- &sam_pol, ace_perms, &sid_1_5_20,
+ res3 = res ? samr_open_domain( &sam_pol, ace_perms, &sid_1_5_20,
&pol_blt) : False;
- res2 = res4 ? samr_query_lookup_names(
- &pol_dom, 0x000003e8,
+ res2 = res4 ? samr_query_lookup_names( &pol_dom, 0x000003e8,
1, group_names,
&num_group_rids, group_rid, group_type) : False;
/* open the group */
- res2 = res2 ? samr_open_group(
- &pol_dom,
+ res2 = res2 ? samr_open_group( &pol_dom,
0x0000001f, group_rid[0], &pol_grp) : False;
if (!res2 || (group_type != NULL && group_type[0] == SID_NAME_UNKNOWN))
{
- res2 = res3 ? samr_query_lookup_names(
- &pol_blt, 0x000003e8,
+ res2 = res3 ? samr_query_lookup_names( &pol_blt, 0x000003e8,
1, group_names,
&num_group_rids, group_rid, group_type) : False;
/* open the group */
- res2 = res2 ? samr_open_group(
- &pol_blt,
+ res2 = res2 ? samr_open_group( &pol_blt,
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);
return;
}
- res1 = res2 ? samr_query_lookup_names(
- &pol_dom, 0x000003e8,
+ res1 = res2 ? samr_query_lookup_names( &pol_dom, 0x000003e8,
num_names, names,
&num_rids, rid, type) : False;
@@ -1181,7 +1146,7 @@ void cmd_sam_add_groupmem(struct client_info *info, int argc, char *argv[])
}
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",
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 = res3 ? samr_close( &pol_blt) : False;
- res1 = res4 ? samr_close( &pol_dom) : False;
- res = res ? samr_close( &sam_pol) : False;
+ res1 = res ? samr_close(&pol_grp) : False;
+ res1 = res3 ? samr_close(&pol_blt) : False;
+ res1 = res4 ? samr_close(&pol_dom) : False;
+ res = res ? samr_close(&sam_pol) : False;
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);
/* establish a connection. */
- res = res ? samr_connect(
- srv_name, 0x02000000,
+ res = res ? samr_connect( srv_name, 0x02000000,
&sam_pol) : False;
/* connect to the domain */
- res = res ? samr_open_domain(
- &sam_pol, ace_perms, &sid1,
+ res = res ? samr_open_domain( &sam_pol, ace_perms, &sid1,
&pol_dom) : False;
/* read some users */
- res1 = res ? create_samr_domain_group(
- &pol_dom,
+ res1 = res ? create_samr_domain_group( &pol_dom,
acct_name, acct_desc, &group_rid) : 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)
{
@@ -1336,9 +1296,6 @@ void cmd_sam_enum_users(struct client_info *info, int argc, char *argv[])
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
- argc--;
- argv++;
-
while ((opt = getopt(argc, argv, "uga")) != EOF)
{
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");
- msrpc_sam_enum_users( srv_name, domain, &sid1,
+ msrpc_sam_enum_users(srv_name, domain, &sid1,
&sam, &num_sam_entries,
sam_display_user,
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);
/* establish a connection. */
- res = res ? samr_connect(
- srv_name, 0x02000000,
+ res = res ? samr_connect( srv_name, 0x02000000,
&sam_pol) : False;
/* connect to the domain */
- res = res ? samr_open_domain(
- &sam_pol, 0x304, &sid,
+ res = res ? samr_open_domain( &sam_pol, 0x304, &sid,
&pol_dom) : False;
/* look up group rid */
names[0] = group_name;
- res1 = res ? samr_query_lookup_names(
- &pol_dom, 0x3e8,
+ res1 = res ? samr_query_lookup_names( &pol_dom, 0x3e8,
1, names,
&num_rids, rid, type) : False;
if (res1 && num_rids == 1)
{
- res1 = req_groupmem_info(
- &pol_dom,
+ res1 = req_groupmem_info( &pol_dom,
domain,
&sid,
rid[0],
@@ -1452,11 +1405,9 @@ void cmd_sam_query_groupmem(struct client_info *info, int argc, char *argv[])
sam_display_group_members);
}
- res = res ? samr_close(
- &sam_pol) : False;
+ res = res ? samr_close( &sam_pol) : False;
- res = res ? samr_close(
- &pol_dom) : False;
+ res = res ? samr_close( &pol_dom) : False;
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);
/* establish a connection. */
- res = res ? samr_connect(
- srv_name, 0x02000000,
+ res = res ? samr_connect( srv_name, 0x02000000,
&sam_pol) : False;
/* connect to the domain */
- res = res ? samr_open_domain(
- &sam_pol, 0x304, &sid,
+ res = res ? samr_open_domain( &sam_pol, 0x304, &sid,
&pol_dom) : False;
/* look up group rid */
names[0] = group_name;
- res1 = res ? samr_query_lookup_names(
- &pol_dom, 0x3e8,
+ res1 = res ? samr_query_lookup_names( &pol_dom, 0x3e8,
1, names,
&num_rids, rid, type) : False;
if (res1 && num_rids == 1)
{
- res1 = query_groupinfo(
- &pol_dom,
+ res1 = query_groupinfo( &pol_dom,
domain,
&sid,
rid[0],
sam_display_group_info);
}
- res = res ? samr_close(
- &sam_pol) : False;
+ res = res ? samr_close( &sam_pol) : False;
- res = res ? samr_close(
- &pol_dom) : False;
+ res = res ? samr_close( &pol_dom) : False;
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);
/* establish a connection. */
- res = res ? samr_connect(
- srv_name, 0x02000000,
+ res = res ? samr_connect( srv_name, 0x02000000,
&sam_pol) : False;
/* connect to the domain */
- res = res ? samr_open_domain(
- &sam_pol, 0x304, &sid,
+ res = res ? samr_open_domain( &sam_pol, 0x304, &sid,
&pol_dom) : False;
/* look up user rid */
names[0] = user_name;
- res1 = res ? samr_query_lookup_names(
- &pol_dom, 0x3e8,
+ res1 = res ? samr_query_lookup_names( &pol_dom, 0x3e8,
1, names,
&num_rids, rid, type) : False;
/* send user info query */
if (res1 && num_rids == 1)
{
- res1 = req_user_info(
- &pol_dom,
+ res1 = req_user_info( &pol_dom,
domain,
&sid,
rid[0],
sam_display_user_info);
}
- res = res ? samr_close(
- &sam_pol) : False;
+ res = res ? samr_close( &sam_pol) : False;
- res = res ? samr_close(
- &pol_dom) : False;
+ res = res ? samr_close( &pol_dom) : False;
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));
- argc--;
- argv++;
-
while ((opt = getopt(argc, argv,"s:")) != EOF)
{
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);
/* establish a connection. */
- res = res ? samr_connect(
- srv_name, 0x02000000,
+ res = res ? samr_connect( srv_name, 0x02000000,
&sam_pol) : False;
/* connect to the domain */
- res = res ? samr_open_domain(
- &sam_pol, 0x02000000, &sid,
+ res = res ? samr_open_domain( &sam_pol, 0x02000000, &sid,
&pol_dom) : False;
/* look up user rid */
names[0] = user_name;
- res1 = res ? samr_query_lookup_names(
- &pol_dom, 0x3e8,
+ res1 = res ? samr_query_lookup_names( &pol_dom, 0x3e8,
1, names,
&num_rids, rid, type) : False;
/* send set user info */
- if (res1 && num_rids == 1 && get_samr_query_userinfo(
- &pol_dom,
+ if (res1 && num_rids == 1 && get_samr_query_userinfo( &pol_dom,
0x10, rid[0],
(void*)&usr16))
{
@@ -1762,16 +1694,13 @@ void cmd_sam_set_userinfo2(struct client_info *info, int argc, char *argv[])
if (usr != NULL)
{
- res1 = set_samr_set_userinfo2(
- &pol_dom,
+ res1 = set_samr_set_userinfo2( &pol_dom,
switch_value, rid[0], usr);
}
}
- res = res ? samr_close(
- &sam_pol) : False;
+ res = res ? samr_close( &sam_pol) : False;
- res = res ? samr_close(
- &pol_dom) : False;
+ res = res ? samr_close( &pol_dom) : False;
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));
- argc--;
- argv++;
-
- if (argc == 0)
+ if (argc == 1)
{
fstring pass_str;
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);
/* establish a connection. */
- res = res ? samr_connect(
- srv_name, 0x02000000,
+ res = res ? samr_connect( srv_name, 0x02000000,
&sam_pol) : False;
/* connect to the domain */
- res = res ? samr_open_domain(
- &sam_pol, 0x02000000, &sid,
+ res = res ? samr_open_domain( &sam_pol, 0x02000000, &sid,
&pol_dom) : False;
/* look up user rid */
names[0] = user_name;
- res1 = res ? samr_query_lookup_names(
- &pol_dom, 0x3e8,
+ res1 = res ? samr_query_lookup_names( &pol_dom, 0x3e8,
1, names,
&num_rids, rid, type) : False;
/* send set user info */
- if (res1 && num_rids == 1 && get_samr_query_userinfo(
- &pol_dom,
+ if (res1 && num_rids == 1 && get_samr_query_userinfo( &pol_dom,
0x15, rid[0], &usr21))
{
void *usr = NULL;
@@ -1954,16 +1876,13 @@ void cmd_sam_set_userinfo(struct client_info *info, int argc, char *argv[])
}
if (usr != NULL)
{
- res1 = set_samr_set_userinfo(
- &pol_dom,
+ res1 = set_samr_set_userinfo( &pol_dom,
switch_value, rid[0], usr);
}
}
- res = res ? samr_close(
- &sam_pol) : False;
+ res = res ? samr_close( &sam_pol) : False;
- res = res ? samr_close(
- &pol_dom) : False;
+ res = res ? samr_close( &pol_dom) : False;
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.
@@ -1987,14 +1917,10 @@ void cmd_sam_query_dispinfo(struct client_info *info, int argc, char *argv[])
fstring domain;
fstring sid;
DOM_SID sid1;
- BOOL res = True;
uint16 switch_value = 1;
- uint32 ace_perms = 0x304; /* absolutely no idea. */
SAM_DISPINFO_CTR ctr;
SAM_DISPINFO_1 inf1;
uint32 num_entries;
- POLICY_HND sam_pol;
- POLICY_HND pol_dom;
sid_to_string(sid, &info->dom.level5_sid);
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);
}
- 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;
- /* send a samr query_disp_info command */
- res = 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 (res)
+ if (msrpc_sam_query_dispinfo( srv_name, domain, &sid1,
+ switch_value,
+ &num_entries, &ctr, sam_display_disp_info))
{
+
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
{
@@ -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",
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"));
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);
/* establish a connection. */
- res = res ? samr_connect(
- srv_name, 0x02000000,
+ res = res ? samr_connect( srv_name, 0x02000000,
&sam_pol) : False;
/* connect to the domain */
- res = res ? samr_open_domain(
- &sam_pol, 0x304, &sid,
+ res = res ? samr_open_domain( &sam_pol, 0x304, &sid,
&pol_dom) : False;
/* look up alias rid */
names[0] = alias_name;
- res1 = res ? samr_query_lookup_names(
- &pol_dom, 0x3e8,
+ res1 = res ? samr_query_lookup_names( &pol_dom, 0x3e8,
1, names,
&num_rids, rid, type) : False;
if (res1 && num_rids == 1)
{
- res1 = req_aliasmem_info(
+ res1 = req_aliasmem_info(srv_name,
&pol_dom,
domain,
&sid,
@@ -2182,11 +2078,9 @@ void cmd_sam_query_aliasmem(struct client_info *info, int argc, char *argv[])
sam_display_alias_members);
}
- res = res ? samr_close(
- &sam_pol) : False;
+ res = res ? samr_close( &sam_pol) : False;
- res = res ? samr_close(
- &pol_dom) : False;
+ res = res ? samr_close( &pol_dom) : False;
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);
/* establish a connection. */
- res = res ? samr_connect(
- srv_name, 0x02000000,
+ res = res ? samr_connect( srv_name, 0x02000000,
&sam_pol) : False;
/* connect to the domain */
- res = res ? samr_open_domain(
- &sam_pol, 0x304, &sid,
+ res = res ? samr_open_domain( &sam_pol, 0x304, &sid,
&pol_dom) : False;
/* look up alias rid */
names[0] = alias_name;
- res1 = res ? samr_query_lookup_names(
- &pol_dom, 0x3e8,
+ res1 = res ? samr_query_lookup_names( &pol_dom, 0x3e8,
1, names,
&num_rids, rid, type) : False;
if (res1 && num_rids == 1)
{
- res1 = query_aliasinfo(
- &pol_dom,
+ res1 = query_aliasinfo( &pol_dom,
domain,
&sid,
rid[0],
sam_display_alias_info);
}
- res = res ? samr_close(
- &sam_pol) : False;
+ res = res ? samr_close( &sam_pol) : False;
- res = res ? samr_close(
- &pol_dom) : False;
+ res = res ? samr_close( &pol_dom) : False;
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);
strupper(srv_name);
- argc--;
- argv++;
-
while ((opt = getopt(argc, argv, "ma")) != EOF)
{
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);
strupper(srv_name);
- argc--;
- argv++;
-
while ((opt = getopt(argc, argv, "mg")) != EOF)
{
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);
strupper(srv_name);
- argc--;
- argv++;
-
while ((opt = getopt(argc, argv, "i")) != EOF)
{
switch (opt)
diff --git a/source3/rpcclient/cmd_svcctl.c b/source3/rpcclient/cmd_svcctl.c
index 7f3f8532a5..d118a7d15d 100644
--- a/source3/rpcclient/cmd_svcctl.c
+++ b/source3/rpcclient/cmd_svcctl.c
@@ -201,9 +201,6 @@ void cmd_svc_enum(struct client_info *info, int argc, char *argv[])
fstrcat(srv_name, info->dest_host);
strupper(srv_name);
- argc--;
- argv++;
-
while ((opt = getopt(argc, argv,"i")) != EOF)
{
switch (opt)
diff --git a/source3/rpcclient/display.c b/source3/rpcclient/display.c
index d1dfbd117d..58bdba5ffb 100644
--- a/source3/rpcclient/display.c
+++ b/source3/rpcclient/display.c
@@ -181,7 +181,7 @@ void display_srv_info_101(FILE *out_hnd, enum action_type action,
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "Server Info Level 101:\n");
+ report(out_hnd, "Server Info Level 101:\n");
break;
}
@@ -195,8 +195,8 @@ void display_srv_info_101(FILE *out_hnd, enum action_type action,
display_server(out_hnd, action, name, sv101->srv_type, comment);
- fprintf(out_hnd, "\tplatform_id :\t%d\n" , sv101->platform_id);
- fprintf(out_hnd, "\tos version :\t%d.%d\n" , sv101->ver_major, sv101->ver_minor);
+ report(out_hnd, "\tplatform_id :\t%d\n" , sv101->platform_id);
+ report(out_hnd, "\tos version :\t%d.%d\n" , sv101->ver_major, sv101->ver_minor);
break;
}
@@ -222,7 +222,7 @@ void display_srv_info_102(FILE *out_hnd, enum action_type action, SRV_INFO_102 *
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "Server Info Level 102:\n");
+ report(out_hnd, "Server Info Level 102:\n");
break;
}
@@ -239,14 +239,14 @@ void display_srv_info_102(FILE *out_hnd, enum action_type action, SRV_INFO_102 *
display_server(out_hnd, action, name, sv102->srv_type, comment);
- fprintf(out_hnd, "\tplatform_id :\t%d\n" , sv102->platform_id);
- fprintf(out_hnd, "\tos version :\t%d.%d\n" , sv102->ver_major, sv102->ver_minor);
+ report(out_hnd, "\tplatform_id :\t%d\n" , sv102->platform_id);
+ report(out_hnd, "\tos version :\t%d.%d\n" , sv102->ver_major, sv102->ver_minor);
- fprintf(out_hnd, "\tusers :\t%x\n" , sv102->users );
- fprintf(out_hnd, "\tdisc, hidden :\t%x, %x\n" , sv102->disc , sv102->hidden );
- fprintf(out_hnd, "\tannounce, delta :\t%d, %d\n", sv102->announce , sv102->ann_delta);
- fprintf(out_hnd, "\tlicenses :\t%d\n" , sv102->licenses );
- fprintf(out_hnd, "\tuser path :\t%s\n" , usr_path);
+ report(out_hnd, "\tusers :\t%x\n" , sv102->users );
+ report(out_hnd, "\tdisc, hidden :\t%x, %x\n" , sv102->disc , sv102->hidden );
+ report(out_hnd, "\tannounce, delta :\t%d, %d\n", sv102->announce , sv102->ann_delta);
+ report(out_hnd, "\tlicenses :\t%d\n" , sv102->licenses );
+ report(out_hnd, "\tuser path :\t%s\n" , usr_path);
break;
}
@@ -264,7 +264,7 @@ void display_srv_info_ctr(FILE *out_hnd, enum action_type action, SRV_INFO_CTR *
{
if (ctr == NULL || ctr->ptr_srv_ctr == 0)
{
- fprintf(out_hnd, "Server Information: unavailable due to an error\n");
+ report(out_hnd, "Server Information: unavailable due to an error\n");
return;
}
@@ -282,7 +282,7 @@ void display_srv_info_ctr(FILE *out_hnd, enum action_type action, SRV_INFO_CTR *
}
default:
{
- fprintf(out_hnd, "Server Information: Unknown Info Level\n");
+ report(out_hnd, "Server Information: Unknown Info Level\n");
break;
}
}
@@ -303,19 +303,19 @@ void display_conn_info_0(FILE *out_hnd, enum action_type action,
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "Connection Info Level 0:\n");
+ report(out_hnd, "Connection Info Level 0:\n");
break;
}
case ACTION_ENUMERATE:
{
- fprintf(out_hnd, "\tid:\t%d\n", info0->id);
+ report(out_hnd, "\tid:\t%d\n", info0->id);
break;
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -337,7 +337,7 @@ void display_conn_info_1(FILE *out_hnd, enum action_type action,
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "Connection Info Level 1:\n");
+ report(out_hnd, "Connection Info Level 1:\n");
break;
}
@@ -349,20 +349,20 @@ void display_conn_info_1(FILE *out_hnd, enum action_type action,
unistr2_to_ascii(usr_name, &str1->uni_usr_name, sizeof(usr_name)-1);
unistr2_to_ascii(net_name, &str1->uni_net_name, sizeof(net_name)-1);
- fprintf(out_hnd, "\tid :\t%d\n", info1->id);
- fprintf(out_hnd, "\ttype :\t%s\n", get_share_type_str(info1->type));
- fprintf(out_hnd, "\tnum_opens:\t%d\n", info1->num_opens);
- fprintf(out_hnd, "\tnum_users:\t%d\n", info1->num_users);
- fprintf(out_hnd, "\topen_time:\t%d\n", info1->open_time);
+ report(out_hnd, "\tid :\t%d\n", info1->id);
+ report(out_hnd, "\ttype :\t%s\n", get_share_type_str(info1->type));
+ report(out_hnd, "\tnum_opens:\t%d\n", info1->num_opens);
+ report(out_hnd, "\tnum_users:\t%d\n", info1->num_users);
+ report(out_hnd, "\topen_time:\t%d\n", info1->open_time);
- fprintf(out_hnd, "\tuser name:\t%s\n", usr_name);
- fprintf(out_hnd, "\tnet name:\t%s\n", net_name);
+ report(out_hnd, "\tuser name:\t%s\n", usr_name);
+ report(out_hnd, "\tnet name:\t%s\n", net_name);
break;
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -377,7 +377,7 @@ void display_srv_conn_info_0_ctr(FILE *out_hnd, enum action_type action,
{
if (ctr == NULL)
{
- fprintf(out_hnd, "display_srv_conn_info_0_ctr: unavailable due to an internal error\n");
+ report(out_hnd, "display_srv_conn_info_0_ctr: unavailable due to an internal error\n");
return;
}
@@ -414,7 +414,7 @@ void display_srv_conn_info_1_ctr(FILE *out_hnd, enum action_type action,
{
if (ctr == NULL)
{
- fprintf(out_hnd, "display_srv_conn_info_1_ctr: unavailable due to an internal error\n");
+ report(out_hnd, "display_srv_conn_info_1_ctr: unavailable due to an internal error\n");
return;
}
@@ -451,7 +451,7 @@ void display_srv_conn_info_ctr(FILE *out_hnd, enum action_type action,
{
if (ctr == NULL || ctr->ptr_conn_ctr == 0)
{
- fprintf(out_hnd, "display_srv_conn_info_ctr: unavailable due to an internal error\n");
+ report(out_hnd, "display_srv_conn_info_ctr: unavailable due to an internal error\n");
return;
}
@@ -471,7 +471,7 @@ void display_srv_conn_info_ctr(FILE *out_hnd, enum action_type action,
}
default:
{
- fprintf(out_hnd, "display_srv_conn_info_ctr: Unknown Info Level\n");
+ report(out_hnd, "display_srv_conn_info_ctr: Unknown Info Level\n");
break;
}
}
@@ -493,7 +493,7 @@ void display_tprt_info_0(FILE *out_hnd, enum action_type action,
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "Transport Info Level 0:\n");
+ report(out_hnd, "Transport Info Level 0:\n");
break;
}
@@ -507,16 +507,16 @@ void display_tprt_info_0(FILE *out_hnd, enum action_type action,
buffer4_to_str(trans_addr, &str0->buf_trans_addr, sizeof(trans_addr)-1);
unistr2_to_ascii(addr_name, &str0->uni_addr_name, sizeof(addr_name)-1);
- fprintf(out_hnd, "\tnum_vcs :\t%d\n", info0->num_vcs);
- fprintf(out_hnd, "\ttransport name:\t%s\n", trans_name);
- fprintf(out_hnd, "\ttransport addr:\t%s\n", trans_addr);
- fprintf(out_hnd, "\taddress name:\t%s\n", addr_name);
+ report(out_hnd, "\tnum_vcs :\t%d\n", info0->num_vcs);
+ report(out_hnd, "\ttransport name:\t%s\n", trans_name);
+ report(out_hnd, "\ttransport addr:\t%s\n", trans_addr);
+ report(out_hnd, "\taddress name:\t%s\n", addr_name);
break;
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -531,7 +531,7 @@ void display_srv_tprt_info_0_ctr(FILE *out_hnd, enum action_type action,
{
if (ctr == NULL)
{
- fprintf(out_hnd, "display_srv_tprt_info_0_ctr: unavailable due to an internal error\n");
+ report(out_hnd, "display_srv_tprt_info_0_ctr: unavailable due to an internal error\n");
return;
}
@@ -568,7 +568,7 @@ void display_srv_tprt_info_ctr(FILE *out_hnd, enum action_type action,
{
if (ctr == NULL || ctr->ptr_tprt_ctr == 0)
{
- fprintf(out_hnd, "display_srv_tprt_info_ctr: unavailable due to an internal error\n");
+ report(out_hnd, "display_srv_tprt_info_ctr: unavailable due to an internal error\n");
return;
}
@@ -582,7 +582,7 @@ void display_srv_tprt_info_ctr(FILE *out_hnd, enum action_type action,
}
default:
{
- fprintf(out_hnd, "display_srv_tprt_info_ctr: Unknown Info Level\n");
+ report(out_hnd, "display_srv_tprt_info_ctr: Unknown Info Level\n");
break;
}
}
@@ -604,7 +604,7 @@ void display_share_info_1(FILE *out_hnd, enum action_type action,
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "Share Info Level 1:\n");
+ report(out_hnd, "Share Info Level 1:\n");
break;
}
@@ -622,7 +622,7 @@ void display_share_info_1(FILE *out_hnd, enum action_type action,
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -644,7 +644,7 @@ void display_share_info_2(FILE *out_hnd, enum action_type action,
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "Share Info Level 2:\n");
+ report(out_hnd, "Share Info Level 2:\n");
break;
}
@@ -668,7 +668,7 @@ void display_share_info_2(FILE *out_hnd, enum action_type action,
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -683,7 +683,7 @@ void display_srv_share_info_1_ctr(FILE *out_hnd, enum action_type action,
{
if (ctr == NULL)
{
- fprintf(out_hnd, "display_srv_share_info_1_ctr: unavailable due to an internal error\n");
+ report(out_hnd, "display_srv_share_info_1_ctr: unavailable due to an internal error\n");
return;
}
@@ -720,7 +720,7 @@ void display_srv_share_info_2_ctr(FILE *out_hnd, enum action_type action,
{
if (ctr == NULL)
{
- fprintf(out_hnd, "display_srv_share_info_2_ctr: unavailable due to an internal error\n");
+ report(out_hnd, "display_srv_share_info_2_ctr: unavailable due to an internal error\n");
return;
}
@@ -757,7 +757,7 @@ void display_srv_share_info_ctr(FILE *out_hnd, enum action_type action,
{
if (ctr == NULL || ctr->ptr_share_ctr == 0)
{
- fprintf(out_hnd, "display_srv_share_info_ctr: unavailable due to an internal error\n");
+ report(out_hnd, "display_srv_share_info_ctr: unavailable due to an internal error\n");
return;
}
@@ -777,7 +777,7 @@ void display_srv_share_info_ctr(FILE *out_hnd, enum action_type action,
}
default:
{
- fprintf(out_hnd, "display_srv_share_info_ctr: Unknown Info Level\n");
+ report(out_hnd, "display_srv_share_info_ctr: Unknown Info Level\n");
break;
}
}
@@ -799,7 +799,7 @@ void display_file_info_3(FILE *out_hnd, enum action_type action,
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "File Info Level 3:\n");
+ report(out_hnd, "File Info Level 3:\n");
break;
}
@@ -813,18 +813,18 @@ void display_file_info_3(FILE *out_hnd, enum action_type action,
unistr2_to_ascii(user_name, &str3->uni_user_name,
sizeof(user_name)-1);
- fprintf(out_hnd, "\tid :\t%d\n", info3->id);
- fprintf(out_hnd, "\tperms :\t%s\n", get_file_mode_str(info3->perms));
- fprintf(out_hnd, "\tnum_locks:\t%d\n", info3->num_locks);
+ report(out_hnd, "\tid :\t%d\n", info3->id);
+ report(out_hnd, "\tperms :\t%s\n", get_file_mode_str(info3->perms));
+ report(out_hnd, "\tnum_locks:\t%d\n", info3->num_locks);
- fprintf(out_hnd, "\tpath name:\t%s\n", path_name);
- fprintf(out_hnd, "\tuser name:\t%s\n", user_name);
+ report(out_hnd, "\tpath name:\t%s\n", path_name);
+ report(out_hnd, "\tuser name:\t%s\n", user_name);
break;
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -839,7 +839,7 @@ void display_srv_file_info_3_ctr(FILE *out_hnd, enum action_type action,
{
if (ctr == NULL)
{
- fprintf(out_hnd, "display_srv_file_info_3_ctr: unavailable due to an internal error\n");
+ report(out_hnd, "display_srv_file_info_3_ctr: unavailable due to an internal error\n");
return;
}
@@ -876,7 +876,7 @@ void display_srv_file_info_ctr(FILE *out_hnd, enum action_type action,
{
if (ctr == NULL || ctr->ptr_file_ctr == 0)
{
- fprintf(out_hnd, "display_srv_file_info_ctr: unavailable due to an internal error\n");
+ report(out_hnd, "display_srv_file_info_ctr: unavailable due to an internal error\n");
return;
}
@@ -890,7 +890,7 @@ void display_srv_file_info_ctr(FILE *out_hnd, enum action_type action,
}
default:
{
- fprintf(out_hnd, "display_srv_file_info_ctr: Unknown Info Level\n");
+ report(out_hnd, "display_srv_file_info_ctr: Unknown Info Level\n");
break;
}
}
@@ -911,7 +911,7 @@ void display_sess_info_0(FILE *out_hnd, enum action_type action,
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "Session Info Level 0:\n");
+ report(out_hnd, "Session Info Level 0:\n");
break;
}
@@ -922,13 +922,13 @@ void display_sess_info_0(FILE *out_hnd, enum action_type action,
unistr2_to_ascii(name, &str0->uni_name,
sizeof(name)-1);
- fprintf(out_hnd, "\tname:\t%s\n", name);
+ report(out_hnd, "\tname:\t%s\n", name);
break;
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -950,7 +950,7 @@ void display_sess_info_1(FILE *out_hnd, enum action_type action,
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "Session Info Level 1:\n");
+ report(out_hnd, "Session Info Level 1:\n");
break;
}
@@ -964,20 +964,20 @@ void display_sess_info_1(FILE *out_hnd, enum action_type action,
unistr2_to_ascii(name, &str1->uni_name,
sizeof(name)-1);
- fprintf(out_hnd, "\tname:\t%s\n", name);
+ report(out_hnd, "\tname:\t%s\n", name);
- fprintf(out_hnd, "\topen :\t%d\n", info1->num_opens);
- fprintf(out_hnd, "\ttime :\t%d\n", info1->open_time);
- fprintf(out_hnd, "\tidle :\t%d\n", info1->idle_time);
- fprintf(out_hnd, "\tflags:\t%d\n", info1->user_flags);
+ report(out_hnd, "\topen :\t%d\n", info1->num_opens);
+ report(out_hnd, "\ttime :\t%d\n", info1->open_time);
+ report(out_hnd, "\tidle :\t%d\n", info1->idle_time);
+ report(out_hnd, "\tflags:\t%d\n", info1->user_flags);
- fprintf(out_hnd, "\tuser :\t%s\n", user_name);
+ report(out_hnd, "\tuser :\t%s\n", user_name);
break;
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -992,7 +992,7 @@ void display_srv_sess_info_0_ctr(FILE *out_hnd, enum action_type action,
{
if (ctr == NULL)
{
- fprintf(out_hnd, "display_srv_sess_info_0_ctr: unavailable due to an internal error\n");
+ report(out_hnd, "display_srv_sess_info_0_ctr: unavailable due to an internal error\n");
return;
}
@@ -1029,7 +1029,7 @@ void display_srv_sess_info_1_ctr(FILE *out_hnd, enum action_type action,
{
if (ctr == NULL)
{
- fprintf(out_hnd, "display_srv_sess_info_1_ctr: unavailable due to an internal error\n");
+ report(out_hnd, "display_srv_sess_info_1_ctr: unavailable due to an internal error\n");
return;
}
@@ -1066,7 +1066,7 @@ void display_srv_sess_info_ctr(FILE *out_hnd, enum action_type action,
{
if (ctr == NULL || ctr->ptr_sess_ctr == 0)
{
- fprintf(out_hnd, "display_srv_sess_info_ctr: unavailable due to an internal error\n");
+ report(out_hnd, "display_srv_sess_info_ctr: unavailable due to an internal error\n");
return;
}
@@ -1086,7 +1086,7 @@ void display_srv_sess_info_ctr(FILE *out_hnd, enum action_type action,
}
default:
{
- fprintf(out_hnd, "display_srv_sess_info_ctr: Unknown Info Level\n");
+ report(out_hnd, "display_srv_sess_info_ctr: Unknown Info Level\n");
break;
}
}
@@ -1106,7 +1106,7 @@ void display_server(FILE *out_hnd, enum action_type action,
}
case ACTION_ENUMERATE:
{
- fprintf(out_hnd, "\t%-15.15s%-20s %s\n",
+ report(out_hnd, "\t%-15.15s%-20s %s\n",
sname, get_server_type_str(type), comment);
break;
}
@@ -1131,7 +1131,7 @@ void display_share(FILE *out_hnd, enum action_type action,
}
case ACTION_ENUMERATE:
{
- fprintf(out_hnd, "\t%-15.15s%-10.10s%s\n",
+ report(out_hnd, "\t%-15.15s%-10.10s%s\n",
sname, get_share_type_str(type), comment);
break;
}
@@ -1159,7 +1159,7 @@ void display_share2(FILE *out_hnd, enum action_type action,
}
case ACTION_ENUMERATE:
{
- fprintf(out_hnd, "\t%-15.15s%-10.10s%s %x %x %x %s %s\n",
+ report(out_hnd, "\t%-15.15s%-10.10s%s %x %x %x %s %s\n",
sname, get_share_type_str(type), comment,
perms, max_uses, num_uses, path, passwd);
break;
@@ -1186,7 +1186,7 @@ void display_name(FILE *out_hnd, enum action_type action,
}
case ACTION_ENUMERATE:
{
- fprintf(out_hnd, "\t%-21.21s\n", sname);
+ report(out_hnd, "\t%-21.21s\n", sname);
break;
}
case ACTION_FOOTER:
@@ -1210,12 +1210,12 @@ void display_alias_members(FILE *out_hnd, enum action_type action,
{
if (num_mem == 0)
{
- fprintf(out_hnd, "\tNo Alias Members\n");
+ report(out_hnd, "\tNo Alias Members\n");
}
else
{
- fprintf(out_hnd, "\tAlias Members:\n");
- fprintf(out_hnd, "\t-------------\n");
+ report(out_hnd, "\tAlias Members:\n");
+ report(out_hnd, "\t-------------\n");
}
break;
}
@@ -1227,7 +1227,7 @@ void display_alias_members(FILE *out_hnd, enum action_type action,
{
if (sid_mem[i] != NULL)
{
- fprintf(out_hnd, "\tMember Name:\t%s\tType:\t%s\n",
+ report(out_hnd, "\tMember Name:\t%s\tType:\t%s\n",
sid_mem[i],
get_sid_name_use_str(type[i]));
}
@@ -1237,7 +1237,7 @@ void display_alias_members(FILE *out_hnd, enum action_type action,
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -1259,12 +1259,12 @@ void display_alias_rid_info(FILE *out_hnd, enum action_type action,
sid_to_string(sid_str, sid);
if (num_rids == 0)
{
- fprintf(out_hnd, "\tNo Aliases:\tSid %s\n", sid_str);
+ report(out_hnd, "\tNo Aliases:\tSid %s\n", sid_str);
}
else
{
- fprintf(out_hnd, "\tAlias Info:\tSid %s\n", sid_str);
- fprintf(out_hnd, "\t----------\n");
+ report(out_hnd, "\tAlias Info:\tSid %s\n", sid_str);
+ report(out_hnd, "\t----------\n");
}
break;
}
@@ -1274,14 +1274,14 @@ void display_alias_rid_info(FILE *out_hnd, enum action_type action,
for (i = 0; i < num_rids; i++)
{
- fprintf(out_hnd, "\tAlias RID:\t%8x\n", rid[i]);
+ report(out_hnd, "\tAlias RID:\t%8x\n", rid[i]);
}
break;
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -1299,12 +1299,12 @@ void display_group_members(FILE *out_hnd, enum action_type action,
{
if (num_mem == 0)
{
- fprintf(out_hnd, "\tNo Members\n");
+ report(out_hnd, "\tNo Members\n");
}
else
{
- fprintf(out_hnd, "\tMembers:\n");
- fprintf(out_hnd, "\t-------\n");
+ report(out_hnd, "\tMembers:\n");
+ report(out_hnd, "\t-------\n");
}
break;
}
@@ -1314,7 +1314,7 @@ void display_group_members(FILE *out_hnd, enum action_type action,
for (i = 0; i < num_mem; i++)
{
- fprintf(out_hnd, "\tMember Name:\t%s\tType:\t%s\n",
+ report(out_hnd, "\tMember Name:\t%s\tType:\t%s\n",
name[i], get_sid_name_use_str(type[i]));
}
@@ -1322,7 +1322,7 @@ void display_group_members(FILE *out_hnd, enum action_type action,
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -1346,11 +1346,11 @@ void display_group_info1(FILE *out_hnd, enum action_type action, GROUP_INFO1 *co
fstring temp;
unistr2_to_ascii(temp, &info1->uni_acct_name, sizeof(temp)-1);
- fprintf(out_hnd, "\tGroup Name:\t%s\n", temp);
+ report(out_hnd, "\tGroup Name:\t%s\n", temp);
unistr2_to_ascii(temp, &info1->uni_acct_desc, sizeof(temp)-1);
- fprintf(out_hnd, "\tDescription:\t%s\n", temp);
- fprintf(out_hnd, "\tunk1:%d\n", info1->unknown_1);
- fprintf(out_hnd, "\tNum Members:%d\n", info1->num_members);
+ report(out_hnd, "\tDescription:\t%s\n", temp);
+ report(out_hnd, "\tunk1:%d\n", info1->unknown_1);
+ report(out_hnd, "\tNum Members:%d\n", info1->num_members);
break;
}
case ACTION_FOOTER:
@@ -1377,7 +1377,7 @@ void display_group_info4(FILE *out_hnd, enum action_type action, GROUP_INFO4 *co
fstring desc;
unistr2_to_ascii(desc, &info4->uni_acct_desc, sizeof(desc)-1);
- fprintf(out_hnd, "\tGroup Description:%s\n",
+ report(out_hnd, "\tGroup Description:%s\n",
desc);
break;
}
@@ -1398,8 +1398,8 @@ void display_group_info_ctr(FILE *out_hnd, enum action_type action,
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "\tSAM Group Info\n");
- fprintf(out_hnd, "\t--------------\n");
+ report(out_hnd, "\tSAM Group Info\n");
+ report(out_hnd, "\t--------------\n");
break;
}
@@ -1426,7 +1426,7 @@ void display_group_info_ctr(FILE *out_hnd, enum action_type action,
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -1444,12 +1444,12 @@ void display_group_rid_info(FILE *out_hnd, enum action_type action,
{
if (num_gids == 0)
{
- fprintf(out_hnd, "\tNo Groups\n");
+ report(out_hnd, "\tNo Groups\n");
}
else
{
- fprintf(out_hnd, "\tGroup Info\n");
- fprintf(out_hnd, "\t----------\n");
+ report(out_hnd, "\tGroup Info\n");
+ report(out_hnd, "\t----------\n");
}
break;
}
@@ -1459,7 +1459,7 @@ void display_group_rid_info(FILE *out_hnd, enum action_type action,
for (i = 0; i < num_gids; i++)
{
- fprintf(out_hnd, "\tGroup RID:\t%8x attr:\t%x\n",
+ report(out_hnd, "\tGroup RID:\t%8x attr:\t%x\n",
gid[i].g_rid, gid[i].attr);
}
@@ -1467,7 +1467,7 @@ void display_group_rid_info(FILE *out_hnd, enum action_type action,
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -1486,12 +1486,12 @@ void display_alias_name_info(FILE *out_hnd, enum action_type action,
{
if (num_aliases == 0)
{
- fprintf(out_hnd, "\tNo Aliases\n");
+ report(out_hnd, "\tNo Aliases\n");
}
else
{
- fprintf(out_hnd, "\tAlias Names\n");
- fprintf(out_hnd, "\t----------- \n");
+ report(out_hnd, "\tAlias Names\n");
+ report(out_hnd, "\t----------- \n");
}
break;
}
@@ -1501,7 +1501,7 @@ void display_alias_name_info(FILE *out_hnd, enum action_type action,
for (i = 0; i < num_aliases; i++)
{
- fprintf(out_hnd, "\tAlias Name:\t%s Attributes:\t%3d\n",
+ report(out_hnd, "\tAlias Name:\t%s Attributes:\t%3d\n",
alias_name[i], num_als_usrs[i]);
}
@@ -1509,7 +1509,7 @@ void display_alias_name_info(FILE *out_hnd, enum action_type action,
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -1532,7 +1532,7 @@ void display_alias_info3(FILE *out_hnd, enum action_type action, ALIAS_INFO3 *co
fstring temp;
unistr2_to_ascii(temp, &info3->uni_acct_desc, sizeof(temp)-1);
- fprintf(out_hnd, "\tDescription:\t%s\n", temp);
+ report(out_hnd, "\tDescription:\t%s\n", temp);
break;
}
case ACTION_FOOTER:
@@ -1552,8 +1552,8 @@ void display_alias_info_ctr(FILE *out_hnd, enum action_type action,
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "\tSAM Group Info\n");
- fprintf(out_hnd, "\t--------------\n");
+ report(out_hnd, "\tSAM Group Info\n");
+ report(out_hnd, "\t--------------\n");
break;
}
@@ -1573,7 +1573,7 @@ void display_alias_info_ctr(FILE *out_hnd, enum action_type action,
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -1589,8 +1589,8 @@ void display_sam_user_info_21(FILE *out_hnd, enum action_type action, SAM_USER_I
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "\tUser Info, Level 0x15\n");
- fprintf(out_hnd, "\t---------------------\n");
+ report(out_hnd, "\tUser Info, Level 0x15\n");
+ report(out_hnd, "\t---------------------\n");
break;
}
@@ -1599,64 +1599,64 @@ void display_sam_user_info_21(FILE *out_hnd, enum action_type action, SAM_USER_I
fstring temp;
unistr2_to_ascii(temp, &usr->uni_user_name, sizeof(temp)-1);
- fprintf(out_hnd, "\t\tUser Name :\t%s\n", temp);
+ report(out_hnd, "\t\tUser Name :\t%s\n", temp);
unistr2_to_ascii(temp, &usr->uni_full_name, sizeof(temp)-1);
- fprintf(out_hnd, "\t\tFull Name :\t%s\n", temp);
+ report(out_hnd, "\t\tFull Name :\t%s\n", temp);
unistr2_to_ascii(temp, &usr->uni_home_dir, sizeof(temp)-1);
- fprintf(out_hnd, "\t\tHome Drive :\t%s\n", temp);
+ report(out_hnd, "\t\tHome Drive :\t%s\n", temp);
unistr2_to_ascii(temp, &usr->uni_dir_drive, sizeof(temp)-1);
- fprintf(out_hnd, "\t\tDir Drive :\t%s\n", temp);
+ report(out_hnd, "\t\tDir Drive :\t%s\n", temp);
unistr2_to_ascii(temp, &usr->uni_profile_path, sizeof(temp)-1);
- fprintf(out_hnd, "\t\tProfile Path:\t%s\n", temp);
+ report(out_hnd, "\t\tProfile Path:\t%s\n", temp);
unistr2_to_ascii(temp, &usr->uni_logon_script, sizeof(temp)-1);
- fprintf(out_hnd, "\t\tLogon Script:\t%s\n", temp);
+ report(out_hnd, "\t\tLogon Script:\t%s\n", temp);
unistr2_to_ascii(temp, &usr->uni_acct_desc, sizeof(temp)-1);
- fprintf(out_hnd, "\t\tDescription :\t%s\n", temp);
+ report(out_hnd, "\t\tDescription :\t%s\n", temp);
unistr2_to_ascii(temp, &usr->uni_workstations, sizeof(temp)-1);
- fprintf(out_hnd, "\t\tWorkstations:\t%s\n", temp);
+ report(out_hnd, "\t\tWorkstations:\t%s\n", temp);
unistr2_to_ascii(temp, &usr->uni_unknown_str, sizeof(temp)-1);
- fprintf(out_hnd, "\t\tUnknown Str :\t%s\n", temp);
+ report(out_hnd, "\t\tUnknown Str :\t%s\n", temp);
unistr2_to_ascii(temp, &usr->uni_munged_dial, sizeof(temp)-1);
- fprintf(out_hnd, "\t\tRemote Dial :\t%s\n", temp);
-
- fprintf(out_hnd, "\t\tLogon Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->logon_time ))));
- fprintf(out_hnd, "\t\tLogoff Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->logoff_time ))));
- fprintf(out_hnd, "\t\tKickoff Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->kickoff_time ))));
- fprintf(out_hnd, "\t\tPassword last set Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->pass_last_set_time ))));
- fprintf(out_hnd, "\t\tPassword can change Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->pass_can_change_time ))));
- fprintf(out_hnd, "\t\tPassword must change Time:\t%s\n", http_timestring(nt_time_to_unix(&(usr->pass_must_change_time))));
+ report(out_hnd, "\t\tRemote Dial :\t%s\n", temp);
+
+ report(out_hnd, "\t\tLogon Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->logon_time ))));
+ report(out_hnd, "\t\tLogoff Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->logoff_time ))));
+ report(out_hnd, "\t\tKickoff Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->kickoff_time ))));
+ report(out_hnd, "\t\tPassword last set Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->pass_last_set_time ))));
+ report(out_hnd, "\t\tPassword can change Time :\t%s\n", http_timestring(nt_time_to_unix(&(usr->pass_can_change_time ))));
+ report(out_hnd, "\t\tPassword must change Time:\t%s\n", http_timestring(nt_time_to_unix(&(usr->pass_must_change_time))));
- fprintf(out_hnd, "\t\tunknown_2[0..31]...\n"); /* user passwords? */
+ report(out_hnd, "\t\tunknown_2[0..31]...\n"); /* user passwords? */
- fprintf(out_hnd, "\t\tuser_rid :\t%x\n" , usr->user_rid ); /* User ID */
- fprintf(out_hnd, "\t\tgroup_rid:\t%x\n" , usr->group_rid); /* Group ID */
- fprintf(out_hnd, "\t\tacb_info :\t%04x\n", usr->acb_info ); /* Account Control Info */
+ report(out_hnd, "\t\tuser_rid :\t%x\n" , usr->user_rid ); /* User ID */
+ report(out_hnd, "\t\tgroup_rid:\t%x\n" , usr->group_rid); /* Group ID */
+ report(out_hnd, "\t\tacb_info :\t%04x\n", usr->acb_info ); /* Account Control Info */
- fprintf(out_hnd, "\t\tunknown_3:\t%08x\n", usr->unknown_3); /* 0x00ff ffff */
- fprintf(out_hnd, "\t\tlogon_divs:\t%d\n", usr->logon_divs); /* 0x0000 00a8 which is 168 which is num hrs in a week */
- fprintf(out_hnd, "\t\tunknown_5:\t%08x\n", usr->unknown_5); /* 0x0002 0000 */
+ report(out_hnd, "\t\tunknown_3:\t%08x\n", usr->unknown_3); /* 0x00ff ffff */
+ report(out_hnd, "\t\tlogon_divs:\t%d\n", usr->logon_divs); /* 0x0000 00a8 which is 168 which is num hrs in a week */
+ report(out_hnd, "\t\tunknown_5:\t%08x\n", usr->unknown_5); /* 0x0002 0000 */
- fprintf(out_hnd, "\t\tpadding1[0..7]...\n");
+ report(out_hnd, "\t\tpadding1[0..7]...\n");
if (usr->ptr_logon_hrs)
{
- fprintf(out_hnd, "\t\tlogon_hrs[0..%d]...\n", usr->logon_hrs.len);
+ report(out_hnd, "\t\tlogon_hrs[0..%d]...\n", usr->logon_hrs.len);
}
break;
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -1740,7 +1740,7 @@ void display_sec_access(FILE *out_hnd, enum action_type action, SEC_ACCESS *cons
}
case ACTION_ENUMERATE:
{
- fprintf(out_hnd, "\t\tPermissions:\t%s\n",
+ report(out_hnd, "\t\tPermissions:\t%s\n",
get_sec_mask_str(info->mask));
}
case ACTION_FOOTER:
@@ -1759,7 +1759,7 @@ void display_sec_ace(FILE *out_hnd, enum action_type action, SEC_ACE *const ace)
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "\tACE\n");
+ report(out_hnd, "\tACE\n");
break;
}
case ACTION_ENUMERATE:
@@ -1771,7 +1771,7 @@ void display_sec_ace(FILE *out_hnd, enum action_type action, SEC_ACE *const ace)
display_sec_access(out_hnd, ACTION_FOOTER , &ace->info);
sid_to_string(sid_str, &ace->sid);
- fprintf(out_hnd, "\t\tSID:\t%s\n", sid_str);
+ report(out_hnd, "\t\tSID:\t%s\n", sid_str);
}
case ACTION_FOOTER:
{
@@ -1789,9 +1789,9 @@ void display_sec_acl(FILE *out_hnd, enum action_type action, SEC_ACL *const sec_
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "\tACL\tNum ACEs:\t%d\trevision:\t%x\n",
+ report(out_hnd, "\tACL\tNum ACEs:\t%d\trevision:\t%x\n",
sec_acl->num_aces, sec_acl->revision);
- fprintf(out_hnd, "\t---\n");
+ report(out_hnd, "\t---\n");
break;
}
@@ -1812,7 +1812,7 @@ void display_sec_acl(FILE *out_hnd, enum action_type action, SEC_ACL *const sec_
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -1827,9 +1827,9 @@ void display_sec_desc(FILE *out_hnd, enum action_type action, SEC_DESC *const se
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "\tSecurity Descriptor\trevision:\t%x\ttype:\t%x\n",
+ report(out_hnd, "\tSecurity Descriptor\trevision:\t%x\ttype:\t%x\n",
sec->revision, sec->type);
- fprintf(out_hnd, "\t-------------------\n");
+ report(out_hnd, "\t-------------------\n");
break;
}
@@ -1852,19 +1852,19 @@ void display_sec_desc(FILE *out_hnd, enum action_type action, SEC_DESC *const se
if (sec->off_owner_sid != 0)
{
sid_to_string(sid_str, sec->owner_sid);
- fprintf(out_hnd, "\tOwner SID:\t%s\n", sid_str);
+ report(out_hnd, "\tOwner SID:\t%s\n", sid_str);
}
if (sec->off_grp_sid != 0)
{
sid_to_string(sid_str, sec->grp_sid);
- fprintf(out_hnd, "\tParent SID:\t%s\n", sid_str);
+ report(out_hnd, "\tParent SID:\t%s\n", sid_str);
}
break;
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -1926,7 +1926,7 @@ static void print_reg_value(FILE *out_hnd, const char *val_name,
{
unibuf_to_ascii(valstr, value->buffer,
MIN(value->buf_len, sizeof(valstr)-1));
- fprintf(out_hnd, "\t%s:\t%s:\t%s\n", val_name, type, valstr);
+ report(out_hnd, "\t%s:\t%s:\t%s\n", val_name, type, valstr);
break;
}
@@ -1935,13 +1935,13 @@ static void print_reg_value(FILE *out_hnd, const char *val_name,
{
if (value->buf_len <= 8)
{
- fprintf(out_hnd, "\t%s:\t%s:\t", val_name, type);
+ report(out_hnd, "\t%s:\t%s:\t", val_name, type);
out_data(out_hnd, (const char*)value->buffer,
value->buf_len, 8);
}
else
{
- fprintf(out_hnd, "\t%s:\t%s:\n", val_name, type);
+ report(out_hnd, "\t%s:\t%s:\n", val_name, type);
out_data(out_hnd, (const char*)value->buffer,
value->buf_len, 16);
}
@@ -1950,14 +1950,14 @@ static void print_reg_value(FILE *out_hnd, const char *val_name,
case 0x04: /* uint32 */
{
- fprintf(out_hnd, "\t%s:\t%s:\t0x%08x\n", val_name, type, buffer2_to_uint32(value));
+ report(out_hnd, "\t%s:\t%s:\t0x%08x\n", val_name, type, buffer2_to_uint32(value));
break;
}
case 0x07: /* multiunistr */
{
buffer2_to_multistr(valstr, value, sizeof(valstr)-1);
- fprintf(out_hnd, "\t%s:\t%s:\t%s\n", val_name, type, valstr);
+ report(out_hnd, "\t%s:\t%s:\t%s\n", val_name, type, valstr);
break;
}
}
@@ -2002,7 +2002,7 @@ void display_reg_key_info(FILE *out_hnd, enum action_type action,
}
case ACTION_ENUMERATE:
{
- fprintf(out_hnd, "\t%s\t(%s)\n",
+ report(out_hnd, "\t%s\t(%s)\n",
key_name, http_timestring(key_mod_time));
break;
}
@@ -2047,8 +2047,8 @@ void display_query_svc_cfg(FILE *out_hnd, enum action_type action,
fstring service;
unistr2_to_ascii(service, &cfg->uni_display_name, sizeof(service)-1);
- fprintf(out_hnd, "\tService:\t%s\n", service);
- fprintf(out_hnd, "\t-------\n");
+ report(out_hnd, "\tService:\t%s\n", service);
+ report(out_hnd, "\t-------\n");
break;
}
case ACTION_ENUMERATE:
@@ -2056,27 +2056,27 @@ void display_query_svc_cfg(FILE *out_hnd, enum action_type action,
fstring temp;
unistr2_to_ascii(temp, &cfg->uni_bin_path_name, sizeof(temp)-1);
- fprintf(out_hnd, "\tPath:\t%s\n", temp);
+ report(out_hnd, "\tPath:\t%s\n", temp);
unistr2_to_ascii(temp, &cfg->uni_load_order_grp, sizeof(temp)-1);
- fprintf(out_hnd, "\tLoad Order:\t%s\n", temp);
+ report(out_hnd, "\tLoad Order:\t%s\n", temp);
unistr2_to_ascii(temp, &cfg->uni_dependencies, sizeof(temp)-1);
- fprintf(out_hnd, "\tDependencies:\t%s\n", temp);
+ report(out_hnd, "\tDependencies:\t%s\n", temp);
unistr2_to_ascii(temp, &cfg->uni_service_start_name, sizeof(temp)-1);
- fprintf(out_hnd, "\tService Start:\t%s\n", temp);
+ report(out_hnd, "\tService Start:\t%s\n", temp);
- fprintf(out_hnd, "\tService Type:\t%d\n", cfg->service_type);
- fprintf(out_hnd, "\tStart Type:\t%s\n" , get_svc_start_type_str(cfg->start_type));
- fprintf(out_hnd, "\tError Control:\t%d\n" , cfg->error_control);
- fprintf(out_hnd, "\tTag Id:\t%d\n" , cfg->tag_id);
+ report(out_hnd, "\tService Type:\t%d\n", cfg->service_type);
+ report(out_hnd, "\tStart Type:\t%s\n" , get_svc_start_type_str(cfg->start_type));
+ report(out_hnd, "\tError Control:\t%d\n" , cfg->error_control);
+ report(out_hnd, "\tTag Id:\t%d\n" , cfg->tag_id);
break;
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -2100,11 +2100,11 @@ void display_svc_info(FILE *out_hnd, enum action_type action,
unistr_to_ascii(name, svc->uni_srvc_name.buffer,
sizeof(name)-1); /* service name */
- fprintf(out_hnd, "\t%s:", name);
+ report(out_hnd, "\t%s:", name);
unistr_to_ascii(name, svc->uni_disp_name.buffer,
sizeof(name)-1); /* display name */
- fprintf(out_hnd, "\t%s\n", name);
+ report(out_hnd, "\t%s\n", name);
break;
}
case ACTION_FOOTER:
@@ -2189,7 +2189,8 @@ static char *get_at_days_str(uint32 monthdays, uint8 weekdays, uint8 flags)
display scheduled jobs
****************************************************************************/
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)
{
switch (action)
{
@@ -2197,12 +2198,12 @@ void display_at_enum_info(FILE *out_hnd, enum action_type action,
{
if (num_jobs == 0)
{
- fprintf(out_hnd, "\tNo Jobs.\n");
+ report(out_hnd, "\tNo Jobs.\n");
}
else
{
- fprintf(out_hnd, "\tJobs:\n");
- fprintf(out_hnd, "\t-----\n");
+ report(out_hnd, "\tJobs:\n");
+ report(out_hnd, "\t-----\n");
}
break;
}
@@ -2214,7 +2215,7 @@ void display_at_enum_info(FILE *out_hnd, enum action_type action,
{
const AT_JOB_INFO *const job = &jobs[i].info;
- fprintf(out_hnd, "\t%d\t%s\t%s\t%s\n",
+ report(out_hnd, "\t%d\t%s\t%s\t%s\n",
jobs[i].jobid,
get_at_time_str(job->time),
get_at_days_str(job->monthdays,
@@ -2227,7 +2228,7 @@ void display_at_enum_info(FILE *out_hnd, enum action_type action,
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -2243,37 +2244,37 @@ void display_at_job_info(FILE *out_hnd, enum action_type action,
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "\tJob Information:\n");
- fprintf(out_hnd, "\t----------------\n");
+ report(out_hnd, "\tJob Information:\n");
+ report(out_hnd, "\t----------------\n");
break;
}
case ACTION_ENUMERATE:
{
- fprintf(out_hnd, "\tTime: %s\n",
+ report(out_hnd, "\tTime: %s\n",
get_at_time_str(job->time));
- fprintf(out_hnd, "\tSchedule: %s\n",
+ report(out_hnd, "\tSchedule: %s\n",
get_at_days_str(job->monthdays, job->weekdays,
job->flags));
- fprintf(out_hnd, "\tStatus: %s",
+ report(out_hnd, "\tStatus: %s",
(job->flags & JOB_EXEC_ERR) ? "Failed" : "OK");
if (job->flags & JOB_RUNS_TODAY)
{
- fprintf(out_hnd, ", Runs Today");
+ report(out_hnd, ", Runs Today");
}
- fprintf(out_hnd, "\n\tInteractive: %s\n",
+ report(out_hnd, "\n\tInteractive: %s\n",
(job->flags & JOB_NONINTERACTIVE) ? "No"
: "Yes");
- fprintf(out_hnd, "\tCommand: %s\n", command);
+ report(out_hnd, "\tCommand: %s\n", command);
break;
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -2288,68 +2289,68 @@ void display_eventlog_eventrecord(FILE *out_hnd, enum action_type action, EVENTL
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "\tevent log records\n");
- fprintf(out_hnd, "\t-----------------\n");
+ report(out_hnd, "\tevent log records\n");
+ report(out_hnd, "\t-----------------\n");
break;
}
case ACTION_ENUMERATE:
{
fstring temp;
- fprintf(out_hnd, "\t\trecord n.:\t%d\n", ev->recordnumber);
+ report(out_hnd, "\t\trecord n.:\t%d\n", ev->recordnumber);
- fprintf(out_hnd, "\t\tsource\teventnumber\teventtype\tcategory\n");
+ report(out_hnd, "\t\tsource\teventnumber\teventtype\tcategory\n");
unistr_to_ascii(temp, ev->sourcename.buffer, sizeof(temp)-1);
- fprintf(out_hnd, "\t\t%s", temp);
+ report(out_hnd, "\t\t%s", temp);
- fprintf(out_hnd, "\t%d\t\t", ev->eventnumber&0x0000FFFF);
+ report(out_hnd, "\t%d\t\t", ev->eventnumber&0x0000FFFF);
switch (ev->eventtype)
{
case EVENTLOG_OK:
- fprintf(out_hnd, "Normal");
+ report(out_hnd, "Normal");
break;
case EVENTLOG_ERROR:
- fprintf(out_hnd, "Error");
+ report(out_hnd, "Error");
break;
case EVENTLOG_WARNING:
- fprintf(out_hnd, "Warning");
+ report(out_hnd, "Warning");
break;
case EVENTLOG_INFORMATION:
- fprintf(out_hnd, "Information");
+ report(out_hnd, "Information");
break;
case EVENTLOG_AUDIT_OK:
- fprintf(out_hnd, "Audit Normal");
+ report(out_hnd, "Audit Normal");
break;
case EVENTLOG_AUDIT_ERROR:
- fprintf(out_hnd, "Audit Error\n");
+ report(out_hnd, "Audit Error\n");
break;
}
- fprintf(out_hnd, "\t%d\n", ev->category);
- fprintf(out_hnd, "\t\tcreationtime:\t%s\n", http_timestring(ev->creationtime));
- fprintf(out_hnd, "\t\twritetime:\t%s\n", http_timestring(ev->writetime));
+ report(out_hnd, "\t%d\n", ev->category);
+ report(out_hnd, "\t\tcreationtime:\t%s\n", http_timestring(ev->creationtime));
+ report(out_hnd, "\t\twritetime:\t%s\n", http_timestring(ev->writetime));
unistr_to_ascii(temp, ev->computername.buffer, sizeof(temp)-1);
- fprintf(out_hnd, "\t\tcomputer:\t%s\n", temp);
+ report(out_hnd, "\t\tcomputer:\t%s\n", temp);
if (ev->num_of_strings!=0)
{
unistr_to_ascii(temp, ev->strings.buffer, sizeof(temp)-1);
- fprintf(out_hnd, "\t\tdescription:\t%s\n", temp);
+ report(out_hnd, "\t\tdescription:\t%s\n", temp);
}
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -2377,13 +2378,13 @@ void display_sam_sync_ctr(FILE *out_hnd, enum action_type action,
case 1:
{
unistr2_to_ascii(name, &(ctr->domain_info.uni_dom_name), sizeof(name)-1);
- fprintf(out_hnd, "Domain: %s\n", name);
+ report(out_hnd, "Domain: %s\n", name);
break;
}
case 2:
{
unistr2_to_ascii(name, &(ctr->group_info.uni_grp_name), sizeof(name)-1);
- fprintf(out_hnd, "Group: %s\n", name);
+ report(out_hnd, "Group: %s\n", name);
break;
}
case 5:
@@ -2392,7 +2393,7 @@ void display_sam_sync_ctr(FILE *out_hnd, enum action_type action,
unsigned char nt_pwd[16];
unistr2_to_ascii(name, &(ctr->account_info.uni_acct_name), sizeof(name)-1);
- fprintf(out_hnd, "Account: %s\n", name);
+ report(out_hnd, "Account: %s\n", name);
sam_pwd_hash(ctr->account_info.user_rid, ctr->account_info.pass.buf_lm_pwd, lm_pwd, 0);
out_struct(out_hnd, lm_pwd, 16, 8);
@@ -2422,8 +2423,8 @@ void display_sam_sync(FILE *out_hnd, enum action_type action,
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "\tSAM Database Sync\n");
- fprintf(out_hnd, "\t-----------------\n");
+ report(out_hnd, "\tSAM Database Sync\n");
+ report(out_hnd, "\t-----------------\n");
break;
}
@@ -2440,7 +2441,7 @@ void display_sam_sync(FILE *out_hnd, enum action_type action,
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -2462,30 +2463,30 @@ void display_sam_unk_info_2(FILE *out_hnd, enum action_type action,
{
fstring name;
unistr2_to_ascii(name, &(info2->uni_domain), sizeof(name)-1);
- fprintf(out_hnd, "Domain:\t%s\n", name);
+ report(out_hnd, "Domain:\t%s\n", name);
unistr2_to_ascii(name, &(info2->uni_server), sizeof(name)-1);
- fprintf(out_hnd, "Server:\t%s\n", name);
+ report(out_hnd, "Server:\t%s\n", name);
- fprintf(out_hnd, "Total Users:\t%d\n", info2->num_domain_usrs);
- fprintf(out_hnd, "Total Groups:\t%d\n", info2->num_domain_grps);
- fprintf(out_hnd, "Total Aliases:\t%d\n", info2->num_local_grps);
+ report(out_hnd, "Total Users:\t%d\n", info2->num_domain_usrs);
+ report(out_hnd, "Total Groups:\t%d\n", info2->num_domain_grps);
+ report(out_hnd, "Total Aliases:\t%d\n", info2->num_local_grps);
- fprintf(out_hnd, "Sequence No:\t%d\n", info2->seq_num);
+ report(out_hnd, "Sequence No:\t%d\n", info2->seq_num);
- fprintf(out_hnd, "Unknown 0:\t0x%x\n", info2->unknown_0);
- fprintf(out_hnd, "Unknown 1:\t0x%x\n", info2->unknown_1);
- fprintf(out_hnd, "Unknown 2:\t0x%x\n", info2->unknown_2);
- fprintf(out_hnd, "Unknown 3:\t0x%x\n", info2->unknown_3);
- fprintf(out_hnd, "Unknown 4:\t0x%x\n", info2->unknown_4);
- fprintf(out_hnd, "Unknown 5:\t0x%x\n", info2->unknown_5);
- fprintf(out_hnd, "Unknown 6:\t0x%x\n", info2->unknown_6);
+ report(out_hnd, "Unknown 0:\t0x%x\n", info2->unknown_0);
+ report(out_hnd, "Unknown 1:\t0x%x\n", info2->unknown_1);
+ report(out_hnd, "Unknown 2:\t0x%x\n", info2->unknown_2);
+ report(out_hnd, "Unknown 3:\t0x%x\n", info2->unknown_3);
+ report(out_hnd, "Unknown 4:\t0x%x\n", info2->unknown_4);
+ report(out_hnd, "Unknown 5:\t0x%x\n", info2->unknown_5);
+ report(out_hnd, "Unknown 6:\t0x%x\n", info2->unknown_6);
break;
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -2501,8 +2502,8 @@ void display_sam_unk_ctr(FILE *out_hnd, enum action_type action,
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "\tSAM Domain Info\n");
- fprintf(out_hnd, "\t---------------\n");
+ report(out_hnd, "\tSAM Domain Info\n");
+ report(out_hnd, "\t---------------\n");
break;
}
@@ -2522,7 +2523,120 @@ void display_sam_unk_ctr(FILE *out_hnd, enum action_type action,
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+sam info level 1 display function
+****************************************************************************/
+void display_sam_info_1(FILE *out_hnd, enum action_type action,
+ SAM_ENTRY1 *const e1, SAM_STR1 *const s1)
+{
+ if (e1 == NULL)
+ {
+ return;
+ }
+
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ report(out_hnd, "Sam Level 1:\n");
+
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ fstring tmp;
+
+ report(out_hnd, "\tIndex:\t%d\n", e1->user_idx);
+ report(out_hnd, "\tRID:\t0x%x\n", e1->rid_user);
+ report(out_hnd, "\tACB:\t%s\n",
+ pwdb_encode_acct_ctrl(e1->acb_info,
+ NEW_PW_FORMAT_SPACE_PADDED_LEN));
+
+ unistr_to_ascii(tmp, s1->uni_acct_name.buffer, sizeof(tmp)-1);
+ report(out_hnd, "\tAccount Name:\t%s\n", tmp);
+ unistr_to_ascii(tmp, s1->uni_full_name.buffer, sizeof(tmp)-1);
+ report(out_hnd, "\tFull Name:\t%s\n", tmp);
+ unistr_to_ascii(tmp, s1->uni_acct_desc.buffer, sizeof(tmp)-1);
+ report(out_hnd, "\tUser Description:\t%s\n", tmp);
+
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ report(out_hnd, "\n");
+ break;
+ }
+ }
+
+}
+
+/****************************************************************************
+connection info level 1 container display function
+****************************************************************************/
+void display_sam_info_1_ctr(FILE *out_hnd, enum action_type action,
+ uint32 count, SAM_DISPINFO_1 *const ctr)
+{
+ if (ctr == NULL)
+ {
+ report(out_hnd, "display_sam_info_1_ctr: unavailable due to an internal error\n");
+ return;
+ }
+
+ switch (action)
+ {
+ case ACTION_HEADER:
+ {
+ break;
+ }
+ case ACTION_ENUMERATE:
+ {
+ int i;
+
+ for (i = 0; i < count; i++)
+ {
+ display_sam_info_1(out_hnd, ACTION_HEADER , &ctr->sam[i], &ctr->str[i]);
+ display_sam_info_1(out_hnd, ACTION_ENUMERATE, &ctr->sam[i], &ctr->str[i]);
+ display_sam_info_1(out_hnd, ACTION_FOOTER , &ctr->sam[i], &ctr->str[i]);
+ }
+ break;
+ }
+ case ACTION_FOOTER:
+ {
+ break;
+ }
+ }
+}
+
+/****************************************************************************
+connection info container display function
+****************************************************************************/
+void display_sam_disp_info_ctr(FILE *out_hnd, enum action_type action,
+ uint16 level, uint32 count,
+ SAM_DISPINFO_CTR *const ctr)
+{
+ if (ctr == NULL)
+ {
+ report(out_hnd, "display_sam_info_ctr: unavailable due to an internal error\n");
+ return;
+ }
+
+ switch (level)
+ {
+ case 1:
+ {
+ display_sam_info_1_ctr(out_hnd, action,
+ count, ctr->sam.info1);
+ break;
+ }
+ default:
+ {
+ report(out_hnd, "display_sam_info_ctr: Unknown Info Level\n");
break;
}
}
@@ -2543,7 +2657,7 @@ void display_print_info_0(FILE *out_hnd, enum action_type action,
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "Printer Info Level 0:\n");
+ report(out_hnd, "Printer Info Level 0:\n");
break;
}
@@ -2555,15 +2669,15 @@ void display_print_info_0(FILE *out_hnd, enum action_type action,
unistr_to_ascii(name, i0->printername.buffer, sizeof(name)-1);
unistr_to_ascii(serv, i0->servername .buffer, sizeof(serv)-1);
- fprintf(out_hnd, "\tprinter name:\t%s\n", name);
- fprintf(out_hnd, "\tserver name:\t%s\n", serv);
- fprintf(out_hnd, "\t[Other info not displayed]\n");
+ report(out_hnd, "\tprinter name:\t%s\n", name);
+ report(out_hnd, "\tserver name:\t%s\n", serv);
+ report(out_hnd, "\t[Other info not displayed]\n");
break;
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -2585,7 +2699,7 @@ void display_print_info_1(FILE *out_hnd, enum action_type action,
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "Printer Info Level 1:\n");
+ report(out_hnd, "Printer Info Level 1:\n");
break;
}
@@ -2599,16 +2713,16 @@ void display_print_info_1(FILE *out_hnd, enum action_type action,
unistr_to_ascii(name, i1->name .buffer, sizeof(name)-1);
unistr_to_ascii(comm, i1->comment .buffer, sizeof(comm)-1);
- fprintf(out_hnd, "\tflags:\t%d\n", i1->flags);
- fprintf(out_hnd, "\tname:\t%s\n", name);
- fprintf(out_hnd, "\tdescription:\t%s\n", desc);
- fprintf(out_hnd, "\tcomment:\t%s\n", comm);
+ report(out_hnd, "\tflags:\t%d\n", i1->flags);
+ report(out_hnd, "\tname:\t%s\n", name);
+ report(out_hnd, "\tdescription:\t%s\n", desc);
+ report(out_hnd, "\tcomment:\t%s\n", comm);
break;
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -2623,7 +2737,7 @@ void display_printer_info_0_ctr(FILE *out_hnd, enum action_type action,
{
if (ctr == NULL)
{
- fprintf(out_hnd, "display_printer_info_0_ctr: unavailable due to an internal error\n");
+ report(out_hnd, "display_printer_info_0_ctr: unavailable due to an internal error\n");
return;
}
@@ -2660,7 +2774,7 @@ void display_printer_info_1_ctr(FILE *out_hnd, enum action_type action,
{
if (ctr == NULL)
{
- fprintf(out_hnd, "display_printer_info_1_ctr: unavailable due to an internal error\n");
+ report(out_hnd, "display_printer_info_1_ctr: unavailable due to an internal error\n");
return;
}
@@ -2698,7 +2812,7 @@ void display_printer_info_ctr(FILE *out_hnd, enum action_type action,
{
if (ctr == NULL)
{
- fprintf(out_hnd, "display_printer_info_ctr: unavailable due to an internal error\n");
+ report(out_hnd, "display_printer_info_ctr: unavailable due to an internal error\n");
return;
}
@@ -2718,7 +2832,7 @@ void display_printer_info_ctr(FILE *out_hnd, enum action_type action,
}
default:
{
- fprintf(out_hnd, "display_printer_info_ctr: Unknown Info Level\n");
+ report(out_hnd, "display_printer_info_ctr: Unknown Info Level\n");
break;
}
}
@@ -2739,7 +2853,7 @@ void display_job_info_2(FILE *out_hnd, enum action_type action,
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "Job Info Level 2:\n");
+ report(out_hnd, "Job Info Level 2:\n");
break;
}
@@ -2747,49 +2861,49 @@ void display_job_info_2(FILE *out_hnd, enum action_type action,
{
fstring tmp;
- fprintf(out_hnd, "\tjob id:\t%d\n", i2->jobid);
+ report(out_hnd, "\tjob id:\t%d\n", i2->jobid);
unistr_to_ascii(tmp, i2->printername.buffer, sizeof(tmp)-1);
- fprintf(out_hnd, "\tprinter name:\t%s\n", tmp);
+ report(out_hnd, "\tprinter name:\t%s\n", tmp);
unistr_to_ascii(tmp, i2->machinename.buffer, sizeof(tmp)-1);
- fprintf(out_hnd, "\tmachine name:\t%s\n", tmp);
+ report(out_hnd, "\tmachine name:\t%s\n", tmp);
unistr_to_ascii(tmp, i2->username.buffer, sizeof(tmp)-1);
- fprintf(out_hnd, "\tusername:\t%s\n", tmp);
+ report(out_hnd, "\tusername:\t%s\n", tmp);
unistr_to_ascii(tmp, i2->document.buffer, sizeof(tmp)-1);
- fprintf(out_hnd, "\tdocument:\t%s\n", tmp);
+ report(out_hnd, "\tdocument:\t%s\n", tmp);
unistr_to_ascii(tmp, i2->notifyname.buffer, sizeof(tmp)-1);
- fprintf(out_hnd, "\tnotify name:\t%s\n", tmp);
+ report(out_hnd, "\tnotify name:\t%s\n", tmp);
unistr_to_ascii(tmp, i2->datatype.buffer, sizeof(tmp)-1);
- fprintf(out_hnd, "\tdata type:\t%s\n", tmp);
+ report(out_hnd, "\tdata type:\t%s\n", tmp);
unistr_to_ascii(tmp, i2->printprocessor.buffer, sizeof(tmp)-1);
- fprintf(out_hnd, "\tprint processor:\t%s\n", tmp);
+ report(out_hnd, "\tprint processor:\t%s\n", tmp);
unistr_to_ascii(tmp, i2->parameters.buffer, sizeof(tmp)-1);
- fprintf(out_hnd, "\tparameters:\t%s\n", tmp);
+ report(out_hnd, "\tparameters:\t%s\n", tmp);
unistr_to_ascii(tmp, i2->drivername.buffer, sizeof(tmp)-1);
- fprintf(out_hnd, "\tdriver name:\t%s\n", tmp);
- fprintf(out_hnd, "\tDevice Mode:\tNOT DISPLAYED YET\n");
+ report(out_hnd, "\tdriver name:\t%s\n", tmp);
+ report(out_hnd, "\tDevice Mode:\tNOT DISPLAYED YET\n");
/*
DEVICEMODE *devmode;
*/
unistr_to_ascii(tmp, i2->text_status.buffer, sizeof(tmp)-1);
- fprintf(out_hnd, "\ttext status:\t%s\n", tmp);
+ report(out_hnd, "\ttext status:\t%s\n", tmp);
/* SEC_DESC sec_desc;*/
- fprintf(out_hnd, "\tstatus:\t%d\n", i2->status);
- fprintf(out_hnd, "\tpriority:\t%d\n", i2->priority);
- fprintf(out_hnd, "\tposition:\t%d\n", i2->position);
- fprintf(out_hnd, "\tstarttime:\t%d\n", i2->starttime);
- fprintf(out_hnd, "\tuntiltime:\t%d\n", i2->untiltime);
- fprintf(out_hnd, "\ttotalpages:\t%d\n", i2->totalpages);
- fprintf(out_hnd, "\tsize:\t%d\n", i2->size);
+ report(out_hnd, "\tstatus:\t%d\n", i2->status);
+ report(out_hnd, "\tpriority:\t%d\n", i2->priority);
+ report(out_hnd, "\tposition:\t%d\n", i2->position);
+ report(out_hnd, "\tstarttime:\t%d\n", i2->starttime);
+ report(out_hnd, "\tuntiltime:\t%d\n", i2->untiltime);
+ report(out_hnd, "\ttotalpages:\t%d\n", i2->totalpages);
+ report(out_hnd, "\tsize:\t%d\n", i2->size);
/*
SYSTEMTIME submitted;
*/
- fprintf(out_hnd, "\tsubmitted:\tNOT DISPLAYED YET\n");
- fprintf(out_hnd, "\ttimeelapsed:\t%d\n", i2->timeelapsed);
- fprintf(out_hnd, "\tpagesprinted:\t%d\n", i2->pagesprinted);
+ report(out_hnd, "\tsubmitted:\tNOT DISPLAYED YET\n");
+ report(out_hnd, "\ttimeelapsed:\t%d\n", i2->timeelapsed);
+ report(out_hnd, "\tpagesprinted:\t%d\n", i2->pagesprinted);
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -2811,7 +2925,7 @@ void display_job_info_1(FILE *out_hnd, enum action_type action,
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "Job Info Level 1:\n");
+ report(out_hnd, "Job Info Level 1:\n");
break;
}
@@ -2819,34 +2933,34 @@ void display_job_info_1(FILE *out_hnd, enum action_type action,
{
fstring tmp;
- fprintf(out_hnd, "\tjob id:\t%d\n", i1->jobid);
+ report(out_hnd, "\tjob id:\t%d\n", i1->jobid);
unistr_to_ascii(tmp, i1->printername.buffer, sizeof(tmp)-1);
- fprintf(out_hnd, "\tprinter name:\t%s\n", tmp);
+ report(out_hnd, "\tprinter name:\t%s\n", tmp);
unistr_to_ascii(tmp, i1->machinename.buffer, sizeof(tmp)-1);
- fprintf(out_hnd, "\tmachine name:\t%s\n", tmp);
+ report(out_hnd, "\tmachine name:\t%s\n", tmp);
unistr_to_ascii(tmp, i1->username.buffer, sizeof(tmp)-1);
- fprintf(out_hnd, "\tusername:\t%s\n", tmp);
+ report(out_hnd, "\tusername:\t%s\n", tmp);
unistr_to_ascii(tmp, i1->document.buffer, sizeof(tmp)-1);
- fprintf(out_hnd, "\tdocument:\t%s\n", tmp);
+ report(out_hnd, "\tdocument:\t%s\n", tmp);
unistr_to_ascii(tmp, i1->datatype.buffer, sizeof(tmp)-1);
- fprintf(out_hnd, "\tdata type:\t%s\n", tmp);
+ report(out_hnd, "\tdata type:\t%s\n", tmp);
unistr_to_ascii(tmp, i1->text_status.buffer, sizeof(tmp)-1);
- fprintf(out_hnd, "\ttext status:\t%s\n", tmp);
- fprintf(out_hnd, "\tstatus:\t%d\n", i1->status);
- fprintf(out_hnd, "\tpriority:\t%d\n", i1->priority);
- fprintf(out_hnd, "\tposition:\t%d\n", i1->position);
- fprintf(out_hnd, "\ttotalpages:\t%d\n", i1->totalpages);
+ report(out_hnd, "\ttext status:\t%s\n", tmp);
+ report(out_hnd, "\tstatus:\t%d\n", i1->status);
+ report(out_hnd, "\tpriority:\t%d\n", i1->priority);
+ report(out_hnd, "\tposition:\t%d\n", i1->position);
+ report(out_hnd, "\ttotalpages:\t%d\n", i1->totalpages);
/*
SYSTEMTIME submitted;
*/
- fprintf(out_hnd, "\tsubmitted:\tNOT DISPLAYED YET\n");
- fprintf(out_hnd, "\tpagesprinted:\t%d\n", i1->pagesprinted);
+ report(out_hnd, "\tsubmitted:\tNOT DISPLAYED YET\n");
+ report(out_hnd, "\tpagesprinted:\t%d\n", i1->pagesprinted);
break;
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
@@ -2861,7 +2975,7 @@ void display_job_info_2_ctr(FILE *out_hnd, enum action_type action,
{
if (ctr == NULL)
{
- fprintf(out_hnd, "display_job_info_2_ctr: unavailable due to an internal error\n");
+ report(out_hnd, "display_job_info_2_ctr: unavailable due to an internal error\n");
return;
}
@@ -2898,7 +3012,7 @@ void display_job_info_1_ctr(FILE *out_hnd, enum action_type action,
{
if (ctr == NULL)
{
- fprintf(out_hnd, "display_job_info_1_ctr: unavailable due to an internal error\n");
+ report(out_hnd, "display_job_info_1_ctr: unavailable due to an internal error\n");
return;
}
@@ -2936,7 +3050,7 @@ void display_job_info_ctr(FILE *out_hnd, enum action_type action,
{
if (ctr == NULL)
{
- fprintf(out_hnd, "display_job_info_ctr: unavailable due to an internal error\n");
+ report(out_hnd, "display_job_info_ctr: unavailable due to an internal error\n");
return;
}
@@ -2956,7 +3070,7 @@ void display_job_info_ctr(FILE *out_hnd, enum action_type action,
}
default:
{
- fprintf(out_hnd, "display_job_info_ctr: Unknown Info Level\n");
+ report(out_hnd, "display_job_info_ctr: Unknown Info Level\n");
break;
}
}
@@ -2972,8 +3086,8 @@ void display_job_info_ctr(FILE *out_hnd, enum action_type action,
{
case ACTION_HEADER:
{
- fprintf(out_hnd, "\t\n");
- fprintf(out_hnd, "\t-------------------\n");
+ report(out_hnd, "\t\n");
+ report(out_hnd, "\t-------------------\n");
break;
}
@@ -2983,7 +3097,7 @@ void display_job_info_ctr(FILE *out_hnd, enum action_type action,
}
case ACTION_FOOTER:
{
- fprintf(out_hnd, "\n");
+ report(out_hnd, "\n");
break;
}
}
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index 490c52ab3d..70f7d0d87e 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -45,6 +45,7 @@ extern int DEBUGLEVEL;
static int process_tok(fstring tok);
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_set (struct client_info *info, int argc, char *argv[]);
static struct user_credentials usr;
@@ -498,6 +499,12 @@ commands[] =
{COMPL_NONE, COMPL_NONE}
},
+ {
+ "rpcclient",
+ cmd_set,
+ "run rpcclient inside rpcclient (change options etc.)",
+ {COMPL_NONE, COMPL_NONE}
+ },
/*
* bye bye
*/
@@ -642,6 +649,9 @@ static int process_tok(char *tok)
return(-2);
}
+/* command options mask */
+static uint32 cmd_set_options = 0xffffffff;
+
/****************************************************************************
process commands from the client
****************************************************************************/
@@ -651,6 +661,9 @@ static BOOL do_command(struct client_info *info, char *line)
char *ptr = line;
pstring tok;
+ cmd_argc = 0;
+ cmd_argv = NULL;
+
/* get the first part of the command */
if (!next_token(&ptr,tok,NULL, sizeof(tok)))
{
@@ -668,10 +681,15 @@ static BOOL do_command(struct client_info *info, char *line)
return False;
}
+ cmd_set_options = 0x0;
+
if ((i = process_tok(cmd_argv[0])) >= 0)
{
- optind = -1;
- commands[i].fn(info, (uint32)cmd_argc, cmd_argv);
+ int argc = (int)cmd_argc;
+ char **argv = cmd_argv;
+ optind = 0;
+
+ commands[i].fn(info, argc, argv);
}
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);
- cmd_argc = 0;
- cmd_argv = NULL;
return True;
}
@@ -728,28 +744,31 @@ static BOOL process( struct client_info *info, char *cmd_str)
pstring line;
char *cmd = cmd_str;
- if (cmd[0] != '\0') while (cmd[0] != '\0')
+ if (cmd != NULL)
{
- char *p;
-
- if ((p = strchr(cmd, ';')) == 0)
+ while (cmd[0] != '\0')
{
- 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;
- }
+ char *p;
- /* input language code to internal one */
- CNV_INPUT (line);
+ if ((p = strchr(cmd, ';')) == 0)
+ {
+ 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))
{
@@ -760,7 +779,7 @@ static BOOL process( struct client_info *info, char *cmd_str)
#ifndef HAVE_LIBREADLINE
/* 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);
#ifdef CLIX
@@ -786,8 +805,8 @@ static BOOL process( struct client_info *info, char *cmd_str)
#else /* HAVE_LIBREADLINE */
- slprintf(promptline, sizeof(promptline) - 1, "smb: %s> ",
- CNV_LANG(info->cur_dir));
+ slprintf(promptline, sizeof(promptline) - 1, "%s$ ",
+ CNV_LANG(cli_info.dest_host));
if (!readline(promptline))
break;
@@ -824,12 +843,11 @@ usage on the program
****************************************************************************/
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);
fprintf(out_hnd, "\nVersion %s\n",VERSION);
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-l log basename. Basename for log/debug files\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-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%%pass set the network username and password\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, "\n");
}
-enum client_action
-{
- CLIENT_NONE,
- CLIENT_IPC,
- CLIENT_SVC
-};
-
#ifdef HAVE_LIBREADLINE
/****************************************************************************
@@ -1320,183 +1332,77 @@ static char *complete_cmd_null(char *text, int state)
#endif /* HAVE_LIBREADLINE */
-/****************************************************************************
- main program
-****************************************************************************/
- int main(int argc,char *argv[])
+static void set_user_password(struct user_credentials *u,
+ BOOL got_pass, char *password)
{
- BOOL interactive = True;
+ /* 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);
+ }
+}
- int opt;
+#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;
- 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;
-
pstring password; /* local copy only, if one is entered */
- usr.ntlmssp_flags = 0x0;
-
- usr_creds = &usr;
- out_hnd = stdout;
- fstrcpy(debugf, argv[0]);
-
- 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.user_name, "");
- pstrcpy(cli_info.myhostname, "");
- pstrcpy(cli_info.dest_host, "");
-
- 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.level5_sid);
- fstrcpy(cli_info.dom.level3_dom, "");
- fstrcpy(cli_info.dom.level5_dom, "");
-
-#ifdef HAVE_LIBREADLINE
-
- /* Initialise GNU Readline */
-
- rl_readline_name = "rpcclient";
- rl_attempted_completion_function = completion_fn;
- rl_completion_entry_function = (Function *)complete_cmd_null;
-
- /* Initialise history list */
-
- using_history();
-
-#endif /* HAVE_LIBREADLINE */
-
- TimeInit();
- charset_initialise();
-
- myumask = umask(0);
- umask(myumask);
-
- if (!get_myname(global_myname, NULL))
- {
- 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)
- {
- usage(argv[0]);
- exit(1);
- }
-
if (*argv[1] != '-')
{
-
- 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;
+ cmd_set_options |= CMD_PASS;
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)
+ 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)
{
@@ -1512,26 +1418,29 @@ static char *complete_cmd_null(char *text, int state)
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);
- cli_action = CLIENT_IPC;
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;
}
@@ -1539,12 +1448,13 @@ static char *complete_cmd_null(char *text, int state)
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);
- got_pass = True;
+ cmd_set_options |= CMD_PASS;
memset(strchr(optarg,'%')+1,'X',strlen(password));
}
break;
@@ -1552,18 +1462,21 @@ static char *complete_cmd_null(char *text, int state)
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))
{
@@ -1574,18 +1487,20 @@ static char *complete_cmd_null(char *text, int state)
case 'n':
{
+ cmd_set_options |= CMD_NAME;
fstrcpy(global_myname, optarg);
break;
}
case 'N':
{
- got_pass = True;
+ cmd_set_options |= CMD_NOPW | CMD_PASS;
break;
}
case 'd':
{
+ cmd_set_options |= CMD_DBLV;
if (*optarg == 'A')
DEBUGLEVEL = 10000;
else
@@ -1595,6 +1510,7 @@ static char *complete_cmd_null(char *text, int state)
case 'l':
{
+ cmd_set_options |= CMD_INTER;
slprintf(debugf, sizeof(debugf)-1,
"%s.client", optarg);
interactive = False;
@@ -1603,106 +1519,201 @@ static char *complete_cmd_null(char *text, int state)
case 'c':
{
+ cmd_set_options |= CMD_STR | CMD_PASS;
cmd_str = optarg;
- got_pass = True;
break;
}
case 'h':
{
+ cmd_set_options |= CMD_HELP;
usage(argv[0]);
- exit(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]);
- exit(1);
break;
}
}
}
+ if (IS_BITS_SET_ALL(cmd_set_options, CMD_HELP))
+ {
+ return;
+ }
+
setup_logging(debugf, interactive);
+ reopen_logs();
- if (cli_action == CLIENT_NONE)
+ if (IS_BITS_SET_ALL(cmd_set_options, CMD_NOPW))
{
- usage(argv[0]);
- exit(1);
+ 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);
- 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());
-
load_interfaces();
- if (cli_action == CLIENT_IPC)
- {
- 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 (cmd_str != NULL)
{
- if (password[0] == 0)
- {
- pwd_set_nullpwd(&(usr.pwd));
- }
- else
+ 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,'%')))
{
- /* generate 16 byte hashes */
- pwd_make_lm_nt_16(&(usr.pwd), password);
+ *p = 0;
+ pstrcpy(password,p+1);
+ memset(strchr(getenv("USER"),'%')+1,'X',strlen(password));
}
+ strupper(u->user_name);
}
- else
+
+ /* modification to support PASSWD environmental var
+ 25.Aug.97, jdblair@uab.edu */
+ if (getenv("PASSWD"))
{
- pwd_read(&(usr.pwd), "Enter Password:", True);
+ 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
+****************************************************************************/
+ int main(int argc,char *argv[])
+{
+ extern struct user_credentials *usr_creds;
+ mode_t myumask = 0755;
+
+ DEBUGLEVEL = 2;
+
+ usr.ntlmssp_flags = 0x0;
+
+ usr_creds = &usr;
+ out_hnd = stdout;
+ fstrcpy(debugf, argv[0]);
+
+ init_policy_hnd(64);
+
+ pstrcpy(usr.domain, "");
+ pstrcpy(usr.user_name, "");
+
+ pstrcpy(cli_info.myhostname, "");
+ pstrcpy(cli_info.dest_host, "");
+ cli_info.dest_ip.s_addr = 0;
+
+ ZERO_STRUCT(cli_info.dom.level3_sid);
+ ZERO_STRUCT(cli_info.dom.level5_sid);
+ fstrcpy(cli_info.dom.level3_dom, "");
+ fstrcpy(cli_info.dom.level5_dom, "");
+
+#ifdef HAVE_LIBREADLINE
+
+ /* Initialise GNU Readline */
+
+ rl_readline_name = "rpcclient";
+ rl_attempted_completion_function = completion_fn;
+ rl_completion_entry_function = (Function *)complete_cmd_null;
+
+ /* Initialise history list */
+
+ using_history();
+
+#endif /* HAVE_LIBREADLINE */
+
+ TimeInit();
+ charset_initialise();
+
+ myumask = umask(0);
+ umask(myumask);
- switch (cli_action)
+ if (!get_myname(global_myname, NULL))
{
- case CLIENT_IPC:
- {
- process(&cli_info, cmd_str);
- break;
- }
+ fprintf(stderr, "Failed to get my hostname.\n");
+ }
- default:
- {
- fprintf(stderr, "unknown client action requested\n");
- break;
- }
+ if (argc < 2)
+ {
+ usage(argv[0]);
+ exit(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);
+ }
+
+ codepage_initialise(lp_client_code_page());
+
+ DEBUG(3,("%s client started (version %s)\n",timestring(),VERSION));
+
+ process(&cli_info, NULL);
+
return(0);
}