The branch, master has been updated via 9e71fef57b956fa62134e5b885fc4ff78a957e71 (commit) via 53b59aa2cf78d465f471916c7fae60b9f212840b (commit) via ddb4db7c65db202d71785a404622a4d6f1c3906a (commit) from d9e94bf33681dda2b9fad5efa3226e5d818fab6b (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 9e71fef57b956fa62134e5b885fc4ff78a957e71 Author: Jelmer Vernooij <jel...@samba.org> Date: Wed Feb 11 18:45:51 2009 +0100 Use convenience function for finding setup dir in SaMDB tests. commit 53b59aa2cf78d465f471916c7fae60b9f212840b Author: Jelmer Vernooij <jel...@samba.org> Date: Wed Feb 11 18:44:57 2009 +0100 Use convenience function for finding setup_dir based on location of python module. commit ddb4db7c65db202d71785a404622a4d6f1c3906a Author: Jelmer Vernooij <jel...@samba.org> Date: Wed Feb 11 18:31:52 2009 +0100 Move some samdb-specific code out of provision. ----------------------------------------------------------------------- Summary of changes: source4/scripting/python/samba/provision.py | 25 +++++++++++++++++++------ source4/scripting/python/samba/samdb.py | 8 ++++++++ source4/scripting/python/samba/tests/samdb.py | 4 ++-- source4/setup/provision | 4 ++-- source4/setup/provision-backend | 4 ++-- source4/setup/upgrade | 3 ++- 6 files changed, 35 insertions(+), 13 deletions(-) Changeset truncated at 500 lines: diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py index 91cc074..d77b487 100644 --- a/source4/scripting/python/samba/provision.py +++ b/source4/scripting/python/samba/provision.py @@ -45,6 +45,23 @@ from ldb import SCOPE_SUBTREE, SCOPE_ONELEVEL, SCOPE_BASE, LdbError, \ __docformat__ = "restructuredText" + +def find_setup_dir(): + """Find the setup directory used by provision.""" + dirname = os.path.dirname(__file__) + if "/site-packages/" in dirname: + prefix = dirname[:dirname.index("/site-packages/")] + for suffix in ["share/setup", "share/samba/setup", "setup"]: + ret = os.path.join(prefix, suffix) + if os.path.isdir(ret): + return ret + # In source tree + ret = os.path.join(dirname, "../../../setup") + if os.path.isdir(ret): + return ret + raise Exception("Unable to find setup directory.") + + DEFAULTSITE = "Default-First-Site-Name" class InvalidNetbiosName(Exception): @@ -394,7 +411,6 @@ def make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole, }) - def setup_name_mappings(samdb, idmap, sid, domaindn, root_uid, nobody_uid, users_gid, wheel_gid): """setup reasonable name mappings for sam names to unix names. @@ -408,11 +424,7 @@ def setup_name_mappings(samdb, idmap, sid, domaindn, root_uid, nobody_uid, :param users_gid: gid of the UNIX users group. :param wheel_gid: gid of the UNIX wheel group.""" # add some foreign sids if they are not present already - samdb.add_foreign(domaindn, "S-1-5-7", "Anonymous") - samdb.add_foreign(domaindn, "S-1-1-0", "World") - samdb.add_foreign(domaindn, "S-1-5-2", "Network") - samdb.add_foreign(domaindn, "S-1-5-18", "System") - samdb.add_foreign(domaindn, "S-1-5-11", "Authenticated Users") + samdb.add_stock_foreign_sids() idmap.setup_name_mapping("S-1-5-7", idmap.TYPE_UID, nobody_uid) idmap.setup_name_mapping("S-1-5-32-544", idmap.TYPE_GID, wheel_gid) @@ -1423,6 +1435,7 @@ def provision_backend(setup_dir=None, message=None, "--server-role='" + serverrole + "'"] message("Run provision with: " + " ".join(args)) + def create_phpldapadmin_config(path, setup_path, ldapi_uri): """Create a PHP LDAP admin configuration file. diff --git a/source4/scripting/python/samba/samdb.py b/source4/scripting/python/samba/samdb.py index 947c460..9cc55e5 100644 --- a/source4/scripting/python/samba/samdb.py +++ b/source4/scripting/python/samba/samdb.py @@ -65,6 +65,14 @@ description: %s for msg in self.parse_ldif(add): self.add(msg[1]) + def add_stock_foreign_sids(self): + domaindn = self.domain_dn() + self.add_foreign(domaindn, "S-1-5-7", "Anonymous") + self.add_foreign(domaindn, "S-1-1-0", "World") + self.add_foreign(domaindn, "S-1-5-2", "Network") + self.add_foreign(domaindn, "S-1-5-18", "System") + self.add_foreign(domaindn, "S-1-5-11", "Authenticated Users") + def enable_account(self, user_dn): """Enable an account. diff --git a/source4/scripting/python/samba/tests/samdb.py b/source4/scripting/python/samba/tests/samdb.py index 8b8f178..434d7a7 100644 --- a/source4/scripting/python/samba/tests/samdb.py +++ b/source4/scripting/python/samba/tests/samdb.py @@ -19,7 +19,7 @@ from samba.auth import system_session from samba.credentials import Credentials import os -from samba.provision import setup_samdb, guess_names, setup_templatesdb, make_smbconf +from samba.provision import setup_samdb, guess_names, setup_templatesdb, make_smbconf, find_setup_dir from samba.samdb import SamDB from samba.tests import cmdline_loadparm, TestCaseInTempDir from samba.dcerpc import security @@ -30,7 +30,7 @@ from samba import param class SamDBTestCase(TestCaseInTempDir): def setup_path(self, relpath): - return os.path.join("setup", relpath) + return os.path.join(find_setup_dir(), relpath) def setUp(self): super(SamDBTestCase, self).setUp() diff --git a/source4/setup/provision b/source4/setup/provision index eab5d09..5cb851c 100755 --- a/source4/setup/provision +++ b/source4/setup/provision @@ -35,7 +35,7 @@ from samba.credentials import DONT_USE_KERBEROS from samba.auth import system_session import samba.getopt as options from samba import param -from samba.provision import provision, FILL_FULL, FILL_NT4SYNC, FILL_DRS +from samba.provision import provision, FILL_FULL, FILL_NT4SYNC, FILL_DRS, find_setup_dir # how do we make this case insensitive?? @@ -168,7 +168,7 @@ creds.set_kerberos_state(DONT_USE_KERBEROS) setup_dir = opts.setupdir if setup_dir is None: - setup_dir = os.path.dirname(__file__) + setup_dir = find_setup_dir() samdb_fill = FILL_FULL if opts.blank: diff --git a/source4/setup/provision-backend b/source4/setup/provision-backend index e4e2d56..eca209c 100755 --- a/source4/setup/provision-backend +++ b/source4/setup/provision-backend @@ -34,7 +34,7 @@ from samba import param from samba.auth import system_session import samba.getopt as options -from samba.provision import provision_backend +from samba.provision import provision_backend, find_setup_dir parser = optparse.OptionParser("provision [options]") sambaopts = options.SambaOptions(parser) @@ -94,7 +94,7 @@ else: setup_dir = opts.setupdir if setup_dir is None: - setup_dir = os.path.dirname(__file__) + setup_dir = find_setup_dir() provision_backend(setup_dir=setup_dir, message=message, smbconf=smbconf, targetdir=opts.targetdir, realm=opts.realm, domain=opts.domain, diff --git a/source4/setup/upgrade b/source4/setup/upgrade index 9c1a0cf..3d13169 100755 --- a/source4/setup/upgrade +++ b/source4/setup/upgrade @@ -65,13 +65,14 @@ else: smbconf = os.path.join(libdir, "smb.conf") samba3 = Samba3(libdir, smbconf) +from samba.provision import find_setup_dir from samba.upgrade import upgrade_provision message("Provisioning\n") setup_dir = opts.setupdir if setup_dir is None: - setup_dir = os.path.dirname(__file__) + setup_dir = find_setup_dir() lp = sambaopts.get_loadparm() smbconf = lp.configfile -- Samba Shared Repository