summaryrefslogtreecommitdiff
path: root/source3/rpcclient/rpcclient.c
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2003-03-17 05:55:41 +0000
committerTim Potter <tpot@samba.org>2003-03-17 05:55:41 +0000
commit1eae003fefaa8e4e9e131c9d5f2a299cec2b5e55 (patch)
treebdefc7df2e7fac926d5c1402b175428ee985c0ee /source3/rpcclient/rpcclient.c
parent355bea4b2cd62bdd00bfbb3fba017c62b11ebc95 (diff)
downloadsamba-1eae003fefaa8e4e9e131c9d5f2a299cec2b5e55.tar.gz
samba-1eae003fefaa8e4e9e131c9d5f2a299cec2b5e55.tar.bz2
samba-1eae003fefaa8e4e9e131c9d5f2a299cec2b5e55.zip
Applied waider's patch to return DOS error codes for pipes that
support it. (This used to be commit ac3df9a8051bd105e8e4192d36b3024fdf9f9506)
Diffstat (limited to 'source3/rpcclient/rpcclient.c')
-rw-r--r--source3/rpcclient/rpcclient.c48
1 files changed, 34 insertions, 14 deletions
diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c
index c3b2cd4ea1..2338d72f19 100644
--- a/source3/rpcclient/rpcclient.c
+++ b/source3/rpcclient/rpcclient.c
@@ -73,7 +73,10 @@ static char **completion_fn(char *text, int start, int end)
for (i=0; commands->cmd_set[i].name; i++)
{
if ((strncmp(text, commands->cmd_set[i].name, strlen(text)) == 0) &&
- commands->cmd_set[i].fn)
+ (( commands->cmd_set[i].returntype == RPC_RTYPE_NTSTATUS &&
+ commands->cmd_set[i].ntfn ) ||
+ ( commands->cmd_set[i].returntype == RPC_RTYPE_WERROR &&
+ commands->cmd_set[i].wfn)))
{
matches[count] = strdup(commands->cmd_set[i].name);
if (!matches[count])
@@ -393,18 +396,18 @@ static struct cmd_set rpcclient_commands[] = {
{ "GENERAL OPTIONS" },
- { "help", cmd_help, -1, "Get help on commands", "[command]" },
- { "?", cmd_help, -1, "Get help on commands", "[command]" },
- { "debuglevel", cmd_debuglevel, -1, "Set debug level", "level" },
- { "list", cmd_listcommands, -1, "List available commands on <pipe>", "pipe" },
- { "exit", cmd_quit, -1, "Exit program", "" },
- { "quit", cmd_quit, -1, "Exit program", "" },
+ { "help", RPC_RTYPE_NTSTATUS, cmd_help, NULL, -1, "Get help on commands", "[command]" },
+ { "?", RPC_RTYPE_NTSTATUS, cmd_help, NULL, -1, "Get help on commands", "[command]" },
+ { "debuglevel", RPC_RTYPE_NTSTATUS, cmd_debuglevel, NULL, -1, "Set debug level", "level" },
+ { "list", RPC_RTYPE_NTSTATUS, cmd_listcommands, NULL, -1, "List available commands on <pipe>", "pipe" },
+ { "exit", RPC_RTYPE_NTSTATUS, cmd_quit, NULL, -1, "Exit program", "" },
+ { "quit", RPC_RTYPE_NTSTATUS, cmd_quit, NULL, -1, "Exit program", "" },
{ NULL }
};
static struct cmd_set separator_command[] = {
- { "---------------", NULL, -1, "----------------------" },
+ { "---------------", MAX_RPC_RETURN_TYPE, NULL, NULL, -1, "----------------------" },
{ NULL }
};
@@ -458,7 +461,8 @@ static NTSTATUS do_cmd(struct cli_state *cli,
struct cmd_set *cmd_entry,
int argc, char **argv)
{
- NTSTATUS result;
+ NTSTATUS ntresult;
+ WERROR wresult;
TALLOC_CTX *mem_ctx;
@@ -477,9 +481,22 @@ static NTSTATUS do_cmd(struct cli_state *cli,
return NT_STATUS_UNSUCCESSFUL;
}
- /* Run command */
-
- result = cmd_entry->fn(cli, mem_ctx, argc, (const char **) argv);
+ /* Run command */
+
+ if ( cmd_entry->returntype == RPC_RTYPE_NTSTATUS ) {
+ ntresult = cmd_entry->ntfn(cli, mem_ctx, argc, (const char **) argv);
+ if (!NT_STATUS_IS_OK(ntresult)) {
+ printf("result was %s\n", nt_errstr(ntresult));
+ }
+ } else {
+ wresult = cmd_entry->wfn( cli, mem_ctx, argc, (const char **) argv);
+ /* print out the DOS error */
+ if (!W_ERROR_IS_OK(wresult)) {
+ printf( "result was %s\n", dos_errstr(wresult));
+ }
+ ntresult = W_ERROR_IS_OK(wresult)?NT_STATUS_OK:NT_STATUS_UNSUCCESSFUL;
+ }
+
/* Cleanup */
@@ -488,7 +505,7 @@ static NTSTATUS do_cmd(struct cli_state *cli,
talloc_destroy(mem_ctx);
- return result;
+ return ntresult;
}
@@ -517,7 +534,8 @@ static NTSTATUS process_cmd(struct cli_state *cli, char *cmd)
while (temp_set->name) {
if (strequal(argv[0], temp_set->name)) {
- if (!temp_set->fn) {
+ if (!(temp_set->returntype == RPC_RTYPE_NTSTATUS && temp_set->ntfn ) &&
+ !(temp_set->returntype == RPC_RTYPE_WERROR && temp_set->wfn )) {
fprintf (stderr, "Invalid command\n");
goto out_free;
}
@@ -535,9 +553,11 @@ static NTSTATUS process_cmd(struct cli_state *cli, char *cmd)
}
out_free:
+/* moved to do_cmd()
if (!NT_STATUS_IS_OK(result)) {
printf("result was %s\n", nt_errstr(result));
}
+*/
if (argv) {
/* NOTE: popt allocates the whole argv, including the