diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2005-08-31 02:39:57 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:35:04 -0500 |
commit | f58a74aabab3d5c0d1185ac2f77a5f54feb781e9 (patch) | |
tree | 79d531450d96f07da379fdd72fb40d1221570627 /source4 | |
parent | 40f85ace04abad7460d0f0afe9211c4280482c6c (diff) | |
download | samba-f58a74aabab3d5c0d1185ac2f77a5f54feb781e9.tar.gz samba-f58a74aabab3d5c0d1185ac2f77a5f54feb781e9.tar.bz2 samba-f58a74aabab3d5c0d1185ac2f77a5f54feb781e9.zip |
r9816: Work on testsuite for upgrade
Add 'paths' object to provision code.
(This used to be commit 488d737fb0ebbc2535d0ec17c14f0dc1eaf2a578)
Diffstat (limited to 'source4')
-rw-r--r-- | source4/lib/samba3/PLAN | 2 | ||||
-rw-r--r-- | source4/lib/samba3/samba3.c | 7 | ||||
-rwxr-xr-x | source4/script/tests/test_s3upgrade.sh | 17 | ||||
-rw-r--r-- | source4/scripting/libjs/provision.js | 44 | ||||
-rw-r--r-- | source4/scripting/libjs/upgrade.js | 18 | ||||
-rwxr-xr-x | source4/setup/provision | 2 | ||||
-rwxr-xr-x | source4/setup/upgrade | 31 |
7 files changed, 83 insertions, 38 deletions
diff --git a/source4/lib/samba3/PLAN b/source4/lib/samba3/PLAN index f6cdf1cce4..8c1a673535 100644 --- a/source4/lib/samba3/PLAN +++ b/source4/lib/samba3/PLAN @@ -1,3 +1,3 @@ TODO (SoC project): - - test ldb_map backend (testsuite?) + - finish ldb_map testsuite - testsuite for the static upgrade diff --git a/source4/lib/samba3/samba3.c b/source4/lib/samba3/samba3.c index 8d5ad77185..b9bb6d7362 100644 --- a/source4/lib/samba3/samba3.c +++ b/source4/lib/samba3/samba3.c @@ -88,9 +88,12 @@ NTSTATUS samba3_read(const char *libdir, const char *smbconf, TALLOC_CTX *ctx, s ret = talloc_zero(ctx, struct samba3); - if (smbconf) { + if (smbconf != NULL) { ret->configuration = param_init(ret); - param_read(ret->configuration, smbconf); + if (param_read(ret->configuration, smbconf) == -1) { + talloc_free(ret); + return NT_STATUS_UNSUCCESSFUL; + } } dbfile = talloc_asprintf(ctx, "%s/account_policy.tdb", libdir); diff --git a/source4/script/tests/test_s3upgrade.sh b/source4/script/tests/test_s3upgrade.sh new file mode 100755 index 0000000000..b0042bed45 --- /dev/null +++ b/source4/script/tests/test_s3upgrade.sh @@ -0,0 +1,17 @@ +#!/bin/sh +PREFIX=$1 + +if [ -z "$PREFIX" ] +then + print "Usage: test_s3upgrade.sh <prefix" + exit 1 +fi + +DATADIR=$PREFIX/upgrade + +mkdir -p $DATADIR +rm -f $DATADIR/* + +bin/smbscript setup/upgrade --targetdir=$DATADIR ../testdata/samba3 ../testdata/samba3/smb.conf + +# FIXME: Do some sanity checks on the output files diff --git a/source4/scripting/libjs/provision.js b/source4/scripting/libjs/provision.js index 9607d6f274..ef99dc43c5 100644 --- a/source4/scripting/libjs/provision.js +++ b/source4/scripting/libjs/provision.js @@ -199,16 +199,34 @@ function setup_file(template, fname, subobj) assert(ok); } +function provision_default_paths(subobj) +{ + var lp = loadparm_init(); + var paths = new Object(); + paths.smbconf = lp.get("config file"); + paths.hklm = "hklm.ldb"; + paths.hkcu = "hkcu.ldb"; + paths.hkcr = "hkcr.ldb"; + paths.hku = "hku.ldb"; + paths.hkpd = "hkpd.ldb"; + paths.hkpt = "hkpt.ldb"; + paths.samdb = "sam.ldb"; + paths.rootdse = "rootdse.ldb"; + paths.secrets = "secrets.ldb"; + paths.dns = lp.get("private dir") + "/" + subobj.DNSDOMAIN + ".zone"; + paths.winsdb = "wins.ldb"; + return paths; +} + /* provision samba4 - caution, this wipes all existing data! */ -function provision(subobj, message, blank) +function provision(subobj, message, blank, paths) { var data = ""; var lp = loadparm_init(); var sys = sys_init(); - var smbconf = lp.get("config file"); - + /* some options need to be upper/lower case */ @@ -228,31 +246,31 @@ function provision(subobj, message, blank) provision_next_usn = 1; /* only install a new smb.conf if there isn't one there already */ - var st = sys.stat(smbconf); + var st = sys.stat(paths.smbconf); if (st == undefined) { message("Setting up smb.conf\n"); - setup_file("provision.smb.conf", smbconf, subobj); + setup_file("provision.smb.conf", paths.smbconf, subobj); lp.reload(); } message("Setting up hklm.ldb\n"); - setup_ldb("hklm.ldif", "hklm.ldb", subobj); + setup_ldb("hklm.ldif", paths.hklm, subobj); message("Setting up sam.ldb attributes\n"); - setup_ldb("provision_init.ldif", "sam.ldb", subobj); + setup_ldb("provision_init.ldif", paths.samdb, subobj); message("Setting up sam.ldb templates\n"); - setup_ldb("provision_templates.ldif", "sam.ldb", subobj, NULL, false); + setup_ldb("provision_templates.ldif", paths.samdb, subobj, NULL, false); message("Setting up sam.ldb data\n"); - setup_ldb("provision.ldif", "sam.ldb", subobj, NULL, false); + setup_ldb("provision.ldif", paths.samdb, subobj, NULL, false); if (blank == false) { message("Setting up sam.ldb users and groups\n"); - setup_ldb("provision_users.ldif", "sam.ldb", subobj, data, false); + setup_ldb("provision_users.ldif", paths.samdb, subobj, data, false); } message("Setting up rootdse.ldb\n"); - setup_ldb("rootdse.ldif", "rootdse.ldb", subobj); + setup_ldb("rootdse.ldif", paths.rootdse, subobj); message("Setting up secrets.ldb\n"); - setup_ldb("secrets.ldif", "secrets.ldb", subobj); + setup_ldb("secrets.ldif", paths.secrets, subobj); message("Setting up DNS zone file\n"); setup_file("provision.zone", - lp.get("private dir") + "/" + subobj.DNSDOMAIN + ".zone", + paths.dns, subobj); } diff --git a/source4/scripting/libjs/upgrade.js b/source4/scripting/libjs/upgrade.js index 0e12d7c345..4fe6b8cc1e 100644 --- a/source4/scripting/libjs/upgrade.js +++ b/source4/scripting/libjs/upgrade.js @@ -403,17 +403,17 @@ function upgrade_smbconf(oldconf,mark) return newconf; } -function upgrade(subobj, samba3, message) +function upgrade(subobj, samba3, message, paths) { var ret = 0; var lp = loadparm_init(); var samdb = ldb_init(); - var ok = samdb.connect("sam.ldb"); + var ok = samdb.connect(paths.samdb); assert(ok); message("Writing configuration\n"); var newconf = upgrade_smbconf(samba3.configuration,true); - newconf.save(lp.get("config file")); + newconf.save(paths.smbconf); message("Importing account policies\n"); var ldif = upgrade_sam_policy(samba3,subobj.BASEDN); @@ -474,11 +474,12 @@ dn: @MAP=samba3sam message("Importing registry data\n"); var hives = new Array("hkcr","hkcu","hklm","hkpd","hku","hkpt"); for (var i in hives) { - message("... " + hives[i] + "\n"); + var hn = hives[i]; + message("... " + hn + "\n"); var regdb = ldb_init(); - ok = regdb.connect(hives[i] + ".ldb"); + ok = regdb.connect(paths[hn]); assert(ok); - var ldif = upgrade_registry(samba3.registry, hives[i]); + var ldif = upgrade_registry(samba3.registry, hn); for (var j in ldif) { message("... ... " + j); ok = regdb.add(ldif[j]); @@ -492,7 +493,7 @@ dn: @MAP=samba3sam message("Importing WINS data\n"); var winsdb = ldb_init(); - ok = winsdb.connect("wins.ldb"); + ok = winsdb.connect(paths.winsdb); assert(ok); ldb_erase(winsdb); @@ -500,8 +501,5 @@ dn: @MAP=samba3sam ok = winsdb.add(ldif); assert(ok); - message("Reloading smb.conf\n"); - lp.reload(); - return ret; } diff --git a/source4/setup/provision b/source4/setup/provision index b3be197710..fd949ce9d9 100755 --- a/source4/setup/provision +++ b/source4/setup/provision @@ -110,6 +110,6 @@ var blank = (options["blank"] != undefined); message("Provisioning for %s in realm %s\n", subobj.DOMAIN, subobj.REALM); message("Using administrator password: %s\n", subobj.ADMINPASS); -provision(subobj, message, blank); +provision(subobj, message, blank, provision_default_paths(subobj)); message("All OK\n"); return 0; diff --git a/source4/setup/upgrade b/source4/setup/upgrade index 6f10096a45..331892c3db 100755 --- a/source4/setup/upgrade +++ b/source4/setup/upgrade @@ -10,7 +10,7 @@ options = GetOptions(ARGV, "POPT_AUTOHELP", "POPT_COMMON_SAMBA", "POPT_COMMON_VERSION", - 'ldif', + 'targetdir=s', 'quiet', 'blank'); if (options == undefined) { @@ -32,13 +32,6 @@ function message() } } -function ldifprint(data) -{ - if (options.ldif != undefined) { - print(data); - } -} - /* show some help */ @@ -48,7 +41,7 @@ function ShowHelp() Samba4 import tool provision [options] <libdir> <smbconf> - --ldif Dump LDIF + --targetdir=DIR Output to specified directory --quiet Be quiet --blank do not add users or groups, just the structure @@ -73,11 +66,27 @@ if (samba3 == undefined) { exit(1); } + + message("Provisioning\n"); var subobj = upgrade_provision(samba3); -provision(subobj, message, options.blank); +var paths; +if (options.targetdir != undefined) { + paths = new Object(); + paths.smbconf = sprintf("%s/smb.conf", options.targetdir); + var ldbs = new Array("hklm","hkcr","hku","hkcu","hkpd","hkpt","samdb","rootdse","secrets","winsdb"); + for (var i in ldbs) { + var n = ldbs[i]; + paths[n] = sprintf("tdb://%s/%s.ldb", options.targetdir, n); + } + paths.dns = options.targetdir+"/dns.zone"; +} else { + paths = provision_default_paths(subobj);; +} + +provision(subobj, message, options.blank,paths); -var ret = upgrade(subobj,samba3,message); +var ret = upgrade(subobj,samba3,message,paths); if (ret > 0) { message("Failed to import %d entries\n", ret); } else { |