diff options
author | Andrew Bartlett <abartlet@samba.org> | 2006-01-14 06:17:24 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:51:07 -0500 |
commit | f3db23ac75578198ee411b21a7ba2ec49dedafab (patch) | |
tree | 4625f46ea496e475be03e8c94d968d15f56e9693 /source4/scripting/libjs | |
parent | ae51cc9bec8bc5d6efd035ac6e594aa7cc108ffe (diff) | |
download | samba-f3db23ac75578198ee411b21a7ba2ec49dedafab.tar.gz samba-f3db23ac75578198ee411b21a7ba2ec49dedafab.tar.bz2 samba-f3db23ac75578198ee411b21a7ba2ec49dedafab.zip |
r12928: This patch improves the interaction between the vampire and provsion code.
Previously, we had to know (or guess) the host and domain guid at the
provision stage. Now we query the database post-provision, to extract
the values and fill in the zone file.
This allows us to generate a correct zone file in the Windows migration case.
In an effort to make SWAT easier to use, I have removed and renamed
some of the provision options.
I have also fixed a nasty issue in my js code. I had implictly
declared a global variable of the name 'join', with disasterious
results for any subsequent user of the string utility function:
esp exception - ASSERT at lib/appweb/ejs/ejsParser.c:2064, 0
Backtrace:
[ 0] substitute_var:20 -> list[i] = join("", list2)
[ 1] setup_file:9 -> data = substitute_var(data, subobj)
Andrew Bartlett
(This used to be commit a38ceefd11f8b748f30383ef36a4752f178bfca1)
Diffstat (limited to 'source4/scripting/libjs')
-rw-r--r-- | source4/scripting/libjs/provision.js | 64 |
1 files changed, 48 insertions, 16 deletions
diff --git a/source4/scripting/libjs/provision.js b/source4/scripting/libjs/provision.js index 60f267f8d5..2b04aa6791 100644 --- a/source4/scripting/libjs/provision.js +++ b/source4/scripting/libjs/provision.js @@ -302,10 +302,6 @@ function provision(subobj, message, blank, paths, session_info, credentials) } message("Setting up secrets.ldb\n"); setup_ldb("secrets.ldif", info, paths.secrets); - message("Setting up DNS zone file\n"); - setup_file("provision.zone", - paths.dns, - subobj); message("Setting up keytabs\n"); var keytab_ok = credentials_update_all_keytabs(); assert(keytab_ok); @@ -330,6 +326,32 @@ function provision(subobj, message, blank, paths, session_info, credentials) return true; } +/* Write out a DNS zone file, from the info in the current database */ +function provision_dns(subobj, message, paths, session_info, credentials) +{ + message("Setting up DNS zone: " + subobj.DNSDOMAIN + " \n"); + var ldb = ldb_init(); + ldb.session_info = session_info; + ldb.credentials = credentials; + + /* connect to the sam */ + var ok = ldb.connect(paths.samdb); + assert(ok); + + /* These values may have changed, due to an incoming SamSync, so fetch them from the database */ + subobj.DOMAINGUID = searchone(ldb, "(&(objectClass=domainDNS)(dnsDomain=" + subobj.DNSDOMAIN + "))", "objectGUID"); + assert(subobj.DOMAINGUID != undefined); + + subobj.HOSTGUID = searchone(ldb, "(&(objectClass=computer)(cn=" + subobj.NETBIOSNAME + "))", "objectGUID"); + assert(subobj.HOSTGUID != undefined); + + setup_file("provision.zone", + paths.dns, + subobj); + + message("Please install the zone located in " + paths.dns + " into your DNS server\n"); +} + /* guess reasonably default options for provisioning */ @@ -517,27 +539,37 @@ function provision_validate(subobj, message) return true; } -function join_domain(domain, netbios_name, join_type, creds, writefln) +function join_domain(domain, netbios_name, join_type, creds, message) { - ctx = NetContext(creds); - join = new Object(); - join.domain = domain; - join.join_type = join_type; - join.netbios_name = netbios_name; - if (!ctx.JoinDomain(join)) { - writefln("Domain Join failed: " + join.error_string); + var ctx = NetContext(creds); + var joindom = new Object(); + joindom.domain = domain; + joindom.join_type = join_type; + joindom.netbios_name = netbios_name; + if (!ctx.JoinDomain(joindom)) { + message("Domain Join failed: " + join.error_string); return false; } return true; } -function vampire(machine_creds, writefln) -{ - var ctx = NetContext(); +/* Vampire a remote domain. Session info and credentials are required for for + * access to our local database (might be remote ldap) + */ + +function vampire(domain, session_info, credentials, message) { + var ctx = NetContext(credentials); vampire = new Object(); + var machine_creds = credentials_init(); + machine_creds.set_domain(form.DOMAIN); + if (!machine_creds.set_machine_account()) { + message("Failed to access domain join information!"); + return false; + } vampire.machine_creds = machine_creds; + vampire.session_info = session_info; if (!ctx.SamSyncLdb(vampire)) { - writefln("Migration of remote domain to Samba failed: " + vampire.error_string); + message("Migration of remote domain to Samba failed: " + vampire.error_string); return false; } return true; |