Skip to content

Commit

Permalink
r9834: More tests for the upgrade from Samba3
Browse files Browse the repository at this point in the history
(This used to be commit d2db164)
  • Loading branch information
jelmer authored and Gerald (Jerry) Carter committed Oct 10, 2007
1 parent 52bcf4c commit 0712cbd
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 17 deletions.
11 changes: 4 additions & 7 deletions source4/script/tests/test_s3upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ then
exit 1
fi

DATADIR=$PREFIX/upgrade
mkdir -p $PREFIX
rm -f $PREFIX/*

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
bin/smbscript ../testdata/samba3/verify ../testdata/samba3
bin/smbscript setup/upgrade --verify --targetdir=$PREFIX ../testdata/samba3 ../testdata/samba3/smb.conf
42 changes: 42 additions & 0 deletions source4/scripting/ejs/smbcalls_samba3.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ static struct MprVar mprRegistry(struct samba3_regdb *reg)
mprAddArray(&ks, i, k);
}

if (i == 0) {
mprSetVar(&ks, "length", mprCreateIntegerVar(i));
}

mprSetVar(&mpv, "keys", ks);

return mpv;
Expand Down Expand Up @@ -104,6 +108,11 @@ static struct MprVar mprIdmapDb(struct samba3_idmapdb *db)
mprAddArray(&mps, i, mp);
}

if (i == 0) {
mprSetVar(&mpv, "length", mprCreateIntegerVar(i));
}


mprSetVar(&mpv, "mappings", mps);

return mpv;
Expand Down Expand Up @@ -131,6 +140,11 @@ static struct MprVar mprGroupMappings(struct samba3_groupdb *db)
mprAddArray(&mpv, i, g);
}

if (i == 0) {
mprSetVar(&mpv, "length", mprCreateIntegerVar(i));
}


return mpv;
}

Expand Down Expand Up @@ -158,6 +172,10 @@ static struct MprVar mprAliases(struct samba3_groupdb *db)
mprSetVar(&a, "members", am);
}

if (i == 0) {
mprSetVar(&mpv, "length", mprCreateIntegerVar(i));
}

return mpv;
}

Expand Down Expand Up @@ -219,6 +237,10 @@ static struct MprVar mprSecrets(struct samba3_secrets *sec)
mprAddArray(&es, i, mprDomainSecrets(&sec->domains[i]));
}

if (i == 0) {
mprSetVar(&es, "length", mprCreateIntegerVar(i));
}

mprSetVar(&mpv, "domains", es);

es = mprObject("trusted_domains");
Expand Down Expand Up @@ -247,6 +269,10 @@ static struct MprVar mprSecrets(struct samba3_secrets *sec)
mprAddArray(&es, i, e);
}

if (i == 0) {
mprSetVar(&es, "length", mprCreateIntegerVar(i));
}

mprSetVar(&mpv, "trusted_domains", es);

es = mprObject("array");
Expand Down Expand Up @@ -279,6 +305,10 @@ static struct MprVar mprSecrets(struct samba3_secrets *sec)
mprAddArray(&es, i, e);
}

if (i == 0) {
mprSetVar(&es, "length", mprCreateIntegerVar(i));
}

mprSetVar(&mpv, "afs_keyfiles", es);

mprSetVar(&mpv, "ipc_cred", mprCredentials(sec->ipc_cred));
Expand All @@ -301,6 +331,10 @@ static struct MprVar mprShares(struct samba3 *samba3)
mprAddArray(&mpv, i, s);
}

if (i == 0) {
mprSetVar(&mpv, "length", mprCreateIntegerVar(i));
}

return mpv;
}

Expand Down Expand Up @@ -348,6 +382,10 @@ static struct MprVar mprSamAccounts(struct samba3 *samba3)
mprAddArray(&mpv, i, m);
}

if (i == 0) {
mprSetVar(&mpv, "length", mprCreateIntegerVar(i));
}

return mpv;
}

Expand Down Expand Up @@ -375,6 +413,10 @@ static struct MprVar mprWinsEntries(struct samba3 *samba3)
mprAddArray(&mpv, i, w);
}

if (i == 0) {
mprSetVar(&mpv, "length", mprCreateIntegerVar(i));
}

return mpv;
}

Expand Down
30 changes: 21 additions & 9 deletions source4/scripting/libjs/upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,26 +448,26 @@ dn: @MAP=samba3sam

message("Importing users\n");
for (var i in samba3.samaccounts) {
message("... " + samba3.samaccounts[i].username);
var msg = "... " + samba3.samaccounts[i].username;
var ldif = upgrade_sam_account(samba3.samaccounts[i],subobj.BASEDN);
ok = samdb.add(ldif);
if (!ok) {
message("... error: " + samdb.errstring());
msg = msg + "... error: " + samdb.errstring();
ret = ret + 1;
}
message("\n");
message(msg + "\n");
}

message("Importing groups\n");
for (var i in samba3.groupmappings) {
message("... " + samba3.groupmappings[i].nt_name);
var msg = "... " + samba3.groupmappings[i].nt_name;
var ldif = upgrade_sam_group(samba3.groupmappings[i],subobj.BASEDN);
ok = samdb.add(ldif);
if (!ok) {
message("... error: " + samdb.errstring());
msg = msg + "... error: " + samdb.errstring();
ret = ret + 1;
}
message("\n");
message(msg + "\n");
}

message("Importing registry data\n");
Expand All @@ -480,13 +480,13 @@ dn: @MAP=samba3sam
assert(ok);
var ldif = upgrade_registry(samba3.registry, hn, regdb);
for (var j in ldif) {
message("... ... " + j);
var msg = "... ... " + j;
ok = regdb.add(ldif[j]);
if (!ok) {
message("... error: " + regdb.errstring());
msg = msg + "... error: " + regdb.errstring();
ret = ret + 1;
}
message("\n");
message(msg + "\n");
}
}

Expand All @@ -502,3 +502,15 @@ dn: @MAP=samba3sam

return ret;
}

function upgrade_verify(subobj, samba3,paths,message)
{
message("Verifying account policies\n");
var samldb = ldb_init();
var ne = 0;

var ok = samldb.connect(paths.samdb);
assert(ok);

// FIXME
}
9 changes: 8 additions & 1 deletion source4/setup/upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ options = GetOptions(ARGV,
"POPT_AUTOHELP",
"POPT_COMMON_SAMBA",
"POPT_COMMON_VERSION",
'verify',
'targetdir=s',
'quiet', 'blank');

Expand Down Expand Up @@ -92,4 +93,10 @@ if (ret > 0) {
} else {
message("All OK\n");
}
return 0;

if (options.verify != undefined) {
message("Verifying...\n");
ret = upgrade_verify(subobj, samba3,paths,message);
}

return ret;
51 changes: 51 additions & 0 deletions testdata/samba3/verify
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/usr/bin/env smbscript
/* Verifies that the data present in this directory
Can be read correctly by Samba4. Do not update
without changing the corresponding TDB file!
Written by Jelmer Vernooij, 2005.
*/

libinclude("base.js");

var path = substr(ARGV[0], 0, -strlen("verify"));
printf("Reading from %s\n", path);

var s = samba3_read(path, path+"smb.conf");
assert(s != undefined);

// smb.conf checks
assert(s.configuration.get("passdb backend") != undefined);

var data = s.configuration.data();
assert(data != undefined);
var global = data["global"];
assert(global != undefined);
assert(global["passdb backend"] == s.configuration.get("passdb backend"));
assert(global["passdb backend"] != undefined);

println("smb.conf ok");

assert(s.winsentries.length == 22);
assert(s.samaccounts.length == 3);
assert(s.shares.length == 0);
assert(s.registry.keys.length == 28);
assert(s.groupmappings.length == 13);
assert(s.aliases.length == 0);
assert(s.idmapdb.mappings.length == 4);

println("database entry count correct");

// account policies
assert(s.policy.min_password_length == 5);
assert(s.policy.minimum_password_age == 0);
assert(s.policy.maximum_password_age == 999999999);
assert(s.policy.refuse_machine_password_change == 0);
assert(s.policy.reset_count_minutes == 0);
assert(s.policy.disconnect_time == -1);
assert(s.policy.user_must_logon_to_change_password == 0);
assert(s.policy.password_history == 0);
assert(s.policy.lockout_duration == 0);
assert(s.policy.bad_lockout_minutes == 0);

println("account policies ok");

0 comments on commit 0712cbd

Please sign in to comment.