summaryrefslogtreecommitdiff
path: root/source3/lib/netapi
diff options
context:
space:
mode:
Diffstat (limited to 'source3/lib/netapi')
-rw-r--r--source3/lib/netapi/cm.c76
-rw-r--r--source3/lib/netapi/getdc.c9
-rw-r--r--source3/lib/netapi/group.c21
-rw-r--r--source3/lib/netapi/joindomain.c12
-rw-r--r--source3/lib/netapi/localgroup.c15
-rw-r--r--source3/lib/netapi/netapi_private.h4
-rw-r--r--source3/lib/netapi/serverinfo.c9
-rw-r--r--source3/lib/netapi/user.c15
8 files changed, 93 insertions, 68 deletions
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;
}