summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2011-01-12 12:51:07 +0100
committerAndreas Schneider <asn@samba.org>2011-01-13 14:11:16 +0100
commit1ef94dffe6e0b86e0ff30f7d37dc81fc251f6d95 (patch)
tree7e00bc1bfa995453e4c5aad866a7b80e23f121fd
parentaa4efa154f9f7b2d152a99f822c3970f3b736705 (diff)
downloadsamba-1ef94dffe6e0b86e0ff30f7d37dc81fc251f6d95.tar.gz
samba-1ef94dffe6e0b86e0ff30f7d37dc81fc251f6d95.tar.bz2
samba-1ef94dffe6e0b86e0ff30f7d37dc81fc251f6d95.zip
s3-libnetapi: prefer dcerpc_srvsvc_X functions.
Guenther Signed-off-by: Andreas Schneider <asn@samba.org>
-rw-r--r--source3/lib/netapi/file.c29
-rw-r--r--source3/lib/netapi/serverinfo.c25
-rw-r--r--source3/lib/netapi/share.c47
3 files changed, 86 insertions, 15 deletions
diff --git a/source3/lib/netapi/file.c b/source3/lib/netapi/file.c
index 6d76be0500..a8342ac1e4 100644
--- a/source3/lib/netapi/file.c
+++ b/source3/lib/netapi/file.c
@@ -23,7 +23,7 @@
#include "lib/netapi/netapi.h"
#include "lib/netapi/netapi_private.h"
#include "lib/netapi/libnetapi.h"
-#include "../librpc/gen_ndr/cli_srvsvc.h"
+#include "../librpc/gen_ndr/ndr_srvsvc_c.h"
/****************************************************************
****************************************************************/
@@ -34,6 +34,7 @@ WERROR NetFileClose_r(struct libnetapi_ctx *ctx,
WERROR werr;
NTSTATUS status;
struct rpc_pipe_client *pipe_cli = NULL;
+ struct dcerpc_binding_handle *b;
werr = libnetapi_open_pipe(ctx, r->in.server_name,
&ndr_table_srvsvc.syntax_id,
@@ -42,7 +43,9 @@ WERROR NetFileClose_r(struct libnetapi_ctx *ctx,
goto done;
}
- status = rpccli_srvsvc_NetFileClose(pipe_cli, talloc_tos(),
+ b = pipe_cli->binding_handle;
+
+ status = dcerpc_srvsvc_NetFileClose(b, talloc_tos(),
r->in.server_name,
r->in.fileid,
&werr);
@@ -116,6 +119,7 @@ WERROR NetFileGetInfo_r(struct libnetapi_ctx *ctx,
struct rpc_pipe_client *pipe_cli = NULL;
union srvsvc_NetFileInfo info;
uint32_t num_entries = 0;
+ struct dcerpc_binding_handle *b;
if (!r->out.buffer) {
return WERR_INVALID_PARAM;
@@ -136,12 +140,19 @@ WERROR NetFileGetInfo_r(struct libnetapi_ctx *ctx,
goto done;
}
- status = rpccli_srvsvc_NetFileGetInfo(pipe_cli, talloc_tos(),
+ b = pipe_cli->binding_handle;
+
+ status = dcerpc_srvsvc_NetFileGetInfo(b, talloc_tos(),
r->in.server_name,
r->in.fileid,
r->in.level,
&info,
&werr);
+ if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
+ goto done;
+ }
+
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -182,6 +193,7 @@ WERROR NetFileEnum_r(struct libnetapi_ctx *ctx,
struct srvsvc_NetFileCtr3 ctr3;
uint32_t num_entries = 0;
uint32_t i;
+ struct dcerpc_binding_handle *b;
if (!r->out.buffer) {
return WERR_INVALID_PARAM;
@@ -202,6 +214,8 @@ WERROR NetFileEnum_r(struct libnetapi_ctx *ctx,
goto done;
}
+ b = pipe_cli->binding_handle;
+
ZERO_STRUCT(info_ctr);
info_ctr.level = r->in.level;
@@ -216,7 +230,7 @@ WERROR NetFileEnum_r(struct libnetapi_ctx *ctx,
break;
}
- status = rpccli_srvsvc_NetFileEnum(pipe_cli, talloc_tos(),
+ status = dcerpc_srvsvc_NetFileEnum(b, talloc_tos(),
r->in.server_name,
r->in.base_path,
r->in.user_name,
@@ -225,7 +239,12 @@ WERROR NetFileEnum_r(struct libnetapi_ctx *ctx,
r->out.total_entries,
r->out.resume_handle,
&werr);
- if (NT_STATUS_IS_ERR(status)) {
+ if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
+ goto done;
+ }
+
+ if (!W_ERROR_IS_OK(werr) && !W_ERROR_EQUAL(werr, WERR_MORE_DATA)) {
goto done;
}
diff --git a/source3/lib/netapi/serverinfo.c b/source3/lib/netapi/serverinfo.c
index 83b749877e..6de97b9de4 100644
--- a/source3/lib/netapi/serverinfo.c
+++ b/source3/lib/netapi/serverinfo.c
@@ -23,7 +23,7 @@
#include "lib/netapi/netapi.h"
#include "lib/netapi/netapi_private.h"
#include "lib/netapi/libnetapi.h"
-#include "../librpc/gen_ndr/cli_srvsvc.h"
+#include "../librpc/gen_ndr/ndr_srvsvc_c.h"
#include "lib/smbconf/smbconf.h"
#include "lib/smbconf/smbconf_reg.h"
@@ -484,6 +484,7 @@ WERROR NetServerGetInfo_r(struct libnetapi_ctx *ctx,
NTSTATUS status;
WERROR werr;
union srvsvc_NetSrvInfo info;
+ struct dcerpc_binding_handle *b;
if (!r->out.buffer) {
return WERR_INVALID_PARAM;
@@ -509,7 +510,9 @@ WERROR NetServerGetInfo_r(struct libnetapi_ctx *ctx,
goto done;
}
- status = rpccli_srvsvc_NetSrvGetInfo(pipe_cli, talloc_tos(),
+ b = pipe_cli->binding_handle;
+
+ status = dcerpc_srvsvc_NetSrvGetInfo(b, talloc_tos(),
r->in.server_name,
r->in.level,
&info,
@@ -519,6 +522,10 @@ WERROR NetServerGetInfo_r(struct libnetapi_ctx *ctx,
goto done;
}
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
+
status = map_server_info_to_SERVER_INFO_buffer(ctx, r->in.level, &info,
r->out.buffer);
if (!NT_STATUS_IS_OK(status)) {
@@ -598,6 +605,7 @@ WERROR NetServerSetInfo_r(struct libnetapi_ctx *ctx,
NTSTATUS status;
WERROR werr;
union srvsvc_NetSrvInfo info;
+ struct dcerpc_binding_handle *b;
werr = libnetapi_open_pipe(ctx, r->in.server_name,
&ndr_table_srvsvc.syntax_id,
@@ -606,6 +614,8 @@ WERROR NetServerSetInfo_r(struct libnetapi_ctx *ctx,
goto done;
}
+ b = pipe_cli->binding_handle;
+
switch (r->in.level) {
case 1005:
info.info1005 = (struct srvsvc_NetSrvInfo1005 *)r->in.buffer;
@@ -615,7 +625,7 @@ WERROR NetServerSetInfo_r(struct libnetapi_ctx *ctx,
goto done;
}
- status = rpccli_srvsvc_NetSrvSetInfo(pipe_cli, talloc_tos(),
+ status = dcerpc_srvsvc_NetSrvSetInfo(b, talloc_tos(),
r->in.server_name,
r->in.level,
&info,
@@ -640,6 +650,7 @@ WERROR NetRemoteTOD_r(struct libnetapi_ctx *ctx,
NTSTATUS status;
WERROR werr;
struct srvsvc_NetRemoteTODInfo *info = NULL;
+ struct dcerpc_binding_handle *b;
werr = libnetapi_open_pipe(ctx, r->in.server_name,
&ndr_table_srvsvc.syntax_id,
@@ -648,7 +659,9 @@ WERROR NetRemoteTOD_r(struct libnetapi_ctx *ctx,
goto done;
}
- status = rpccli_srvsvc_NetRemoteTOD(pipe_cli, talloc_tos(),
+ b = pipe_cli->binding_handle;
+
+ status = dcerpc_srvsvc_NetRemoteTOD(b, talloc_tos(),
r->in.server_name,
&info,
&werr);
@@ -657,6 +670,10 @@ WERROR NetRemoteTOD_r(struct libnetapi_ctx *ctx,
goto done;
}
+ if (!W_ERROR_IS_OK(werr)) {
+ goto done;
+ }
+
*r->out.buffer = (uint8_t *)talloc_memdup(ctx, info,
sizeof(struct srvsvc_NetRemoteTODInfo));
W_ERROR_HAVE_NO_MEMORY(*r->out.buffer);
diff --git a/source3/lib/netapi/share.c b/source3/lib/netapi/share.c
index 4232a9e7c0..c9c6d147e2 100644
--- a/source3/lib/netapi/share.c
+++ b/source3/lib/netapi/share.c
@@ -184,6 +184,7 @@ WERROR NetShareAdd_r(struct libnetapi_ctx *ctx,
NTSTATUS status;
struct rpc_pipe_client *pipe_cli = NULL;
union srvsvc_NetShareInfo info;
+ struct dcerpc_binding_handle *b;
if (!r->in.buffer) {
return WERR_INVALID_PARAM;
@@ -206,6 +207,8 @@ WERROR NetShareAdd_r(struct libnetapi_ctx *ctx,
goto done;
}
+ b = pipe_cli->binding_handle;
+
status = map_SHARE_INFO_buffer_to_srvsvc_share_info(ctx,
r->in.buffer,
r->in.level,
@@ -215,12 +218,17 @@ WERROR NetShareAdd_r(struct libnetapi_ctx *ctx,
goto done;
}
- status = rpccli_srvsvc_NetShareAdd(pipe_cli, talloc_tos(),
+ status = dcerpc_srvsvc_NetShareAdd(b, talloc_tos(),
r->in.server_name,
r->in.level,
&info,
r->out.parm_err,
&werr);
+ if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
+ goto done;
+ }
+
if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -247,6 +255,7 @@ WERROR NetShareDel_r(struct libnetapi_ctx *ctx,
WERROR werr;
NTSTATUS status;
struct rpc_pipe_client *pipe_cli = NULL;
+ struct dcerpc_binding_handle *b;
if (!r->in.net_name) {
return WERR_INVALID_PARAM;
@@ -259,7 +268,9 @@ WERROR NetShareDel_r(struct libnetapi_ctx *ctx,
goto done;
}
- status = rpccli_srvsvc_NetShareDel(pipe_cli, talloc_tos(),
+ b = pipe_cli->binding_handle;
+
+ status = dcerpc_srvsvc_NetShareDel(b, talloc_tos(),
r->in.server_name,
r->in.net_name,
r->in.reserved,
@@ -296,6 +307,7 @@ WERROR NetShareEnum_r(struct libnetapi_ctx *ctx,
struct srvsvc_NetShareCtr1 ctr1;
struct srvsvc_NetShareCtr2 ctr2;
uint32_t i;
+ struct dcerpc_binding_handle *b;
if (!r->out.buffer) {
return WERR_INVALID_PARAM;
@@ -322,6 +334,8 @@ WERROR NetShareEnum_r(struct libnetapi_ctx *ctx,
goto done;
}
+ b = pipe_cli->binding_handle;
+
info_ctr.level = r->in.level;
switch (r->in.level) {
case 0:
@@ -338,14 +352,19 @@ WERROR NetShareEnum_r(struct libnetapi_ctx *ctx,
break;
}
- status = rpccli_srvsvc_NetShareEnumAll(pipe_cli, talloc_tos(),
+ status = dcerpc_srvsvc_NetShareEnumAll(b, talloc_tos(),
r->in.server_name,
&info_ctr,
r->in.prefmaxlen,
r->out.total_entries,
r->out.resume_handle,
&werr);
- if (NT_STATUS_IS_ERR(status)) {
+ if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
+ goto done;
+ }
+
+ if (!W_ERROR_IS_OK(werr) && !W_ERROR_EQUAL(werr, WERR_MORE_DATA)) {
goto done;
}
@@ -370,6 +389,7 @@ WERROR NetShareEnum_r(struct libnetapi_ctx *ctx,
r->out.entries_read);
if (!NT_STATUS_IS_OK(status)) {
werr = ntstatus_to_werror(status);
+ goto done;
}
}
@@ -397,6 +417,7 @@ WERROR NetShareGetInfo_r(struct libnetapi_ctx *ctx,
struct rpc_pipe_client *pipe_cli = NULL;
union srvsvc_NetShareInfo info;
uint32_t num_entries = 0;
+ struct dcerpc_binding_handle *b;
if (!r->in.net_name || !r->out.buffer) {
return WERR_INVALID_PARAM;
@@ -423,12 +444,18 @@ WERROR NetShareGetInfo_r(struct libnetapi_ctx *ctx,
goto done;
}
- status = rpccli_srvsvc_NetShareGetInfo(pipe_cli, talloc_tos(),
+ b = pipe_cli->binding_handle;
+
+ status = dcerpc_srvsvc_NetShareGetInfo(b, talloc_tos(),
r->in.server_name,
r->in.net_name,
r->in.level,
&info,
&werr);
+ if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
+ goto done;
+ }
if (!W_ERROR_IS_OK(werr)) {
goto done;
@@ -466,6 +493,7 @@ WERROR NetShareSetInfo_r(struct libnetapi_ctx *ctx,
NTSTATUS status;
struct rpc_pipe_client *pipe_cli = NULL;
union srvsvc_NetShareInfo info;
+ struct dcerpc_binding_handle *b;
if (!r->in.buffer) {
return WERR_INVALID_PARAM;
@@ -493,6 +521,8 @@ WERROR NetShareSetInfo_r(struct libnetapi_ctx *ctx,
goto done;
}
+ b = pipe_cli->binding_handle;
+
status = map_SHARE_INFO_buffer_to_srvsvc_share_info(ctx,
r->in.buffer,
r->in.level,
@@ -502,13 +532,18 @@ WERROR NetShareSetInfo_r(struct libnetapi_ctx *ctx,
goto done;
}
- status = rpccli_srvsvc_NetShareSetInfo(pipe_cli, talloc_tos(),
+ status = dcerpc_srvsvc_NetShareSetInfo(b, talloc_tos(),
r->in.server_name,
r->in.net_name,
r->in.level,
&info,
r->out.parm_err,
&werr);
+ if (!NT_STATUS_IS_OK(status)) {
+ werr = ntstatus_to_werror(status);
+ goto done;
+ }
+
if (!W_ERROR_IS_OK(werr)) {
goto done;
}