summaryrefslogtreecommitdiff
path: root/source3/libnet
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2008-06-23 17:29:01 +0200
committerGünther Deschner <gd@samba.org>2008-06-23 23:38:53 +0200
commit48a680ecf2a00169066c6e6c84ec3fecc3245dbd (patch)
treec2e7bf3a887f2846f7ba1b95ed4d00a45cdfcb04 /source3/libnet
parent8725626ec8b2b2a11b2c0bb5e7010f229d552b5e (diff)
downloadsamba-48a680ecf2a00169066c6e6c84ec3fecc3245dbd.tar.gz
samba-48a680ecf2a00169066c6e6c84ec3fecc3245dbd.tar.bz2
samba-48a680ecf2a00169066c6e6c84ec3fecc3245dbd.zip
net_vampire: more libnet_samsync restructuring.
Guenther (This used to be commit 3bcda522f025aff249678a8a086218679fc19c6b)
Diffstat (limited to 'source3/libnet')
-rw-r--r--source3/libnet/libnet_proto.h6
-rw-r--r--source3/libnet/libnet_samsync.c24
-rw-r--r--source3/libnet/libnet_samsync.h16
3 files changed, 19 insertions, 27 deletions
diff --git a/source3/libnet/libnet_proto.h b/source3/libnet/libnet_proto.h
index ba73a3e8bc..2440cd3c7f 100644
--- a/source3/libnet/libnet_proto.h
+++ b/source3/libnet/libnet_proto.h
@@ -47,12 +47,8 @@ _PUBLIC_ void ndr_print_libnet_UnjoinCtx(struct ndr_print *ndr, const char *name
NTSTATUS libnet_samsync_init_context(TALLOC_CTX *mem_ctx,
const struct dom_sid *domain_sid,
- const char *domain_name,
- enum net_samsync_mode mode,
struct samsync_context **ctx_p);
-NTSTATUS libnet_samsync(struct rpc_pipe_client *pipe_hnd,
- enum netr_SamDatabaseID database_id,
- samsync_fn_t callback_fn,
+NTSTATUS libnet_samsync(enum netr_SamDatabaseID database_id,
struct samsync_context *ctx);
NTSTATUS pull_netr_AcctLockStr(TALLOC_CTX *mem_ctx,
struct lsa_BinaryString *r,
diff --git a/source3/libnet/libnet_samsync.c b/source3/libnet/libnet_samsync.c
index 7dd47b6399..e170acc560 100644
--- a/source3/libnet/libnet_samsync.c
+++ b/source3/libnet/libnet_samsync.c
@@ -193,8 +193,6 @@ static NTSTATUS samsync_fix_delta_array(TALLOC_CTX *mem_ctx,
NTSTATUS libnet_samsync_init_context(TALLOC_CTX *mem_ctx,
const struct dom_sid *domain_sid,
- const char *domain_name,
- enum net_samsync_mode mode,
struct samsync_context **ctx_p)
{
struct samsync_context *ctx;
@@ -204,11 +202,6 @@ NTSTATUS libnet_samsync_init_context(TALLOC_CTX *mem_ctx,
ctx = TALLOC_ZERO_P(mem_ctx, struct samsync_context);
NT_STATUS_HAVE_NO_MEMORY(ctx);
- ctx->mode = mode;
-
- ctx->domain_name = talloc_strdup(mem_ctx, domain_name);
- NT_STATUS_HAVE_NO_MEMORY(ctx->domain_name);
-
if (domain_sid) {
ctx->domain_sid = sid_dup_talloc(mem_ctx, domain_sid);
NT_STATUS_HAVE_NO_MEMORY(ctx->domain_sid);
@@ -274,14 +267,12 @@ static const char *samsync_debug_str(TALLOC_CTX *mem_ctx,
* libnet_samsync
*/
-NTSTATUS libnet_samsync(struct rpc_pipe_client *pipe_hnd,
- enum netr_SamDatabaseID database_id,
- samsync_fn_t callback_fn,
+NTSTATUS libnet_samsync(enum netr_SamDatabaseID database_id,
struct samsync_context *ctx)
{
NTSTATUS result;
TALLOC_CTX *mem_ctx;
- const char *logon_server = pipe_hnd->desthost;
+ const char *logon_server = ctx->cli->desthost;
const char *computername = global_myname();
struct netr_Authenticator credential;
struct netr_Authenticator return_authenticator;
@@ -305,9 +296,9 @@ NTSTATUS libnet_samsync(struct rpc_pipe_client *pipe_hnd,
struct netr_DELTA_ENUM_ARRAY *delta_enum_array = NULL;
NTSTATUS callback_status;
- netlogon_creds_client_step(pipe_hnd->dc, &credential);
+ netlogon_creds_client_step(ctx->cli->dc, &credential);
- result = rpccli_netr_DatabaseSync2(pipe_hnd, mem_ctx,
+ result = rpccli_netr_DatabaseSync2(ctx->cli, mem_ctx,
logon_server,
computername,
&credential,
@@ -322,7 +313,7 @@ NTSTATUS libnet_samsync(struct rpc_pipe_client *pipe_hnd,
}
/* Check returned credentials. */
- if (!netlogon_creds_client_check(pipe_hnd->dc,
+ if (!netlogon_creds_client_check(ctx->cli->dc,
&return_authenticator.cred)) {
DEBUG(0,("credentials chain check failed\n"));
return NT_STATUS_ACCESS_DENIED;
@@ -332,7 +323,7 @@ NTSTATUS libnet_samsync(struct rpc_pipe_client *pipe_hnd,
break;
}
- session_key = data_blob_const(pipe_hnd->dc->sess_key, 16);
+ session_key = data_blob_const(ctx->cli->dc->sess_key, 16);
samsync_fix_delta_array(mem_ctx,
&session_key,
@@ -341,7 +332,8 @@ NTSTATUS libnet_samsync(struct rpc_pipe_client *pipe_hnd,
delta_enum_array);
/* Process results */
- callback_status = callback_fn(mem_ctx, database_id, delta_enum_array, result, ctx);
+ callback_status = ctx->delta_fn(mem_ctx, database_id,
+ delta_enum_array, result, ctx);
if (!NT_STATUS_IS_OK(callback_status)) {
result = callback_status;
goto out;
diff --git a/source3/libnet/libnet_samsync.h b/source3/libnet/libnet_samsync.h
index 24b72f3ab1..03d4f5366c 100644
--- a/source3/libnet/libnet_samsync.h
+++ b/source3/libnet/libnet_samsync.h
@@ -24,6 +24,14 @@ enum net_samsync_mode {
NET_SAMSYNC_MODE_DUMP = 2
};
+struct samsync_context;
+
+typedef NTSTATUS (*samsync_delta_fn_t)(TALLOC_CTX *,
+ enum netr_SamDatabaseID,
+ struct netr_DELTA_ENUM_ARRAY *,
+ NTSTATUS,
+ struct samsync_context *);
+
struct samsync_context {
enum net_samsync_mode mode;
const struct dom_sid *domain_sid;
@@ -34,15 +42,11 @@ struct samsync_context {
char *result_message;
char *error_message;
+ struct rpc_pipe_client *cli;
+ samsync_delta_fn_t delta_fn;
void *private_data;
};
-typedef NTSTATUS (*samsync_fn_t)(TALLOC_CTX *,
- enum netr_SamDatabaseID,
- struct netr_DELTA_ENUM_ARRAY *,
- NTSTATUS,
- struct samsync_context *);
-
NTSTATUS fetch_sam_entries_ldif(TALLOC_CTX *mem_ctx,
enum netr_SamDatabaseID database_id,
struct netr_DELTA_ENUM_ARRAY *r,