sambaundoguididx: fix for -s
authorAndrew Bartlett <abartlet@samba.org>
Mon, 20 May 2019 04:29:10 +0000 (16:29 +1200)
committerKarolin Seeger <kseeger@samba.org>
Wed, 28 Aug 2019 07:36:29 +0000 (07:36 +0000)
Quick fix running this script with -s instead of -H. samdb_url() returns
a url with a protocol prefix, which causes issues further down in the
script.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13978

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
(cherry picked from commit 40ca8ed5a152ae7c5ec039649c09a037a20a4143)

source4/scripting/bin/sambaundoguididx

index 9a38851b4213bc1b185b2c40650ee5b834fe4581..92405eab24db4a30475e4df80ff86fcc9f9f3d73 100755 (executable)
@@ -30,7 +30,7 @@ lp_ctx = sambaopts.get_loadparm()
 lp_ctx.set("dsdb:guid index", "false")
 
 if opts.H is None:
-    url = lp_ctx.samdb_url()
+    url = lp_ctx.private_path("sam.ldb")
 else:
     url = opts.H
 
@@ -62,7 +62,9 @@ dbs = []
 for part in partitions[0]['partition']:
     dbname = str(part).split(":")[1]
     dbpath = os.path.join(privatedir, dbname)
-    db = ldb.Ldb(url="ldb://" + dbpath,
+    if os.path.isfile(dbpath):
+        dbpath = "ldb://" + dbpath
+    db = ldb.Ldb(url=dbpath,
                  options=["modules:"],
                  flags=ldb.FLG_DONT_CREATE_DB)
     db.transaction_start()