summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2001-05-04 14:16:47 +0000
committerGerald Carter <jerry@samba.org>2001-05-04 14:16:47 +0000
commit4ec4436c960103326eca9e6d3f6c3fc4f5acf683 (patch)
treecb12454054133b704faa81cc5948319cc73f4ae3
parente70f98aa4f88970e2a70752328426b2beb3b8978 (diff)
downloadsamba-4ec4436c960103326eca9e6d3f6c3fc4f5acf683.tar.gz
samba-4ec4436c960103326eca9e6d3f6c3fc4f5acf683.tar.xz
samba-4ec4436c960103326eca9e6d3f6c3fc4f5acf683.zip
merging Tim's changes form HEAD
-rw-r--r--source/libsmb/cli_samr.c184
-rw-r--r--source/rpcclient/cmd_samr.c196
-rw-r--r--source/rpcclient/cmd_spoolss.c58
-rw-r--r--source/rpcclient/rpcclient.c15
4 files changed, 413 insertions, 40 deletions
diff --git a/source/libsmb/cli_samr.c b/source/libsmb/cli_samr.c
index a822611445d..985a0a1ecb1 100644
--- a/source/libsmb/cli_samr.c
+++ b/source/libsmb/cli_samr.c
@@ -563,3 +563,187 @@ uint32 cli_samr_query_groupmem(
return result;
}
+
+/* Enumerate domain groups */
+
+uint32 cli_samr_enum_dom_groups(struct cli_state *cli, TALLOC_CTX *mem_ctx,
+ POLICY_HND *pol, uint32 *start_idx,
+ uint32 size, struct acct_info **dom_groups,
+ uint32 *num_dom_groups)
+{
+ prs_struct qbuf, rbuf;
+ SAMR_Q_ENUM_DOM_GROUPS q;
+ SAMR_R_ENUM_DOM_GROUPS r;
+ uint32 result = NT_STATUS_UNSUCCESSFUL, name_idx, i;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Initialise parse structures */
+
+ prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
+
+ /* Marshall data and send request */
+
+ init_samr_q_enum_dom_groups(&q, pol, *start_idx, size);
+
+ if (!samr_io_q_enum_dom_groups("", &q, &qbuf, 0) ||
+ !rpc_api_pipe_req(cli, SAMR_ENUM_DOM_GROUPS, &qbuf, &rbuf)) {
+ goto done;
+ }
+
+ /* Unmarshall response */
+
+ if (!samr_io_r_enum_dom_groups("", &r, &rbuf, 0)) {
+ goto done;
+ }
+
+ /* Return output parameters */
+
+ result = r.status;
+
+ if (result != NT_STATUS_NOPROBLEMO &&
+ result != STATUS_MORE_ENTRIES) {
+ goto done;
+ }
+
+ *num_dom_groups = r.num_entries2;
+
+ if (!((*dom_groups) = (struct acct_info *)
+ talloc(mem_ctx, sizeof(struct acct_info) * *num_dom_groups))) {
+ result = NT_STATUS_UNSUCCESSFUL;
+ goto done;
+ }
+
+ memset(*dom_groups, 0, sizeof(struct acct_info) * *num_dom_groups);
+
+ name_idx = 0;
+
+ for (i = 0; i < *num_dom_groups; i++) {
+
+ (*dom_groups)[i].rid = r.sam[i].rid;
+
+ if (r.sam[i].hdr_name.buffer) {
+ unistr2_to_ascii((*dom_groups)[i].acct_name,
+ &r.uni_grp_name[name_idx],
+ sizeof(fstring) - 1);
+ name_idx++;
+ }
+
+ *start_idx = r.next_idx;
+ }
+
+ done:
+ prs_mem_free(&qbuf);
+ prs_mem_free(&rbuf);
+
+ return result;
+}
+
+/* Query alias members */
+
+uint32 cli_samr_query_aliasmem(struct cli_state *cli, TALLOC_CTX *mem_ctx,
+ POLICY_HND *alias_pol, uint32 *num_mem,
+ DOM_SID **sids)
+{
+ prs_struct qbuf, rbuf;
+ SAMR_Q_QUERY_ALIASMEM q;
+ SAMR_R_QUERY_ALIASMEM r;
+ uint32 result = NT_STATUS_UNSUCCESSFUL, i;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Initialise parse structures */
+
+ prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
+
+ /* Marshall data and send request */
+
+ init_samr_q_query_aliasmem(&q, alias_pol);
+
+ if (!samr_io_q_query_aliasmem("", &q, &qbuf, 0) ||
+ !rpc_api_pipe_req(cli, SAMR_QUERY_ALIASMEM, &qbuf, &rbuf)) {
+ goto done;
+ }
+
+ /* Unmarshall response */
+
+ if (!samr_io_r_query_aliasmem("", &r, &rbuf, 0)) {
+ goto done;
+ }
+
+ /* Return output parameters */
+
+ if ((result = r.status) != NT_STATUS_NOPROBLEMO) {
+ goto done;
+ }
+
+ *num_mem = r.num_sids;
+
+ if (!(*sids = talloc(mem_ctx, sizeof(DOM_SID) * *num_mem))) {
+ result = NT_STATUS_UNSUCCESSFUL;
+ goto done;
+ }
+
+ for (i = 0; i < *num_mem; i++) {
+ (*sids)[i] = r.sid[i].sid;
+ }
+
+ done:
+ prs_mem_free(&qbuf);
+ prs_mem_free(&rbuf);
+
+ return result;
+}
+
+/* Open handle on an alias */
+
+uint32 cli_samr_open_alias(struct cli_state *cli, TALLOC_CTX *mem_ctx,
+ POLICY_HND *domain_pol, uint32 access_mask,
+ uint32 alias_rid, POLICY_HND *alias_pol)
+{
+ prs_struct qbuf, rbuf;
+ SAMR_Q_OPEN_ALIAS q;
+ SAMR_R_OPEN_ALIAS r;
+ uint32 result;
+
+ ZERO_STRUCT(q);
+ ZERO_STRUCT(r);
+
+ /* Initialise parse structures */
+
+ prs_init(&qbuf, MAX_PDU_FRAG_LEN, mem_ctx, MARSHALL);
+ prs_init(&rbuf, 0, mem_ctx, UNMARSHALL);
+
+ /* Marshall data and send request */
+
+ init_samr_q_open_alias(&q, domain_pol, access_mask, alias_rid);
+
+ if (!samr_io_q_open_alias("", &q, &qbuf, 0) ||
+ !rpc_api_pipe_req(cli, SAMR_OPEN_ALIAS, &qbuf, &rbuf)) {
+ result = NT_STATUS_UNSUCCESSFUL;
+ goto done;
+ }
+
+ /* Unmarshall response */
+
+ if (!samr_io_r_open_alias("", &r, &rbuf, 0)) {
+ result = NT_STATUS_UNSUCCESSFUL;
+ goto done;
+ }
+
+ /* Return output parameters */
+
+ if ((result = r.status) == NT_STATUS_NOPROBLEMO) {
+ *alias_pol = r.pol;
+ }
+
+ done:
+ prs_mem_free(&qbuf);
+ prs_mem_free(&rbuf);
+
+ return result;
+}
diff --git a/source/rpcclient/cmd_samr.c b/source/rpcclient/cmd_samr.c
index d0706cc9b76..d199e65b95a 100644
--- a/source/rpcclient/cmd_samr.c
+++ b/source/rpcclient/cmd_samr.c
@@ -5,8 +5,8 @@
Copyright (C) Andrew Tridgell 1992-2000,
Copyright (C) Luke Kenneth Casson Leighton 1996-2000,
- Copyright (C) Elrond 2000
- Copyright (C) Tim Potter 2000
+ Copyright (C) Elrond 2000,
+ Copyright (C) Tim Potter 2000
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -122,6 +122,7 @@ static uint32 cmd_samr_query_user(struct cli_state *cli, int argc, char **argv)
return NT_STATUS_UNSUCCESSFUL;
}
+ fetch_domain_sid(cli);
/* Initialise RPC connection */
if (!cli_nt_session_open (cli, PIPE_SAMR)) {
@@ -139,7 +140,6 @@ static uint32 cmd_samr_query_user(struct cli_state *cli, int argc, char **argv)
}
got_connect_pol = True;
- fetch_domain_sid(cli);
if ((result = cli_samr_open_domain(cli, mem_ctx, &connect_pol,
MAXIMUM_ALLOWED_ACCESS,
@@ -250,6 +250,8 @@ static uint32 cmd_samr_query_group(struct cli_state *cli, int argc, char **argv)
return NT_STATUS_UNSUCCESSFUL;
}
+ fetch_domain_sid(cli);
+
/* Initialise RPC connection */
if (!cli_nt_session_open (cli, PIPE_SAMR)) {
fprintf (stderr, "Could not initialize samr pipe!\n");
@@ -266,7 +268,6 @@ static uint32 cmd_samr_query_group(struct cli_state *cli, int argc, char **argv)
}
got_connect_pol = True;
- fetch_domain_sid(cli);
if ((result = cli_samr_open_domain(cli, mem_ctx, &connect_pol,
MAXIMUM_ALLOWED_ACCESS,
@@ -338,6 +339,8 @@ static uint32 cmd_samr_query_usergroups(struct cli_state *cli, int argc, char **
sscanf(argv[1], "%i", &user_rid);
+ fetch_domain_sid(cli);
+
/* Initialise RPC connection */
if (!cli_nt_session_open (cli, PIPE_SAMR)) {
fprintf (stderr, "Could not initialize samr pipe!\n");
@@ -354,7 +357,6 @@ static uint32 cmd_samr_query_usergroups(struct cli_state *cli, int argc, char **
}
got_connect_pol = True;
- fetch_domain_sid(cli);
if ((result = cli_samr_open_domain(cli, mem_ctx, &connect_pol,
MAXIMUM_ALLOWED_ACCESS,
@@ -423,6 +425,8 @@ static uint32 cmd_samr_query_groupmem(struct cli_state *cli, int argc, char **ar
sscanf(argv[1], "%i", &group_rid);
+ fetch_domain_sid(cli);
+
/* Initialise RPC connection */
if (!cli_nt_session_open (cli, PIPE_SAMR)) {
fprintf (stderr, "Could not initialize samr pipe!\n");
@@ -439,7 +443,6 @@ static uint32 cmd_samr_query_groupmem(struct cli_state *cli, int argc, char **ar
}
got_connect_pol = True;
- fetch_domain_sid(cli);
if ((result = cli_samr_open_domain(cli, mem_ctx, &connect_pol,
MAXIMUM_ALLOWED_ACCESS,
@@ -482,14 +485,195 @@ static uint32 cmd_samr_query_groupmem(struct cli_state *cli, int argc, char **ar
return result;
}
+/* Enumerate domain groups */
+
+static uint32 cmd_samr_enum_dom_groups(struct cli_state *cli, int argc,
+ char **argv)
+{
+ POLICY_HND connect_pol, domain_pol;
+ uint32 result = NT_STATUS_UNSUCCESSFUL;
+ BOOL got_connect_pol = False, got_domain_pol = False;
+ TALLOC_CTX *mem_ctx;
+ fstring server;
+ uint32 start_idx, size, num_dom_groups, i;
+ struct acct_info *dom_groups;
+
+ if (argc != 1) {
+ printf("Usage: %s\n", argv[0]);
+ return 0;
+ }
+
+ if (!(mem_ctx = talloc_init())) {
+ DEBUG(0, ("cmd_samr_enum_dom_groups: talloc_init returned "
+ "NULL!\n"));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ fetch_domain_sid(cli);
+
+ /* Initialise RPC connection */
+
+ if (!cli_nt_session_open (cli, PIPE_SAMR)) {
+ fprintf (stderr, "Could not initialize samr pipe!\n");
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->desthost);
+ strupper(server);
+
+ /* Get sam policy handle */
+
+ if ((result = cli_samr_connect(cli, mem_ctx, server,
+ MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol)) !=
+ NT_STATUS_NOPROBLEMO) {
+ goto done;
+ }
+
+ got_connect_pol = True;
+
+ /* Get domain policy handle */
+
+ if ((result = cli_samr_open_domain(cli, mem_ctx, &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid, &domain_pol))
+ != NT_STATUS_NOPROBLEMO) {
+ goto done;
+ }
+
+ got_domain_pol = True;
+
+ /* Enumerate domain groups */
+
+ start_idx = 0;
+ size = 0xffff;
+
+ result = cli_samr_enum_dom_groups(cli, mem_ctx, &domain_pol,
+ &start_idx, size,
+ &dom_groups, &num_dom_groups);
+
+ for (i = 0; i < num_dom_groups; i++)
+ printf("group:[%s] rid:[0x%x]\n", dom_groups[i].acct_name,
+ dom_groups[i].rid);
+
+ done:
+ if (got_domain_pol) cli_samr_close(cli, mem_ctx, &domain_pol);
+ if (got_connect_pol) cli_samr_close(cli, mem_ctx, &connect_pol);
+
+ cli_nt_session_close(cli);
+ talloc_destroy(mem_ctx);
+
+ return result;
+}
+
+/* Query alias membership */
+
+static uint32 cmd_samr_query_aliasmem(struct cli_state *cli, int argc,
+ char **argv)
+{
+ POLICY_HND connect_pol, domain_pol, alias_pol;
+ BOOL got_connect_pol = False, got_domain_pol = False,
+ got_alias_pol = False;
+ TALLOC_CTX *mem_ctx;
+ uint32 result = NT_STATUS_UNSUCCESSFUL, alias_rid, num_members, i;
+ DOM_SID *alias_sids;
+
+ fstring server;
+
+ if (argc != 2) {
+ printf("Usage: %s rid\n", argv[0]);
+ return 0;
+ }
+
+ if (!(mem_ctx=talloc_init())) {
+ DEBUG(0,("cmd_samr_query_aliasmem: talloc_init() "
+ "returned NULL!\n"));
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ sscanf(argv[1], "%i", &alias_rid);
+
+ /* Initialise RPC connection */
+
+ fetch_domain_sid(cli);
+
+ if (!cli_nt_session_open (cli, PIPE_SAMR)) {
+ fprintf (stderr, "Could not initialize samr pipe!\n");
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ /* Open SAMR handle */
+
+ slprintf(server, sizeof(fstring)-1, "\\\\%s", cli->desthost);
+ strupper(server);
+
+ if ((result = cli_samr_connect(cli, mem_ctx, server,
+ MAXIMUM_ALLOWED_ACCESS,
+ &connect_pol)) !=
+ NT_STATUS_NOPROBLEMO) {
+ goto done;
+ }
+
+ got_connect_pol = True;
+
+ /* Open handle on domain */
+
+ if ((result = cli_samr_open_domain(cli, mem_ctx, &connect_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ &domain_sid, &domain_pol))
+ != NT_STATUS_NOPROBLEMO) {
+ goto done;
+ }
+
+ got_domain_pol = True;
+
+ /* Open handle on alias */
+
+ if ((result = cli_samr_open_alias(cli, mem_ctx, &domain_pol,
+ MAXIMUM_ALLOWED_ACCESS,
+ alias_rid, &alias_pol))
+ != NT_STATUS_NOPROBLEMO) {
+ goto done;
+ }
+
+ got_alias_pol = True;
+
+ if ((result = cli_samr_query_aliasmem(cli, mem_ctx, &alias_pol,
+ &num_members, &alias_sids))
+ != NT_STATUS_NOPROBLEMO) {
+ goto done;
+ }
+
+ for (i = 0; i < num_members; i++) {
+ fstring sid_str;
+
+ sid_to_string(sid_str, &alias_sids[i]);
+ printf("\tsid:[%s]\n", sid_str);
+ }
+
+ done:
+ if (got_alias_pol) cli_samr_close(cli, mem_ctx, &alias_pol);
+ if (got_domain_pol) cli_samr_close(cli, mem_ctx, &domain_pol);
+ if (got_connect_pol) cli_samr_close(cli, mem_ctx, &connect_pol);
+
+ cli_nt_session_close(cli);
+ talloc_destroy(mem_ctx);
+
+ return result;
+}
+
/* List of commands exported by this module */
struct cmd_set samr_commands[] = {
{ "SAMR", NULL, "" },
+
{ "queryuser", cmd_samr_query_user, "Query user info" },
{ "querygroup", cmd_samr_query_group, "Query group info" },
{ "queryusergroups", cmd_samr_query_usergroups, "Query user groups" },
{ "querygroupmem", cmd_samr_query_groupmem, "Query group membership" },
+ { "queryaliasmem", cmd_samr_query_aliasmem, "Query alias membership" },
+ { "enumdomgroups", cmd_samr_enum_dom_groups, "Enumerate domain groups" },
+
{ NULL, NULL, NULL }
};
diff --git a/source/rpcclient/cmd_spoolss.c b/source/rpcclient/cmd_spoolss.c
index bec6777b5a9..aeb4ce3e20e 100644
--- a/source/rpcclient/cmd_spoolss.c
+++ b/source/rpcclient/cmd_spoolss.c
@@ -104,14 +104,14 @@ static void display_sec_ace(SEC_ACE *ace)
/****************************************************************************
display sec_acl structure
****************************************************************************/
-static void display_sec_acl(SEC_ACL *the_acl)
+static void display_sec_acl(SEC_ACL *acl)
{
- if (the_acl->size != 0 && the_acl->num_aces != 0) {
+ if (acl->size != 0 && acl->num_aces != 0) {
int i;
- printf("\t\tRevision:[%d]\n", the_acl->revision);
- for (i = 0; i < the_acl->num_aces; i++) {
- display_sec_ace(&the_acl->ace[i]);
+ printf("\t\tRevision:[%d]\n", acl->revision);
+ for (i = 0; i < acl->num_aces; i++) {
+ display_sec_ace(&acl->ace[i]);
}
}
}
@@ -146,7 +146,7 @@ static uint32 cmd_spoolss_open_printer_ex(struct cli_state *cli, int argc, char
{
uint32 result = NT_STATUS_UNSUCCESSFUL;
pstring printername;
- fstring the_server, user;
+ fstring servername, user;
POLICY_HND hnd;
TALLOC_CTX *mem_ctx;
@@ -165,8 +165,8 @@ static uint32 cmd_spoolss_open_printer_ex(struct cli_state *cli, int argc, char
}
- slprintf (the_server, sizeof(fstring)-1, "\\\\%s", cli->desthost);
- strupper (the_server);
+ slprintf (servername, sizeof(fstring)-1, "\\\\%s", cli->desthost);
+ strupper (servername);
fstrcpy (user, cli->user_name);
fstrcpy (printername, argv[1]);
@@ -179,7 +179,7 @@ static uint32 cmd_spoolss_open_printer_ex(struct cli_state *cli, int argc, char
/* Open the printer handle */
result = cli_spoolss_open_printer_ex (cli, mem_ctx, printername, "",
- MAXIMUM_ALLOWED_ACCESS, the_server, user, &hnd);
+ MAXIMUM_ALLOWED_ACCESS, servername, user, &hnd);
if (result == NT_STATUS_NOPROBLEMO) {
printf ("Printer %s opened successfully\n", printername);
@@ -202,13 +202,13 @@ printer info level 0 display function
static void display_print_info_0(PRINTER_INFO_0 *i1)
{
fstring name;
- fstring the_server;
+ fstring servername;
unistr_to_ascii(name, i1->printername.buffer, sizeof(name) - 1);
- unistr_to_ascii(the_server, i1->servername.buffer, sizeof(the_server) - 1);
+ unistr_to_ascii(servername, i1->servername.buffer, sizeof(servername) - 1);
printf("\tprintername:[%s]\n", name);
- printf("\tservername:[%s]\n", the_server);
+ printf("\tservername:[%s]\n", servername);
printf("\tcjobs:[0x%x]\n", i1->cjobs);
printf("\ttotal_jobs:[0x%x]\n", i1->total_jobs);
@@ -515,7 +515,7 @@ static uint32 cmd_spoolss_getprinter(struct cli_state *cli, int argc, char **arg
PRINTER_INFO_CTR ctr;
fstring printername,
servername,
- the_username;
+ user;
TALLOC_CTX *mem_ctx;
if (argc == 1 || argc > 3) {
@@ -544,12 +544,12 @@ static uint32 cmd_spoolss_getprinter(struct cli_state *cli, int argc, char **arg
slprintf (servername, sizeof(fstring)-1, "\\\\%s", cli->desthost);
strupper (servername);
slprintf (printername, sizeof(fstring)-1, "%s\\%s", servername, argv[1]);
- fstrcpy (the_username, cli->user_name);
+ fstrcpy (user, cli->user_name);
/* get a printer handle */
if ((result = cli_spoolss_open_printer_ex(
cli, mem_ctx, printername, "", MAXIMUM_ALLOWED_ACCESS, servername,
- the_username, &pol)) != NT_STATUS_NOPROBLEMO) {
+ user, &pol)) != NT_STATUS_NOPROBLEMO) {
goto done;
}
@@ -712,7 +712,7 @@ static uint32 cmd_spoolss_getdriver(struct cli_state *cli, int argc, char **argv
BOOL opened_hnd = False;
PRINTER_DRIVER_CTR ctr;
fstring printername,
- the_server,
+ servername,
user;
uint32 i;
TALLOC_CTX *mem_ctx;
@@ -737,8 +737,8 @@ static uint32 cmd_spoolss_getdriver(struct cli_state *cli, int argc, char **argv
}
/* get the arguments need to open the printer handle */
- slprintf (the_server, sizeof(fstring)-1, "\\\\%s", cli->desthost);
- strupper (the_server);
+ slprintf (servername, sizeof(fstring)-1, "\\\\%s", cli->desthost);
+ strupper (servername);
fstrcpy (user, cli->user_name);
fstrcpy (printername, argv[1]);
if (argc == 3)
@@ -746,7 +746,7 @@ static uint32 cmd_spoolss_getdriver(struct cli_state *cli, int argc, char **argv
/* Open a printer handle */
if ((result=cli_spoolss_open_printer_ex (cli, mem_ctx, printername, "",
- MAXIMUM_ALLOWED_ACCESS, the_server, user, &pol)) != NT_STATUS_NO_PROBLEMO)
+ MAXIMUM_ALLOWED_ACCESS, servername, user, &pol)) != NT_STATUS_NO_PROBLEMO)
{
printf ("Error opening printer handle for %s!\n", printername);
return result;
@@ -818,7 +818,7 @@ static uint32 cmd_spoolss_enum_drivers(struct cli_state *cli, int argc, char **a
uint32 result=0,
info_level = 1;
PRINTER_DRIVER_CTR ctr;
- fstring the_server;
+ fstring servername;
uint32 i, j,
returned;
TALLOC_CTX *mem_ctx;
@@ -843,8 +843,8 @@ static uint32 cmd_spoolss_enum_drivers(struct cli_state *cli, int argc, char **a
}
/* get the arguments need to open the printer handle */
- slprintf (the_server, sizeof(fstring)-1, "\\\\%s", cli->desthost);
- strupper (the_server);
+ slprintf (servername, sizeof(fstring)-1, "\\\\%s", cli->desthost);
+ strupper (servername);
if (argc == 2)
info_level = atoi(argv[1]);
@@ -1157,7 +1157,7 @@ static uint32 cmd_spoolss_addprinterex (struct cli_state *cli, int argc, char **
level = 2;
PRINTER_INFO_CTR ctr;
PRINTER_INFO_2 info2;
- fstring the_server;
+ fstring servername;
TALLOC_CTX *mem_ctx = NULL;
/* parse the command arguements */
@@ -1174,8 +1174,8 @@ static uint32 cmd_spoolss_addprinterex (struct cli_state *cli, int argc, char **
}
- slprintf (the_server, sizeof(fstring)-1, "\\\\%s", cli->desthost);
- strupper (the_server);
+ slprintf (servername, sizeof(fstring)-1, "\\\\%s", cli->desthost);
+ strupper (servername);
/* Initialise RPC connection */
if (!cli_nt_session_open (cli, PIPE_SPOOLSS))
@@ -1188,7 +1188,7 @@ static uint32 cmd_spoolss_addprinterex (struct cli_state *cli, int argc, char **
/* Fill in the DRIVER_INFO_3 struct */
ZERO_STRUCT(info2);
#if 0 /* JERRY */
- init_unistr( &info2.servername, the_server);
+ init_unistr( &info2.servername, servername);
#endif
init_unistr( &info2.printername, argv[1]);
init_unistr( &info2.sharename, argv[2]);
@@ -1241,7 +1241,7 @@ static uint32 cmd_spoolss_setdriver (struct cli_state *cli, int argc, char **arg
PRINTER_INFO_2 info2;
fstring servername,
printername,
- the_username;
+ user;
TALLOC_CTX *mem_ctx = NULL;
/* parse the command arguements */
@@ -1260,7 +1260,7 @@ static uint32 cmd_spoolss_setdriver (struct cli_state *cli, int argc, char **arg
slprintf (servername, sizeof(fstring)-1, "\\\\%s", cli->desthost);
strupper (servername);
slprintf (printername, sizeof(fstring)-1, "%s\\%s", servername, argv[1]);
- fstrcpy (the_username, cli->user_name);
+ fstrcpy (user, cli->user_name);
/* Initialise RPC connection */
if (!cli_nt_session_open (cli, PIPE_SPOOLSS))
@@ -1272,7 +1272,7 @@ static uint32 cmd_spoolss_setdriver (struct cli_state *cli, int argc, char **arg
/* get a printer handle */
if ((result = cli_spoolss_open_printer_ex(cli, mem_ctx, printername, "",
- MAXIMUM_ALLOWED_ACCESS, servername, the_username, &pol))
+ MAXIMUM_ALLOWED_ACCESS, servername, user, &pol))
!= NT_STATUS_NOPROBLEMO)
{
goto done;
diff --git a/source/rpcclient/rpcclient.c b/source/rpcclient/rpcclient.c
index d50510212ef..dc93c0536bb 100644
--- a/source/rpcclient/rpcclient.c
+++ b/source/rpcclient/rpcclient.c
@@ -408,6 +408,9 @@ static uint32 process_cmd(struct cli_state *cli, char *cmd)
char *p = cmd;
uint32 result=0;
+ if (cmd[strlen(cmd) - 1] == '\n')
+ cmd[strlen(cmd) - 1] = '\0';
+
if (!next_token(&p, buf, " ", sizeof(buf))) {
return 0;
}
@@ -633,7 +636,6 @@ static void usage(char *pname)
/* There are no pointers in ntuser_creds struct so zero it out */
ZERO_STRUCTP (&creds);
-
/* Load command lists */
add_command_set(rpcclient_commands);
add_command_set(separator_command);
@@ -647,7 +649,6 @@ static void usage(char *pname)
add_command_set(samr_commands);
add_command_set(separator_command);
-
/* Do anything specified with -c */
if (cmdstr[0]) {
char *cmd;
@@ -660,7 +661,6 @@ static void usage(char *pname)
return 0;
}
-
/* Loop around accepting commands */
while(1) {
pstring prompt;
@@ -670,7 +670,12 @@ static void usage(char *pname)
line = smb_readline(prompt, NULL, completion_fn);
- process_cmd(&cli, line);
+ if (line == NULL)
+ break;
+
+ if (line[0] != '\n')
+ process_cmd(&cli, line);
}
-}
+ return 0;
+}