[SCM] Samba Shared Repository - branch v3-2-test updated -
release-3-2-0pre2-803-gd9f19fc
Günther Deschner
gd at samba.org
Thu Apr 10 20:06:00 GMT 2008
The branch, v3-2-test has been updated
via d9f19fc61586d606393368799dee9757c169d602 (commit)
from d34c3e8ad2b21051162e2a9d65f773c486c43d8b (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test
- Log -----------------------------------------------------------------
commit d9f19fc61586d606393368799dee9757c169d602
Author: Günther Deschner <gd at samba.org>
Date: Thu Apr 10 22:04:04 2008 +0200
Use libnetapi_open_ipc_connection in libnetapi.
Guenther
-----------------------------------------------------------------------
Summary of changes:
source/lib/netapi/getdc.c | 55 ++++-----------------------------
source/lib/netapi/joindomain.c | 66 +++++++---------------------------------
source/lib/netapi/netapi.c | 2 +
source/lib/netapi/serverinfo.c | 36 ++-------------------
source/lib/netapi/user.c | 54 ++++++--------------------------
5 files changed, 33 insertions(+), 180 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source/lib/netapi/getdc.c b/source/lib/netapi/getdc.c
index 944cfb2..8f88294 100644
--- a/source/lib/netapi/getdc.c
+++ b/source/lib/netapi/getdc.c
@@ -45,19 +45,8 @@ WERROR NetGetDCName_r(struct libnetapi_ctx *ctx,
NTSTATUS status;
WERROR werr;
- status = cli_full_connection(&cli, NULL, r->in.server_name,
- NULL, 0,
- "IPC$", "IPC",
- ctx->username,
- ctx->workgroup,
- ctx->password,
- CLI_FULL_CONNECTION_USE_KERBEROS |
- CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS |
- CLI_FULL_CONNECTION_ANONYMOUS_FALLBACK,
- Undefined, NULL);
-
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_open_ipc_connection(ctx, r->in.server_name, &cli);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -74,9 +63,6 @@ WERROR NetGetDCName_r(struct libnetapi_ctx *ctx,
(const char **)r->out.buffer,
&werr);
done:
- if (cli) {
- cli_shutdown(cli);
- }
return werr;
}
@@ -101,19 +87,8 @@ WERROR NetGetAnyDCName_r(struct libnetapi_ctx *ctx,
NTSTATUS status;
WERROR werr;
- status = cli_full_connection(&cli, NULL, r->in.server_name,
- NULL, 0,
- "IPC$", "IPC",
- ctx->username,
- ctx->workgroup,
- ctx->password,
- CLI_FULL_CONNECTION_USE_KERBEROS |
- CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS |
- CLI_FULL_CONNECTION_ANONYMOUS_FALLBACK,
- Undefined, NULL);
-
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_open_ipc_connection(ctx, r->in.server_name, &cli);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -133,9 +108,6 @@ WERROR NetGetAnyDCName_r(struct libnetapi_ctx *ctx,
goto done;
}
done:
- if (cli) {
- cli_shutdown(cli);
- }
return werr;
@@ -175,19 +147,8 @@ WERROR DsGetDcName_r(struct libnetapi_ctx *ctx,
struct cli_state *cli = NULL;
struct rpc_pipe_client *pipe_cli = NULL;
- status = cli_full_connection(&cli, NULL, r->in.server_name,
- NULL, 0,
- "IPC$", "IPC",
- ctx->username,
- ctx->workgroup,
- ctx->password,
- CLI_FULL_CONNECTION_USE_KERBEROS |
- CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS |
- CLI_FULL_CONNECTION_ANONYMOUS_FALLBACK,
- Undefined, NULL);
-
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_open_ipc_connection(ctx, r->in.server_name, &cli);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -213,9 +174,5 @@ WERROR DsGetDcName_r(struct libnetapi_ctx *ctx,
}
done:
- if (cli) {
- cli_shutdown(cli);
- }
-
return werr;
}
diff --git a/source/lib/netapi/joindomain.c b/source/lib/netapi/joindomain.c
index 96c2f3d..056d8d2 100644
--- a/source/lib/netapi/joindomain.c
+++ b/source/lib/netapi/joindomain.c
@@ -103,18 +103,8 @@ WERROR NetJoinDomain_r(struct libnetapi_ctx *ctx,
WERROR werr;
unsigned int old_timeout = 0;
- status = cli_full_connection(&cli, NULL, r->in.server,
- NULL, 0,
- "IPC$", "IPC",
- ctx->username,
- ctx->workgroup,
- ctx->password,
- CLI_FULL_CONNECTION_USE_KERBEROS |
- CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS,
- Undefined, NULL);
-
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_open_ipc_connection(ctx, r->in.server, &cli);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -152,7 +142,6 @@ WERROR NetJoinDomain_r(struct libnetapi_ctx *ctx,
if (old_timeout) {
cli_set_timeout(cli, old_timeout);
}
- cli_shutdown(cli);
}
return werr;
@@ -245,18 +234,8 @@ WERROR NetUnjoinDomain_r(struct libnetapi_ctx *ctx,
WERROR werr;
unsigned int old_timeout = 0;
- status = cli_full_connection(&cli, NULL, r->in.server_name,
- NULL, 0,
- "IPC$", "IPC",
- ctx->username,
- ctx->workgroup,
- ctx->password,
- CLI_FULL_CONNECTION_USE_KERBEROS |
- CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS,
- Undefined, NULL);
-
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_open_ipc_connection(ctx, r->in.server_name, &cli);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -289,8 +268,9 @@ WERROR NetUnjoinDomain_r(struct libnetapi_ctx *ctx,
done:
if (cli) {
- cli_set_timeout(cli, old_timeout);
- cli_shutdown(cli);
+ if (old_timeout) {
+ cli_set_timeout(cli, old_timeout);
+ }
}
return werr;
@@ -307,18 +287,8 @@ WERROR NetGetJoinInformation_r(struct libnetapi_ctx *ctx,
NTSTATUS status;
WERROR werr;
- status = cli_full_connection(&cli, NULL, r->in.server_name,
- NULL, 0,
- "IPC$", "IPC",
- ctx->username,
- ctx->workgroup,
- ctx->password,
- CLI_FULL_CONNECTION_USE_KERBEROS |
- CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS,
- Undefined, NULL);
-
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_open_ipc_connection(ctx, r->in.server_name, &cli);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -340,10 +310,6 @@ WERROR NetGetJoinInformation_r(struct libnetapi_ctx *ctx,
}
done:
- if (cli) {
- cli_shutdown(cli);
- }
-
return werr;
}
@@ -451,18 +417,8 @@ WERROR NetGetJoinableOUs_r(struct libnetapi_ctx *ctx,
NTSTATUS status;
WERROR werr;
- status = cli_full_connection(&cli, NULL, r->in.server_name,
- NULL, 0,
- "IPC$", "IPC",
- ctx->username,
- ctx->workgroup,
- ctx->password,
- CLI_FULL_CONNECTION_USE_KERBEROS |
- CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS,
- Undefined, NULL);
-
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_open_ipc_connection(ctx, r->in.server_name, &cli);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
diff --git a/source/lib/netapi/netapi.c b/source/lib/netapi/netapi.c
index fbec275..2478a8d 100644
--- a/source/lib/netapi/netapi.c
+++ b/source/lib/netapi/netapi.c
@@ -19,6 +19,7 @@
#include "includes.h"
#include "lib/netapi/netapi.h"
+#include "lib/netapi/netapi_private.h"
extern bool AllowDebugChange;
@@ -113,6 +114,7 @@ NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx)
NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx)
{
+ libnetapi_shutdown_cm(ctx);
if (ctx->krb5_cc_env) {
char *env = getenv(KRB5_ENV_CCNAME);
diff --git a/source/lib/netapi/serverinfo.c b/source/lib/netapi/serverinfo.c
index fb5d940..238b9ca 100644
--- a/source/lib/netapi/serverinfo.c
+++ b/source/lib/netapi/serverinfo.c
@@ -70,18 +70,8 @@ WERROR NetServerGetInfo_r(struct libnetapi_ctx *ctx,
WERROR werr;
union srvsvc_NetSrvInfo info;
- status = cli_full_connection(&cli, NULL, r->in.server_name,
- NULL, 0,
- "IPC$", "IPC",
- ctx->username,
- ctx->workgroup,
- ctx->password,
- CLI_FULL_CONNECTION_USE_KERBEROS |
- CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS,
- Undefined, NULL);
-
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_open_ipc_connection(ctx, r->in.server_name, &cli);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -109,10 +99,6 @@ WERROR NetServerGetInfo_r(struct libnetapi_ctx *ctx,
}
done:
- if (cli) {
- cli_shutdown(cli);
- }
-
return werr;
}
@@ -186,18 +172,8 @@ WERROR NetServerSetInfo_r(struct libnetapi_ctx *ctx,
WERROR werr;
union srvsvc_NetSrvInfo info;
- status = cli_full_connection(&cli, NULL, r->in.server_name,
- NULL, 0,
- "IPC$", "IPC",
- ctx->username,
- ctx->workgroup,
- ctx->password,
- CLI_FULL_CONNECTION_USE_KERBEROS |
- CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS,
- Undefined, NULL);
-
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_open_ipc_connection(ctx, r->in.server_name, &cli);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -229,9 +205,5 @@ WERROR NetServerSetInfo_r(struct libnetapi_ctx *ctx,
}
done:
- if (cli) {
- cli_shutdown(cli);
- }
-
return werr;
}
diff --git a/source/lib/netapi/user.c b/source/lib/netapi/user.c
index 54157a8..d9505bc 100644
--- a/source/lib/netapi/user.c
+++ b/source/lib/netapi/user.c
@@ -180,18 +180,8 @@ WERROR NetUserAdd_r(struct libnetapi_ctx *ctx,
goto done;
}
- status = cli_full_connection(&cli, NULL, r->in.server_name,
- NULL, 0,
- "IPC$", "IPC",
- ctx->username,
- ctx->workgroup,
- ctx->password,
- CLI_FULL_CONNECTION_USE_KERBEROS |
- CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS,
- Undefined, NULL);
-
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_open_ipc_connection(ctx, r->in.server_name, &cli);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -353,8 +343,6 @@ WERROR NetUserAdd_r(struct libnetapi_ctx *ctx,
rpccli_samr_Close(pipe_cli, ctx, &connect_handle);
}
- cli_shutdown(cli);
-
return werr;
}
@@ -385,18 +373,8 @@ WERROR NetUserDel_r(struct libnetapi_ctx *ctx,
ZERO_STRUCT(domain_handle);
ZERO_STRUCT(user_handle);
- status = cli_full_connection(&cli, NULL, r->in.server_name,
- NULL, 0,
- "IPC$", "IPC",
- ctx->username,
- ctx->workgroup,
- ctx->password,
- CLI_FULL_CONNECTION_USE_KERBEROS |
- CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS,
- Undefined, NULL);
-
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_open_ipc_connection(ctx, r->in.server_name, &cli);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -534,8 +512,6 @@ WERROR NetUserDel_r(struct libnetapi_ctx *ctx,
rpccli_samr_Close(pipe_cli, ctx, &connect_handle);
}
- cli_shutdown(cli);
-
return werr;
}
@@ -621,18 +597,8 @@ WERROR NetUserEnum_r(struct libnetapi_ctx *ctx,
return WERR_NOT_SUPPORTED;
}
- status = cli_full_connection(&cli, NULL, r->in.server_name,
- NULL, 0,
- "IPC$", "IPC",
- ctx->username,
- ctx->workgroup,
- ctx->password,
- CLI_FULL_CONNECTION_USE_KERBEROS |
- CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS,
- Undefined, NULL);
-
- if (!NT_STATUS_IS_OK(status)) {
- werr = ntstatus_to_werror(status);
+ werr = libnetapi_open_ipc_connection(ctx, r->in.server_name, &cli);
+ if (!W_ERROR_IS_OK(werr)) {
goto done;
}
@@ -721,6 +687,10 @@ WERROR NetUserEnum_r(struct libnetapi_ctx *ctx,
r->out.buffer);
done:
+ if (!cli) {
+ return werr;
+ }
+
if (is_valid_policy_hnd(&domain_handle)) {
rpccli_samr_Close(pipe_cli, ctx, &domain_handle);
}
@@ -728,10 +698,6 @@ WERROR NetUserEnum_r(struct libnetapi_ctx *ctx,
rpccli_samr_Close(pipe_cli, ctx, &connect_handle);
}
- if (cli) {
- cli_shutdown(cli);
- }
-
return werr;
}
--
Samba Shared Repository
More information about the samba-cvs
mailing list