diff options
author | Günther Deschner <gd@samba.org> | 2010-09-21 20:56:23 -0700 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2010-09-23 10:26:25 -0700 |
commit | ffdfcfb514c1a0849ba334ae6b9b00d3ad3c2227 (patch) | |
tree | 536860be90ee3531863894f87e5c24b1cb523702 | |
parent | c3f5d990652aec4b4f1f23a5e1c7b644cd46cbe7 (diff) | |
download | samba-ffdfcfb514c1a0849ba334ae6b9b00d3ad3c2227.tar.gz samba-ffdfcfb514c1a0849ba334ae6b9b00d3ad3c2227.tar.bz2 samba-ffdfcfb514c1a0849ba334ae6b9b00d3ad3c2227.zip |
s3-dsgetdcname: always pass in messaging context.
Volker, please check.
Guenther
-rw-r--r-- | source3/lib/netapi/getdc.c | 6 | ||||
-rw-r--r-- | source3/lib/netapi/joindomain.c | 18 | ||||
-rw-r--r-- | source3/lib/netapi/netapi_private.h | 2 | ||||
-rw-r--r-- | source3/libnet/libnet_samsync.c | 4 | ||||
-rw-r--r-- | source3/libnet/libnet_samsync.h | 1 | ||||
-rw-r--r-- | source3/libnet/libnet_samsync_keytab.c | 22 | ||||
-rw-r--r-- | source3/libsmb/dsgetdcname.c | 28 | ||||
-rw-r--r-- | source3/utils/net.c | 6 | ||||
-rw-r--r-- | source3/utils/net.h | 1 | ||||
-rw-r--r-- | source3/utils/net_ads.c | 2 | ||||
-rw-r--r-- | source3/utils/net_lookup.c | 2 |
11 files changed, 51 insertions, 41 deletions
diff --git a/source3/lib/netapi/getdc.c b/source3/lib/netapi/getdc.c index 565ccbc14b..904270242a 100644 --- a/source3/lib/netapi/getdc.c +++ b/source3/lib/netapi/getdc.c @@ -112,9 +112,13 @@ WERROR DsGetDcName_l(struct libnetapi_ctx *ctx, struct DsGetDcName *r) { NTSTATUS status; + struct libnetapi_private_ctx *priv; + + priv = talloc_get_type_abort(ctx->private_data, + struct libnetapi_private_ctx); status = dsgetdcname(ctx, - NULL, + priv->msg_ctx, r->in.domain_name, r->in.domain_guid, r->in.site_name, diff --git a/source3/lib/netapi/joindomain.c b/source3/lib/netapi/joindomain.c index 89a7c93d5e..e5777a0d33 100644 --- a/source3/lib/netapi/joindomain.c +++ b/source3/lib/netapi/joindomain.c @@ -36,8 +36,12 @@ WERROR NetJoinDomain_l(struct libnetapi_ctx *mem_ctx, struct NetJoinDomain *r) { struct libnet_JoinCtx *j = NULL; + struct libnetapi_private_ctx *priv; WERROR werr; + priv = talloc_get_type_abort(mem_ctx->private_data, + struct libnetapi_private_ctx); + if (!r->in.domain) { return WERR_INVALID_PARAM; } @@ -55,7 +59,7 @@ WERROR NetJoinDomain_l(struct libnetapi_ctx *mem_ctx, uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED | DS_WRITABLE_REQUIRED | DS_RETURN_DNS_NAME; - status = dsgetdcname(mem_ctx, NULL, r->in.domain, + status = dsgetdcname(mem_ctx, priv->msg_ctx, r->in.domain, NULL, NULL, flags, &info); if (!NT_STATUS_IS_OK(status)) { libnetapi_set_error_string(mem_ctx, @@ -154,6 +158,10 @@ WERROR NetUnjoinDomain_l(struct libnetapi_ctx *mem_ctx, struct dom_sid domain_sid; const char *domain = NULL; WERROR werr; + struct libnetapi_private_ctx *priv; + + priv = talloc_get_type_abort(mem_ctx->private_data, + struct libnetapi_private_ctx); if (!secrets_fetch_domain_sid(lp_workgroup(), &domain_sid)) { return WERR_SETUP_NOT_JOINED; @@ -178,7 +186,7 @@ WERROR NetUnjoinDomain_l(struct libnetapi_ctx *mem_ctx, uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED | DS_WRITABLE_REQUIRED | DS_RETURN_DNS_NAME; - status = dsgetdcname(mem_ctx, NULL, domain, + status = dsgetdcname(mem_ctx, priv->msg_ctx, domain, NULL, NULL, flags, &info); if (!NT_STATUS_IS_OK(status)) { libnetapi_set_error_string(mem_ctx, @@ -348,8 +356,12 @@ WERROR NetGetJoinableOUs_l(struct libnetapi_ctx *ctx, const char *dc = NULL; uint32_t flags = DS_DIRECTORY_SERVICE_REQUIRED | DS_RETURN_DNS_NAME; + struct libnetapi_private_ctx *priv; + + priv = talloc_get_type_abort(ctx->private_data, + struct libnetapi_private_ctx); - status = dsgetdcname(ctx, NULL, r->in.domain, + status = dsgetdcname(ctx, priv->msg_ctx, r->in.domain, NULL, NULL, flags, &info); if (!NT_STATUS_IS_OK(status)) { libnetapi_set_error_string(ctx, "%s", diff --git a/source3/lib/netapi/netapi_private.h b/source3/lib/netapi/netapi_private.h index d0f7756d16..859c064223 100644 --- a/source3/lib/netapi/netapi_private.h +++ b/source3/lib/netapi/netapi_private.h @@ -44,6 +44,8 @@ struct libnetapi_private_ctx { } samr; struct client_ipc_connection *ipc_connections; + + struct messaging_context *msg_ctx; }; NET_API_STATUS libnetapi_get_password(struct libnetapi_ctx *ctx, char **password); diff --git a/source3/libnet/libnet_samsync.c b/source3/libnet/libnet_samsync.c index 1b5b9c3b2f..6e416af180 100644 --- a/source3/libnet/libnet_samsync.c +++ b/source3/libnet/libnet_samsync.c @@ -80,6 +80,10 @@ NTSTATUS libnet_samsync_init_context(TALLOC_CTX *mem_ctx, NT_STATUS_HAVE_NO_MEMORY(ctx->domain_sid_str); } + ctx->msg_ctx = messaging_init(ctx, procid_self(), + event_context_init(ctx)); + NT_STATUS_HAVE_NO_MEMORY(ctx->msg_ctx); + *ctx_p = ctx; return NT_STATUS_OK; diff --git a/source3/libnet/libnet_samsync.h b/source3/libnet/libnet_samsync.h index cc3334050f..efdbb372bd 100644 --- a/source3/libnet/libnet_samsync.h +++ b/source3/libnet/libnet_samsync.h @@ -75,6 +75,7 @@ struct samsync_context { struct samsync_object *objects; struct rpc_pipe_client *cli; + struct messaging_context *msg_ctx; const struct samsync_ops *ops; diff --git a/source3/libnet/libnet_samsync_keytab.c b/source3/libnet/libnet_samsync_keytab.c index 0f7c5afac6..3f7e895928 100644 --- a/source3/libnet/libnet_samsync_keytab.c +++ b/source3/libnet/libnet_samsync_keytab.c @@ -32,22 +32,13 @@ static NTSTATUS keytab_ad_connect(TALLOC_CTX *mem_ctx, const char *domain_name, + const char *dc, const char *username, const char *password, struct libnet_keytab_context *ctx) { - NTSTATUS status; ADS_STATUS ad_status; ADS_STRUCT *ads; - struct netr_DsRGetDCNameInfo *info = NULL; - const char *dc; - - status = dsgetdcname(mem_ctx, NULL, domain_name, NULL, NULL, 0, &info); - if (!NT_STATUS_IS_OK(status)) { - return status; - } - - dc = strip_hostname(info->dc_unc); ads = ads_init(NULL, domain_name, dc); NT_STATUS_HAVE_NO_MEMORY(ads); @@ -119,17 +110,28 @@ static NTSTATUS init_keytab(TALLOC_CTX *mem_ctx, struct libnet_keytab_entry *entry; uint64_t old_sequence_num = 0; const char *principal = NULL; + struct netr_DsRGetDCNameInfo *info = NULL; + const char *dc; ret = libnet_keytab_init(mem_ctx, ctx->output_filename, &keytab_ctx); if (ret) { return krb5_to_nt_status(ret); } + status = dsgetdcname(mem_ctx, ctx->msg_ctx, + ctx->domain_name, NULL, NULL, 0, &info); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + dc = strip_hostname(info->dc_unc); + keytab_ctx->clean_old_entries = ctx->clean_old_entries; ctx->private_data = keytab_ctx; status = keytab_ad_connect(mem_ctx, ctx->domain_name, + dc, ctx->username, ctx->password, keytab_ctx); diff --git a/source3/libsmb/dsgetdcname.c b/source3/libsmb/dsgetdcname.c index 2803e74b66..4d0310fd7c 100644 --- a/source3/libsmb/dsgetdcname.c +++ b/source3/libsmb/dsgetdcname.c @@ -900,30 +900,6 @@ static NTSTATUS process_dc_dns(TALLOC_CTX *mem_ctx, /**************************************************************** ****************************************************************/ -static struct event_context *ev_context(void) -{ - static struct event_context *ctx; - - if (!ctx && !(ctx = event_context_init(NULL))) { - smb_panic("Could not init event context"); - } - return ctx; -} - -/**************************************************************** -****************************************************************/ - -static struct messaging_context *msg_context(TALLOC_CTX *mem_ctx) -{ - static struct messaging_context *ctx; - - if (!ctx && !(ctx = messaging_init(mem_ctx, procid_self(), - ev_context()))) { - smb_panic("Could not init messaging context"); - } - return ctx; -} - /**************************************************************** ****************************************************************/ @@ -948,8 +924,8 @@ static NTSTATUS process_dc_netbios(TALLOC_CTX *mem_ctx, NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX_WITH_IP; - if (!msg_ctx) { - msg_ctx = msg_context(mem_ctx); + if (msg_ctx == NULL) { + return NT_STATUS_INVALID_PARAMETER; } if (flags & DS_PDC_REQUIRED) { diff --git a/source3/utils/net.c b/source3/utils/net.c index eea13ea138..6c2fbad59a 100644 --- a/source3/utils/net.c +++ b/source3/utils/net.c @@ -929,6 +929,12 @@ static struct functable net_func[] = { c->opt_password = getenv("PASSWD"); } + c->msg_ctx = messaging_init(c, procid_self(), + event_context_init(c)); + if (c->msg_ctx == NULL) { + exit(1); + } + rc = net_run_function(c, argc_new-1, argv_new+1, "net", net_func); DEBUG(2,("return code = %d\n", rc)); diff --git a/source3/utils/net.h b/source3/utils/net.h index fc6addf231..d09d9905d7 100644 --- a/source3/utils/net.h +++ b/source3/utils/net.h @@ -78,6 +78,7 @@ struct net_context { struct sockaddr_storage opt_dest_ip; bool smb_encrypt; struct libnetapi_ctx *netapi_ctx; + struct messaging_context *msg_ctx; bool display_usage; void *private_data; diff --git a/source3/utils/net_ads.c b/source3/utils/net_ads.c index 08bb9d1f60..a07e6c56ea 100644 --- a/source3/utils/net_ads.c +++ b/source3/utils/net_ads.c @@ -986,6 +986,7 @@ static int net_ads_leave(struct net_context *c, int argc, const char **argv) r->in.unjoin_flags = WKSSVC_JOIN_FLAGS_JOIN_TYPE | WKSSVC_JOIN_FLAGS_ACCOUNT_DELETE; r->in.delete_machine_account = true; + r->in.msg_ctx = c->msg_ctx; werr = libnet_Unjoin(ctx, r); if (!W_ERROR_IS_OK(werr)) { @@ -1357,6 +1358,7 @@ int net_ads_join(struct net_context *c, int argc, const char **argv) r->in.join_flags = WKSSVC_JOIN_FLAGS_JOIN_TYPE | WKSSVC_JOIN_FLAGS_ACCOUNT_CREATE | WKSSVC_JOIN_FLAGS_DOMAIN_JOIN_IF_JOINED; + r->in.msg_ctx = c->msg_ctx; werr = libnet_Join(ctx, r); if (!W_ERROR_IS_OK(werr)) { diff --git a/source3/utils/net_lookup.c b/source3/utils/net_lookup.c index 5ff62398f2..3609eacdf8 100644 --- a/source3/utils/net_lookup.c +++ b/source3/utils/net_lookup.c @@ -409,7 +409,7 @@ static int net_lookup_dsgetdcname(struct net_context *c, int argc, const char ** site_name = argv[2]; } - status = dsgetdcname(mem_ctx, NULL, domain_name, NULL, site_name, + status = dsgetdcname(mem_ctx, c->msg_ctx, domain_name, NULL, site_name, flags, &info); if (!NT_STATUS_IS_OK(status)) { d_printf(_("failed with: %s\n"), nt_errstr(status)); |