mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
s3-dsgetdcname: always pass in messaging context.
Volker, please check. Guenther
This commit is contained in:
parent
c3f5d99065
commit
ffdfcfb514
@ -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,
|
||||
|
@ -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;
|
||||
|
||||
status = dsgetdcname(ctx, NULL, r->in.domain,
|
||||
priv = talloc_get_type_abort(ctx->private_data,
|
||||
struct libnetapi_private_ctx);
|
||||
|
||||
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",
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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));
|
||||
|
@ -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;
|
||||
|
@ -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)) {
|
||||
|
@ -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));
|
||||
|
Loading…
Reference in New Issue
Block a user