From 084c8065f871c1aa31f5d157f1843437db449603 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Thu, 29 Apr 2010 08:51:01 +1000 Subject: s4:libnet Make 'net vampire' more robust to command line arguments When we have just joined a domain, we know a bit about that domain. Use these to override previous guesses as to what domain and realm to use for the rest of the join. Andrew Bartlett --- source4/libnet/libnet_vampire.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'source4/libnet') diff --git a/source4/libnet/libnet_vampire.c b/source4/libnet/libnet_vampire.c index 8d2393fc2a..a5c8a8f5d4 100644 --- a/source4/libnet/libnet_vampire.c +++ b/source4/libnet/libnet_vampire.c @@ -36,6 +36,7 @@ #include "system/time.h" #include "lib/ldb_wrap.h" #include "auth/auth.h" +#include "auth/credentials/credentials.h" #include "param/param.h" #include "param/provision.h" #include "libcli/security/dom_sid.h" @@ -655,6 +656,11 @@ NTSTATUS libnet_Vampire(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, return NT_STATUS_NO_MEMORY; } + /* Re-use the domain we are joining as the domain for the user + * to be authenticated with, unless they specified + * otherwise */ + cli_credentials_set_domain(ctx->cred, r->in.domain_name, CRED_GUESS_ENV); + join->in.domain_name = r->in.domain_name; join->in.account_name = account_name; join->in.netbios_name = netbios_name; @@ -673,6 +679,20 @@ NTSTATUS libnet_Vampire(struct libnet_context *ctx, TALLOC_CTX *mem_ctx, s->targetdir = r->in.targetdir; ZERO_STRUCT(b); + + /* Be more robust: + * We now know the domain and realm for sure - if they didn't + * put one on the command line, use this for the rest of the + * join */ + cli_credentials_set_realm(ctx->cred, join->out.realm, CRED_GUESS_ENV); + cli_credentials_set_domain(ctx->cred, join->out.domain_name, CRED_GUESS_ENV); + + /* Now set these values into the smb.conf - we probably had + * empty or useless defaults here from whatever smb.conf we + * started with */ + lp_set_cmdline(s->lp_ctx, "realm", join->out.realm); + lp_set_cmdline(s->lp_ctx, "workgroup", join->out.domain_name); + b.in.domain_dns_name = join->out.realm; b.in.domain_netbios_name = join->out.domain_name; b.in.domain_sid = join->out.domain_sid; -- cgit