diff options
author | Volker Lendecke <vl@samba.org> | 2008-07-20 17:59:30 +0200 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2008-07-21 14:36:27 +0200 |
commit | 798b56edaec88206b0d61d2852af41777d53aef2 (patch) | |
tree | 562ea623ec18a357fb65485bfa731900095db88c /source3 | |
parent | 739e9cfbe0b5eff80bdcba1cf10bd5bfe6873d6a (diff) | |
download | samba-798b56edaec88206b0d61d2852af41777d53aef2.tar.gz samba-798b56edaec88206b0d61d2852af41777d53aef2.tar.bz2 samba-798b56edaec88206b0d61d2852af41777d53aef2.zip |
Refactoring: libnetapi_open_pipe takes an interface instead of pipe_idx
(This used to be commit 726e56c72fdb685ab5eddefd2fd8b043dc38d6ad)
Diffstat (limited to 'source3')
-rw-r--r-- | source3/include/proto.h | 3 | ||||
-rw-r--r-- | source3/lib/netapi/cm.c | 76 | ||||
-rw-r--r-- | source3/lib/netapi/getdc.c | 9 | ||||
-rw-r--r-- | source3/lib/netapi/group.c | 21 | ||||
-rw-r--r-- | source3/lib/netapi/joindomain.c | 12 | ||||
-rw-r--r-- | source3/lib/netapi/localgroup.c | 15 | ||||
-rw-r--r-- | source3/lib/netapi/netapi_private.h | 4 | ||||
-rw-r--r-- | source3/lib/netapi/serverinfo.c | 9 | ||||
-rw-r--r-- | source3/lib/netapi/user.c | 15 | ||||
-rw-r--r-- | source3/rpc_client/cli_pipe.c | 6 |
10 files changed, 99 insertions, 71 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 2612953051..194dda7648 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -7911,6 +7911,9 @@ bool prs_data_blob(prs_struct *prs, DATA_BLOB *blob, TALLOC_CTX *mem_ctx); /* The following definitions come from rpc_parse/parse_rpc.c */ const char *cli_get_pipe_name(int pipe_idx); +const char *cli_get_pipe_name_from_iface(TALLOC_CTX *mem_ctx, + struct cli_state *cli, + const struct ndr_syntax_id *interface); int cli_get_pipe_idx(const RPC_IFACE *syntax); const struct ndr_syntax_id *cli_get_iface(int pipe_idx); void init_rpc_hdr(RPC_HDR *hdr, enum RPC_PKT_TYPE pkt_type, uint8 flags, diff --git a/source3/lib/netapi/cm.c b/source3/lib/netapi/cm.c index fe5490c73b..8eaabb3cda 100644 --- a/source3/lib/netapi/cm.c +++ b/source3/lib/netapi/cm.c @@ -91,75 +91,70 @@ static struct client_pipe_connection *pipe_connections; /******************************************************************** ********************************************************************/ -static struct rpc_pipe_client *pipe_cm_find(struct cli_state *cli, - int pipe_idx, - NTSTATUS *status) +static NTSTATUS pipe_cm_find(struct cli_state *cli, + const struct ndr_syntax_id *interface, + struct rpc_pipe_client **presult) { struct client_pipe_connection *p; for (p = pipe_connections; p; p = p->next) { if (!rpc_pipe_np_smb_conn(p->pipe)) { - *status = NT_STATUS_PIPE_EMPTY; - return NULL; + return NT_STATUS_PIPE_EMPTY; } - if (strequal(cli->desthost, p->pipe->desthost) && - rpccli_is_pipe_idx(p->pipe, pipe_idx)) { - *status = NT_STATUS_OK; - return p->pipe; + if (strequal(cli->desthost, p->pipe->desthost) + && ndr_syntax_id_equal(&p->pipe->abstract_syntax, + interface)) { + *presult = p->pipe; + return NT_STATUS_OK; } } - *status = NT_STATUS_PIPE_NOT_AVAILABLE; - - return NULL; + return NT_STATUS_PIPE_NOT_AVAILABLE; } /******************************************************************** ********************************************************************/ -static struct rpc_pipe_client *pipe_cm_connect(TALLOC_CTX *mem_ctx, - struct cli_state *cli, - int pipe_idx, - NTSTATUS *status) +static NTSTATUS pipe_cm_connect(TALLOC_CTX *mem_ctx, + struct cli_state *cli, + const struct ndr_syntax_id *interface, + struct rpc_pipe_client **presult) { struct client_pipe_connection *p; + NTSTATUS status; p = TALLOC_ZERO_ARRAY(mem_ctx, struct client_pipe_connection, 1); if (!p) { - *status = NT_STATUS_NO_MEMORY; - return NULL; + return NT_STATUS_NO_MEMORY; } - *status = cli_rpc_pipe_open_noauth(cli, cli_get_iface(pipe_idx), - &p->pipe); - if (!NT_STATUS_IS_OK(*status)) { + status = cli_rpc_pipe_open_noauth(cli, interface, &p->pipe); + if (!NT_STATUS_IS_OK(status)) { TALLOC_FREE(p); - return NULL; + return status; } DLIST_ADD(pipe_connections, p); - return p->pipe; + *presult = p->pipe; + return NT_STATUS_OK; } /******************************************************************** ********************************************************************/ -static struct rpc_pipe_client *pipe_cm_open(TALLOC_CTX *ctx, - struct cli_state *cli, - int pipe_idx, - NTSTATUS *status) +static NTSTATUS pipe_cm_open(TALLOC_CTX *ctx, + struct cli_state *cli, + const struct ndr_syntax_id *interface, + struct rpc_pipe_client **presult) { - struct rpc_pipe_client *p; - - p = pipe_cm_find(cli, pipe_idx, status); - if (!p) { - p = pipe_cm_connect(ctx, cli, pipe_idx, status); + if (NT_STATUS_IS_OK(pipe_cm_find(cli, interface, presult))) { + return NT_STATUS_OK; } - return p; + return pipe_cm_connect(ctx, cli, interface, presult); } /******************************************************************** @@ -167,23 +162,26 @@ static struct rpc_pipe_client *pipe_cm_open(TALLOC_CTX *ctx, WERROR libnetapi_open_pipe(struct libnetapi_ctx *ctx, struct cli_state *cli, - int pipe_idx, - struct rpc_pipe_client **pipe_cli) + const struct ndr_syntax_id *interface, + struct rpc_pipe_client **presult) { + struct rpc_pipe_client *result; NTSTATUS status; - if (!cli || !pipe_cli) { + if (!cli || !presult) { return WERR_INVALID_PARAM; } - *pipe_cli = pipe_cm_open(ctx, cli, pipe_idx, &status); - if (!*pipe_cli) { + status = pipe_cm_open(ctx, cli, interface, &result); + if (!NT_STATUS_IS_OK(status)) { libnetapi_set_error_string(ctx, "failed to open PIPE %s: %s", - cli_get_pipe_name(pipe_idx), + cli_get_pipe_name_from_iface(debug_ctx(), cli, + interface), get_friendly_nt_error_msg(status)); return WERR_DEST_NOT_FOUND; } + *presult = result; return WERR_OK; } diff --git a/source3/lib/netapi/getdc.c b/source3/lib/netapi/getdc.c index c1d021b1d4..4636042431 100644 --- a/source3/lib/netapi/getdc.c +++ b/source3/lib/netapi/getdc.c @@ -50,7 +50,8 @@ WERROR NetGetDCName_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_NETLOGON, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_netlogon.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -90,7 +91,8 @@ WERROR NetGetAnyDCName_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_NETLOGON, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_netlogon.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -149,7 +151,8 @@ WERROR DsGetDcName_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_NETLOGON, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_netlogon.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } diff --git a/source3/lib/netapi/group.c b/source3/lib/netapi/group.c index 15580b3c22..04ffb7c807 100644 --- a/source3/lib/netapi/group.c +++ b/source3/lib/netapi/group.c @@ -76,7 +76,8 @@ WERROR NetGroupAdd_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_SAMR, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_samr.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -255,7 +256,8 @@ WERROR NetGroupDel_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_SAMR, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_samr.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -428,7 +430,8 @@ WERROR NetGroupSetInfo_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_SAMR, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_samr.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -671,7 +674,8 @@ WERROR NetGroupGetInfo_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_SAMR, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_samr.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -795,7 +799,8 @@ WERROR NetGroupAddUser_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_SAMR, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_samr.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -924,7 +929,8 @@ WERROR NetGroupDelUser_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_SAMR, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_samr.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -1210,7 +1216,8 @@ WERROR NetGroupEnum_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_SAMR, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_samr.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } diff --git a/source3/lib/netapi/joindomain.c b/source3/lib/netapi/joindomain.c index a33e0eeee5..8d5202f07e 100644 --- a/source3/lib/netapi/joindomain.c +++ b/source3/lib/netapi/joindomain.c @@ -110,7 +110,8 @@ WERROR NetJoinDomain_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_WKSSVC, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_wkssvc.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -241,7 +242,8 @@ WERROR NetUnjoinDomain_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_WKSSVC, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_wkssvc.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -293,7 +295,8 @@ WERROR NetGetJoinInformation_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_WKSSVC, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_wkssvc.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -427,7 +430,8 @@ WERROR NetGetJoinableOUs_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_WKSSVC, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_wkssvc.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } diff --git a/source3/lib/netapi/localgroup.c b/source3/lib/netapi/localgroup.c index faf57cc5fa..fe36d86b05 100644 --- a/source3/lib/netapi/localgroup.c +++ b/source3/lib/netapi/localgroup.c @@ -166,7 +166,8 @@ WERROR NetLocalGroupAdd_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_SAMR, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_samr.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -293,7 +294,8 @@ WERROR NetLocalGroupDel_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_SAMR, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_samr.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -472,7 +474,8 @@ WERROR NetLocalGroupGetInfo_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_SAMR, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_samr.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -650,7 +653,8 @@ WERROR NetLocalGroupSetInfo_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_SAMR, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_samr.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -792,7 +796,8 @@ WERROR NetLocalGroupEnum_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_SAMR, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_samr.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } diff --git a/source3/lib/netapi/netapi_private.h b/source3/lib/netapi/netapi_private.h index 915d60617f..ef6e7cf2b7 100644 --- a/source3/lib/netapi/netapi_private.h +++ b/source3/lib/netapi/netapi_private.h @@ -49,8 +49,8 @@ WERROR libnetapi_open_ipc_connection(struct libnetapi_ctx *ctx, WERROR libnetapi_shutdown_cm(struct libnetapi_ctx *ctx); WERROR libnetapi_open_pipe(struct libnetapi_ctx *ctx, struct cli_state *cli, - int pipe_idx, - struct rpc_pipe_client **pipe_cli); + const struct ndr_syntax_id *interface, + struct rpc_pipe_client **presult); WERROR libnetapi_samr_open_domain(struct libnetapi_ctx *mem_ctx, struct rpc_pipe_client *pipe_cli, uint32_t connect_mask, diff --git a/source3/lib/netapi/serverinfo.c b/source3/lib/netapi/serverinfo.c index 7920bc29d0..a591d3753a 100644 --- a/source3/lib/netapi/serverinfo.c +++ b/source3/lib/netapi/serverinfo.c @@ -75,7 +75,8 @@ WERROR NetServerGetInfo_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_SRVSVC, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_srvsvc.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -175,7 +176,8 @@ WERROR NetServerSetInfo_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_SRVSVC, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_srvsvc.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -221,7 +223,8 @@ WERROR NetRemoteTOD_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_SRVSVC, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_srvsvc.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } diff --git a/source3/lib/netapi/user.c b/source3/lib/netapi/user.c index 8d69536848..f896dde3aa 100644 --- a/source3/lib/netapi/user.c +++ b/source3/lib/netapi/user.c @@ -170,7 +170,8 @@ WERROR NetUserAdd_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_SAMR, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_samr.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -333,7 +334,8 @@ WERROR NetUserDel_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_SAMR, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_samr.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -709,7 +711,8 @@ WERROR NetUserEnum_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_SAMR, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_samr.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -1001,7 +1004,8 @@ WERROR NetQueryDisplayInformation_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_SAMR, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_samr.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } @@ -1128,7 +1132,8 @@ WERROR NetUserGetInfo_r(struct libnetapi_ctx *ctx, goto done; } - werr = libnetapi_open_pipe(ctx, cli, PI_SAMR, &pipe_cli); + werr = libnetapi_open_pipe(ctx, cli, &ndr_table_samr.syntax_id, + &pipe_cli); if (!W_ERROR_IS_OK(werr)) { goto done; } diff --git a/source3/rpc_client/cli_pipe.c b/source3/rpc_client/cli_pipe.c index b5a188ed76..6f132a6431 100644 --- a/source3/rpc_client/cli_pipe.c +++ b/source3/rpc_client/cli_pipe.c @@ -86,9 +86,9 @@ const char *cli_get_pipe_name(int pipe_idx) return &pipe_names[pipe_idx].client_pipe[5]; } -static const char *cli_get_pipe_name_from_iface(TALLOC_CTX *mem_ctx, - struct cli_state *cli, - const struct ndr_syntax_id *interface) +const char *cli_get_pipe_name_from_iface(TALLOC_CTX *mem_ctx, + struct cli_state *cli, + const struct ndr_syntax_id *interface) { int i; for (i = 0; pipe_names[i].client_pipe; i++) { |