summaryrefslogtreecommitdiff
path: root/source4/scripting/python
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-03-03 10:50:53 +0100
committerJelmer Vernooij <jelmer@samba.org>2008-03-03 10:50:53 +0100
commit7dd0cd26d32980d4edb9db5c77c98a2b112e24cb (patch)
tree025dad49b789c0e9f2eb03d87ec386295630b3f0 /source4/scripting/python
parent80e9b72e018fb7d7f2cd5ff383e4a533b4ccc705 (diff)
parent4d4a898742a0439d3f60c84194b02901412f4679 (diff)
downloadsamba-7dd0cd26d32980d4edb9db5c77c98a2b112e24cb.tar.gz
samba-7dd0cd26d32980d4edb9db5c77c98a2b112e24cb.tar.bz2
samba-7dd0cd26d32980d4edb9db5c77c98a2b112e24cb.zip
Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-gmake3
Conflicts: source/Makefile source/build/smb_build/makefile.pm source/librpc/config.mk (This used to be commit 3e02fcfd3fb6683f51417ba39f4ec177494eff3e)
Diffstat (limited to 'source4/scripting/python')
-rw-r--r--source4/scripting/python/samba/__init__.py11
-rw-r--r--source4/scripting/python/samba/provision.py21
2 files changed, 22 insertions, 10 deletions
diff --git a/source4/scripting/python/samba/__init__.py b/source4/scripting/python/samba/__init__.py
index b041165800..8d5f4250c9 100644
--- a/source4/scripting/python/samba/__init__.py
+++ b/source4/scripting/python/samba/__init__.py
@@ -127,7 +127,7 @@ class Ldb(ldb.Ldb):
try:
self.delete(msg.dn)
except ldb.LdbError, (LDB_ERR_NO_SUCH_OBJECT, _):
- # Ignor eno such object errors
+ # Ignore no such object errors
pass
res = self.search(basedn, ldb.SCOPE_SUBTREE, "(&(|(objectclass=*)(distinguishedName=*))(!(distinguishedName=@BASEINFO)))", ["distinguishedName"])
@@ -151,7 +151,14 @@ class Ldb(ldb.Ldb):
previous_remaining = current_remaining
current_remaining = len(res2)
for msg in res2:
- self.delete(msg.dn)
+ try:
+ self.delete(msg.dn)
+ # Ignore no such object errors
+ except ldb.LdbError, (LDB_ERR_NO_SUCH_OBJECT, _):
+ pass
+ # Ignore not allowed on non leaf errors
+ except ldb.LdbError, (LDB_ERR_NOT_ALLOWED_ON_NON_LEAF, _):
+ pass
def load_ldif_file_add(self, ldif_path):
"""Load a LDIF file.
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index 55935b0037..ea2feb981b 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -279,8 +279,6 @@ def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info,
Alternatively, provision() may call this, and then populate the database.
- :param erase: Remove the existing data present in the database.
-
:note: This will wipe the Sam Database!
:note: This function always removes the local SAM LDB file. The erase
@@ -289,10 +287,15 @@ def setup_samdb_partitions(samdb_path, setup_path, message, lp, session_info,
"""
assert session_info is not None
- if os.path.exists(samdb_path):
+ samdb = SamDB(samdb_path, session_info=session_info,
+ credentials=credentials, lp=lp)
+
+ # Wipes the database
+ try:
+ samdb.erase()
+ except:
os.unlink(samdb_path)
- # Also wipes the database
samdb = SamDB(samdb_path, session_info=session_info,
credentials=credentials, lp=lp)
@@ -547,7 +550,7 @@ def setup_self_join(samdb, configdn, schemadn, domaindn,
def setup_samdb(path, setup_path, session_info, credentials, lp,
schemadn, configdn, domaindn, dnsdomain, realm,
- netbiosname, message, hostname, rootdn, erase,
+ netbiosname, message, hostname, rootdn,
domainsid, aci, domainguid, policyguid,
domainname, fill, adminpass, krbtgtpass,
machinepass, hostguid, invocationid, dnspass,
@@ -560,6 +563,8 @@ def setup_samdb(path, setup_path, session_info, credentials, lp,
assert serverrole in ("domain controller", "member server")
+ erase = (fill != FILL_DRS)
+
# Also wipes the database
setup_samdb_partitions(path, setup_path, schemadn=schemadn, configdn=configdn,
domaindn=domaindn, message=message, lp=lp,
@@ -726,7 +731,7 @@ def provision(lp, setup_dir, message, paths, session_info,
hostguid=None, adminpass=None, krbtgtpass=None, domainguid=None,
policyguid=None, invocationid=None, machinepass=None,
dnspass=None, root=None, nobody=None, nogroup=None, users=None,
- wheel=None, backup=None, aci=None, serverrole=None, erase=False,
+ wheel=None, backup=None, aci=None, serverrole=None,
ldap_backend=None, ldap_backend_type=None, sitename=DEFAULTSITE):
"""Provision samba4
@@ -830,7 +835,7 @@ def provision(lp, setup_dir, message, paths, session_info,
message("Setting up smb.conf")
if serverrole == "domain controller":
smbconfsuffix = "dc"
- elif serverrole == "member":
+ elif serverrole == "member server":
smbconfsuffix = "member"
setup_file(setup_path("provision.smb.conf.%s" % smbconfsuffix),
paths.smbconf, {
@@ -873,7 +878,7 @@ def provision(lp, setup_dir, message, paths, session_info,
configdn=configdn, domaindn=domaindn,
dnsdomain=dnsdomain, netbiosname=netbiosname,
realm=realm, message=message, hostname=hostname,
- rootdn=rootdn, erase=erase, domainsid=domainsid,
+ rootdn=rootdn, domainsid=domainsid,
aci=aci, domainguid=domainguid, policyguid=policyguid,
domainname=domain, fill=samdb_fill,
adminpass=adminpass, krbtgtpass=krbtgtpass,