diff options
Diffstat (limited to 'source4/scripting/python')
-rw-r--r-- | source4/scripting/python/samba/provision.py | 2 | ||||
-rw-r--r-- | source4/scripting/python/samba/provisionbackend.py | 56 |
2 files changed, 32 insertions, 26 deletions
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py index e40603a0b0..f803f588eb 100644 --- a/source4/scripting/python/samba/provision.py +++ b/source4/scripting/python/samba/provision.py @@ -1278,7 +1278,7 @@ def provision(setup_dir, message, session_info, else: raise ProvisioningError("Unknown LDAP backend type selected") - provision_backend.provision() + provision_backend.setup() provision_backend.start() # only install a new shares config db if there is none diff --git a/source4/scripting/python/samba/provisionbackend.py b/source4/scripting/python/samba/provisionbackend.py index b4239ef92d..da17cbf05c 100644 --- a/source4/scripting/python/samba/provisionbackend.py +++ b/source4/scripting/python/samba/provisionbackend.py @@ -115,7 +115,22 @@ class ProvisionBackend(object): self.ldap_backend_type = "openldap" #For now, assume existing backends at least emulate OpenLDAP return - + + def setup(self): + pass + + def start(self): + pass + + def shutdown(self): + pass + + def post_setup(self): + pass + + +class LDAPBackend(ProvisionBackend): + def setup(self): # we will shortly start slapd with ldapi for final provisioning. first check with ldapsearch -> rootDSE via self.ldapi_uri # if another instance of slapd is already running try: @@ -123,10 +138,10 @@ class ProvisionBackend(object): search_ol_rootdse = ldapi_db.search(base="", scope=SCOPE_BASE, expression="(objectClass=OpenLDAProotDSE)"); try: - f = open(paths.slapdpid, "r") + f = open(self.paths.slapdpid, "r") p = f.read() f.close() - message("Check for slapd Process with PID: " + str(p) + " and terminate it manually.") + self.message("Check for slapd Process with PID: " + str(p) + " and terminate it manually.") except: pass @@ -136,54 +151,45 @@ class ProvisionBackend(object): pass # Try to print helpful messages when the user has not specified the path to slapd - if slapd_path is None: + if self.slapd_path is None: raise ProvisioningError("Warning: LDAP-Backend must be setup with path to slapd, e.g. --slapd-path=\"/usr/local/libexec/slapd\"!") - if not os.path.exists(slapd_path): - message (slapd_path) + if not os.path.exists(self.slapd_path): + self.message (self.slapd_path) raise ProvisioningError("Warning: Given Path to slapd does not exist!") - if not os.path.isdir(paths.ldapdir): - os.makedirs(paths.ldapdir, 0700) + if not os.path.isdir(self.paths.ldapdir): + os.makedirs(self.paths.ldapdir, 0700) # Put the LDIF of the schema into a database so we can search on # it to generate schema-dependent configurations in Fedora DS and # OpenLDAP - schemadb_path = os.path.join(paths.ldapdir, "schema-tmp.ldb") + schemadb_path = os.path.join(self.paths.ldapdir, "schema-tmp.ldb") try: os.unlink(schemadb_path) except OSError: pass - schema.write_to_tmp_ldb(schemadb_path); + self.schema.write_to_tmp_ldb(schemadb_path); self.credentials = Credentials() - self.credentials.guess(lp) + self.credentials.guess(self.lp) #Kerberos to an ldapi:// backend makes no sense self.credentials.set_kerberos_state(DONT_USE_KERBEROS) - self.credentials.set_password(ldapadminpass) + self.credentials.set_password(self.ldapadminpass) self.secrets_credentials = Credentials() - self.secrets_credentials.guess(lp) + self.secrets_credentials.guess(self.lp) #Kerberos to an ldapi:// backend makes no sense self.secrets_credentials.set_kerberos_state(DONT_USE_KERBEROS) self.secrets_credentials.set_username("samba-admin") - self.secrets_credentials.set_password(ldapadminpass) + self.secrets_credentials.set_password(self.ldapadminpass) - def provision(self): - pass + self.provision() - def start(self): - pass - - def shutdown(self): - pass - - def post_setup(self): + def provision(self): pass - -class LDAPBackend(ProvisionBackend): def start(self): self.slapd_command_escaped = "\'" + "\' \'".join(self.slapd_command) + "\'" setup_file(self.setup_path("ldap_backend_startup.sh"), self.paths.ldapdir + "/ldap_backend_startup.sh", { |