Skip to content

Commit

Permalink
rpcclient: Add RPC_RTYPE_BINDING
Browse files Browse the repository at this point in the history
Purely transport-related commands don't need the cli_state.

Signed-off-by: Volker Lendecke <[email protected]>
Reviewed-by: Jeremy Allison <[email protected]>
  • Loading branch information
vlendec authored and jrasamba committed Mar 16, 2021
1 parent cf2a943 commit e856402
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 8 additions & 1 deletion source3/rpcclient/rpcclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,11 @@ static NTSTATUS do_cmd(struct cli_state *cli,
if (!NT_STATUS_IS_OK(ntresult)) {
printf("result was %s\n", nt_errstr(ntresult));
}
} else if (cmd_entry->returntype == RPC_RTYPE_BINDING) {
ntresult = cmd_entry->bfn(binding, mem_ctx, argc, argv);
if (!NT_STATUS_IS_OK(ntresult)) {
printf("result was %s\n", nt_errstr(ntresult));
}
} else {
wresult = cmd_entry->wfn(cmd_entry->rpc_pipe, mem_ctx, argc, argv);
/* print out the DOS error */
Expand Down Expand Up @@ -922,7 +927,9 @@ static NTSTATUS process_cmd(struct user_auth_info *auth_info,
if (((set->returntype == RPC_RTYPE_NTSTATUS) &&
(set->ntfn == NULL)) ||
((set->returntype == RPC_RTYPE_WERROR) &&
(set->wfn == NULL))) {
(set->wfn == NULL)) ||
((set->returntype == RPC_RTYPE_BINDING) &&
(set->bfn == NULL))) {
fprintf (stderr, "Invalid command\n");
goto out_free;
}
Expand Down
5 changes: 5 additions & 0 deletions source3/rpcclient/rpcclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
typedef enum {
RPC_RTYPE_NTSTATUS = 0,
RPC_RTYPE_WERROR,
RPC_RTYPE_BINDING,
MAX_RPC_RETURN_TYPE
} RPC_RETURN_TYPE;

Expand All @@ -35,6 +36,10 @@ struct cmd_set {
NTSTATUS (*ntfn)(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc,
const char **argv);
WERROR (*wfn)(struct rpc_pipe_client *cli, TALLOC_CTX *mem_ctx, int argc, const char **argv);
NTSTATUS (*bfn)(struct dcerpc_binding *binding,
TALLOC_CTX *mem_ctx,
int argc,
const char **argv);
const struct ndr_interface_table *table;
struct rpc_pipe_client *rpc_pipe;
const char *description;
Expand Down

0 comments on commit e856402

Please sign in to comment.