diff options
author | Howard Chu <hyc@symas.com> | 2013-09-17 15:38:42 -0700 |
---|---|---|
committer | Nadezhda Ivanova <nivanova@samba.org> | 2013-09-18 21:39:51 +0200 |
commit | 31ca4fc67443e0c7a8fec61e91df39fe2535982e (patch) | |
tree | dfeef4d13e4c3fc32888011962d694b5ba8d72b7 | |
parent | 743d4a474e1d80783f658fa1001a6d077fcfbede (diff) | |
download | samba-31ca4fc67443e0c7a8fec61e91df39fe2535982e.tar.gz samba-31ca4fc67443e0c7a8fec61e91df39fe2535982e.tar.bz2 samba-31ca4fc67443e0c7a8fec61e91df39fe2535982e.zip |
OpenLDAP provisioning tweaks
Remove BerkeleyDB-specific setup.
Streamline cn=samba partition initialization - allow any backend type for it.
Use back-mdb instead of back-ldif for cn=samba partition
Signed-off-by: Howard Chu <hyc@symas.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Nadezhda Ivanova <nivanova@symas.com>
Autobuild-User(master): Nadezhda Ivanova <nivanova@samba.org>
Autobuild-Date(master): Wed Sep 18 21:39:51 CEST 2013 on sn-devel-104
-rw-r--r-- | python/samba/provision/backend.py | 58 | ||||
-rw-r--r-- | source4/setup/cn=replicator.ldif | 12 | ||||
-rw-r--r-- | source4/setup/cn=samba-admin.ldif | 12 | ||||
-rw-r--r-- | source4/setup/cn=samba.ldif | 19 | ||||
-rw-r--r-- | source4/setup/slapd.conf | 2 |
5 files changed, 38 insertions, 65 deletions
diff --git a/python/samba/provision/backend.py b/python/samba/provision/backend.py index 5360ef41f5..af7f07f752 100644 --- a/python/samba/provision/backend.py +++ b/python/samba/provision/backend.py @@ -361,19 +361,13 @@ class OpenLDAPBackend(LDAPBackend): schemadn=self.names.schemadn, files=[ setup_path("schema_samba4.ldif")]) - def setup_db_config(self, dbdir): - """Setup a Berkeley database. + def setup_db_dir(self, dbdir): + """Create a database directory. :param dbdir: Database directory. """ - from samba.provision import setup_path - if not os.path.isdir(os.path.join(dbdir, "bdb-logs")): - os.makedirs(os.path.join(dbdir, "bdb-logs"), 0700) - if not os.path.isdir(os.path.join(dbdir, "tmp")): - os.makedirs(os.path.join(dbdir, "tmp"), 0700) - - setup_file(setup_path("DB_CONFIG"), - os.path.join(dbdir, "DB_CONFIG"), {"LDAPDBDIR": dbdir}) + if not os.path.exists(dbdir): + os.makedirs(dbdir, 0700) def provision(self): from samba.provision import ProvisioningError, setup_path @@ -420,6 +414,7 @@ class OpenLDAPBackend(LDAPBackend): mmr_syncrepl_domaindns_config = "" mmr_syncrepl_forestdns_config = "" mmr_syncrepl_user_config = "" + mmr_pass = "" if self.ol_mmr_urls is not None: # For now, make these equal @@ -536,31 +531,23 @@ class OpenLDAPBackend(LDAPBackend): "ADMIN_UID": str(os.getuid()), "NOSYNC": nosync_config,}) - self.setup_db_config(os.path.join(self.ldapdir, "db", "forestdns")) - self.setup_db_config(os.path.join(self.ldapdir, "db", "domaindns")) - self.setup_db_config(os.path.join(self.ldapdir, "db", "user")) - self.setup_db_config(os.path.join(self.ldapdir, "db", "config")) - self.setup_db_config(os.path.join(self.ldapdir, "db", "schema")) - - if not os.path.exists(os.path.join(self.ldapdir, "db", "samba", "cn=samba")): - os.makedirs(os.path.join(self.ldapdir, "db", "samba", "cn=samba"), 0700) - - setup_file(setup_path("cn=samba.ldif"), - os.path.join(self.ldapdir, "db", "samba", "cn=samba.ldif"), - { "UUID": str(uuid.uuid4()), - "LDAPTIME": timestring(int(time.time()))} ) - setup_file(setup_path("cn=samba-admin.ldif"), - os.path.join(self.ldapdir, "db", "samba", "cn=samba", "cn=samba-admin.ldif"), - {"LDAPADMINPASS_B64": b64encode(self.ldapadminpass), - "UUID": str(uuid.uuid4()), - "LDAPTIME": timestring(int(time.time()))} ) + self.setup_db_dir(os.path.join(self.ldapdir, "db", "forestdns")) + self.setup_db_dir(os.path.join(self.ldapdir, "db", "domaindns")) + self.setup_db_dir(os.path.join(self.ldapdir, "db", "user")) + self.setup_db_dir(os.path.join(self.ldapdir, "db", "config")) + self.setup_db_dir(os.path.join(self.ldapdir, "db", "schema")) + self.setup_db_dir(os.path.join(self.ldapdir, "db", "samba")) if self.ol_mmr_urls is not None: - setup_file(setup_path("cn=replicator.ldif"), - os.path.join(self.ldapdir, "db", "samba", "cn=samba", "cn=replicator.ldif"), - {"MMR_PASSWORD_B64": b64encode(mmr_pass), - "UUID": str(uuid.uuid4()), - "LDAPTIME": timestring(int(time.time()))} ) + mmr = "" + else: + mmr = "#" + + cn_samba = read_and_sub_file( + setup_path("cn=samba.ldif"), + { "LDAPADMINPASS": self.ldapadminpass, + "MMR_PASSWORD": mmr_pass, + "MMR": mmr }) mapping = "schema-map-openldap-2.3" backend_schema = "backend-schema.schema" @@ -636,6 +623,11 @@ class OpenLDAPBackend(LDAPBackend): # Don't confuse the admin by leaving the slapd.conf around os.remove(self.slapdconf) + cn_samba_cmd = [self.slapd_path, "-Tadd", "-b", "cn=samba", "-F", self.olcdir] + p = subprocess.Popen(cn_samba_cmd, stdin=subprocess.PIPE, shell=False) + p.stdin.write(cn_samba) + p.communicate() + class FDSBackend(LDAPBackend): diff --git a/source4/setup/cn=replicator.ldif b/source4/setup/cn=replicator.ldif deleted file mode 100644 index 6001456b4d..0000000000 --- a/source4/setup/cn=replicator.ldif +++ /dev/null @@ -1,12 +0,0 @@ -dn: cn=replicator -objectClass: top -objectClass: person -cn: replicator -userPassword:: ${MMR_PASSWORD_B64} -structuralObjectClass: person -entryUUID: ${UUID} -creatorsName: -createTimestamp: ${LDAPTIME} -entryCSN: 20080714010529.241039Z#000000#000#000000 -modifiersName: -modifyTimestamp: ${LDAPTIME} diff --git a/source4/setup/cn=samba-admin.ldif b/source4/setup/cn=samba-admin.ldif deleted file mode 100644 index c59ffd9ab6..0000000000 --- a/source4/setup/cn=samba-admin.ldif +++ /dev/null @@ -1,12 +0,0 @@ -dn: cn=samba-admin -objectClass: top -objectClass: person -cn: samba-admin -userPassword:: ${LDAPADMINPASS_B64} -structuralObjectClass: person -entryUUID: ${UUID} -creatorsName: -createTimestamp: ${LDAPTIME} -entryCSN: 20080714010529.241038Z#000000#000#000000 -modifiersName: -modifyTimestamp: ${LDAPTIME} diff --git a/source4/setup/cn=samba.ldif b/source4/setup/cn=samba.ldif index 3be6242fe3..79d806ccf6 100644 --- a/source4/setup/cn=samba.ldif +++ b/source4/setup/cn=samba.ldif @@ -2,10 +2,15 @@ dn: cn=Samba objectClass: top objectClass: container cn: Samba -structuralObjectClass: container -entryUUID: b1d4823a-e58c-102c-9f74-51b6d59a1b68 -creatorsName: -createTimestamp: 20080714010529Z -entryCSN: 20080714010529.194412Z#000000#000#000000 -modifiersName: -modifyTimestamp: 20080714010529Z + +dn: cn=samba-admin,cn=samba +objectClass: top +objectClass: person +cn: samba-admin +userPassword: ${LDAPADMINPASS} + +${MMR}dn: cn=replicator,cn=samba +${MMR}objectClass: top +${MMR}objectClass: person +${MMR}cn: replicator +${MMR}userPassword: ${MMR_PASSWORD} diff --git a/source4/setup/slapd.conf b/source4/setup/slapd.conf index 231ef82386..91406b6430 100644 --- a/source4/setup/slapd.conf +++ b/source4/setup/slapd.conf @@ -65,7 +65,7 @@ ${MEMBEROF_CONFIG} moduleload syncprov -database ldif +database mdb suffix cn=Samba directory ${LDAPDIR}/db/samba rootdn cn=Manager,cn=Samba |