diff options
author | Douglas Bagnall <douglas.bagnall@catalyst.net.nz> | 2015-06-23 16:38:29 +1200 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2015-10-29 08:11:54 +0100 |
commit | 4346fe6a0259e326bd5254a9d192f0807b27331e (patch) | |
tree | 2b67395a683438567b42301b1bff10a1782c3381 /source4 | |
parent | 8bdfb256d6c4fdeaaa118fc6da841daebc1c377d (diff) | |
download | samba-4346fe6a0259e326bd5254a9d192f0807b27331e.tar.gz |
KCC: allow --test-all-reps-from to work with --import-ldif
The ldif files lack information that a normal database has, which means
the ldif import function has to use some trickery to set the local DSA.
Once the local DSA is thus set, the fake database is a bit useless from
the point of view of other DSAs. We get around this by re-importing it
each time.
This is doing something slightly different than the normal samdb
--test-all-reps-from, in that the changes are not preserved between each
DSA's run. With the samdb database (unless using --readonly), the later
DSA's will see changes the early ones made. The ordering is arbitrary.
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Thu Oct 29 08:11:54 CET 2015 on sn-devel-104
Diffstat (limited to 'source4')
-rwxr-xr-x | source4/scripting/bin/samba_kcc | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/source4/scripting/bin/samba_kcc b/source4/scripting/bin/samba_kcc index a28b0f196f4..05ca55a180b 100755 --- a/source4/scripting/bin/samba_kcc +++ b/source4/scripting/bin/samba_kcc @@ -53,7 +53,9 @@ from samba.kcc import KCC # If DEFAULT_RNG_SEED is None, /dev/urandom or system time is used. DEFAULT_RNG_SEED = None -def test_all_reps_from(kcc, lp, creds, unix_now, rng_seed=None): + +def test_all_reps_from(kcc, dburl, lp, creds, unix_now, rng_seed=None, + ldif_file=None): """Run the KCC from all DSAs in read-only mode The behaviour depends on the global opts variable which contains @@ -89,8 +91,23 @@ def test_all_reps_from(kcc, lp, creds, unix_now, rng_seed=None): kcc = KCC(unix_now, readonly=True, verify=opts.verify, debug=opts.debug, dot_file_dir=opts.dot_file_dir) - kcc.samdb = samdb - kcc.run(opts.dburl, lp, creds, forced_local_dsa=dsa_dn, + if ldif_file is not None: + try: + # The dburl in this case is a temporary database. + # Its non-existence is ensured at the script startup. + # If it exists, it is from a previous iteration of + # this loop -- unless we're in an unfortunate race. + # Because this database is temporary, it lacks some + # detail and needs to be re-created anew to set the + # local dsa. + os.unlink(dburl) + except OSError: + pass + + kcc.import_ldif(dburl, lp, ldif_file, dsa_dn) + else: + kcc.samdb = samdb + kcc.run(dburl, lp, creds, forced_local_dsa=dsa_dn, forget_local_links=opts.forget_local_links, forget_intersite_links=opts.forget_intersite_links, attempt_live_connections=opts.attempt_live_connections) @@ -305,7 +322,9 @@ if opts.importldif: kcc.load_samdb(opts.dburl, lp, creds, force=False) if opts.test_all_reps_from: - test_all_reps_from(kcc, lp, creds, unix_now, rng_seed=opts.seed) + test_all_reps_from(kcc, opts.dburl, lp, creds, unix_now, + rng_seed=opts.seed, + ldif_file=opts.importldif) sys.exit() if opts.list_valid_dsas: |