From c787b13c8f1bd086bda284fcc21d25c94ac880a8 Mon Sep 17 00:00:00 2001 From: Stanislav Levin Date: Mar 12 2019 06:37:17 +0000 Subject: [PATCH 1/3] Revert "Ticket 49830 - Import fails if backend name is "default"" This reverts commit 8720370b3f508d8da3ea42883bf65e50efa27ed3. --- diff --git a/dirsrvtests/tests/suites/import/regression_test.py b/dirsrvtests/tests/suites/import/regression_test.py index d83d003..ad51721 100644 --- a/dirsrvtests/tests/suites/import/regression_test.py +++ b/dirsrvtests/tests/suites/import/regression_test.py @@ -23,52 +23,6 @@ TEST_SUFFIX1 = "dc=importest1,dc=com" TEST_BACKEND1 = "importest1" TEST_SUFFIX2 = "dc=importest2,dc=com" TEST_BACKEND2 = "importest2" -TEST_DEFAULT_SUFFIX = "dc=default,dc=com" -TEST_DEFAULT_NAME = "default" - - -def test_import_be_default(topo): - """ Create a backend using the name "default". previously this name was - used int - - :id: 8e507beb-e917-4330-8cac-1ff0eee10508 - :feature: Import - :setup: Standalone instance - :steps: - 1. Create a test suffix using the be name of "default" - 2. Create an ldif for the "default" backend - 3. Import ldif - 4. Verify all entries were imported - :expectedresults: - 1. Success - 2. Success - 3. Success - 4. Success - """ - log.info('Adding suffix:{} and backend: {}...'.format(TEST_DEFAULT_SUFFIX, - TEST_DEFAULT_NAME)) - backends = Backends(topo.standalone) - backends.create(properties={BACKEND_SUFFIX: TEST_DEFAULT_SUFFIX, - BACKEND_NAME: TEST_DEFAULT_NAME}) - - log.info('Create LDIF file and import it...') - ldif_dir = topo.standalone.get_ldif_dir() - ldif_file = os.path.join(ldif_dir, 'default.ldif') - dbgen(topo.standalone, 5, ldif_file, TEST_DEFAULT_SUFFIX) - - log.info('Stopping the server and running offline import...') - topo.standalone.stop() - assert topo.standalone.ldif2db(TEST_DEFAULT_NAME, None, None, - None, ldif_file) - topo.standalone.start() - - log.info('Verifying entry count after import...') - entries = topo.standalone.search_s(TEST_DEFAULT_SUFFIX, - ldap.SCOPE_SUBTREE, - "(objectclass=*)") - assert len(entries) > 1 - - log.info('Test PASSED') def test_del_suffix_import(topo): diff --git a/ldap/servers/slapd/defbackend.c b/ldap/servers/slapd/defbackend.c index b0465e2..aa709da 100644 --- a/ldap/servers/slapd/defbackend.c +++ b/ldap/servers/slapd/defbackend.c @@ -23,6 +23,8 @@ /* * ---------------- Macros --------------------------------------------------- */ +#define DEFBACKEND_TYPE "default" + #define DEFBACKEND_OP_NOT_HANDLED 0 #define DEFBACKEND_OP_HANDLED 1 @@ -63,7 +65,7 @@ defbackend_init(void) /* * create a new backend */ - defbackend_backend = slapi_be_new(DEFBACKEND_TYPE, DEFBACKEND_NAME, 1 /* Private */, 0 /* Do Not Log Changes */); + defbackend_backend = slapi_be_new(DEFBACKEND_TYPE, DEFBACKEND_TYPE, 1 /* Private */, 0 /* Do Not Log Changes */); if ((rc = slapi_pblock_set(pb, SLAPI_BACKEND, defbackend_backend)) != 0) { errmsg = "slapi_pblock_set SLAPI_BACKEND failed"; goto cleanup_and_return; diff --git a/ldap/servers/slapd/mapping_tree.c b/ldap/servers/slapd/mapping_tree.c index 834949a..472a2f6 100644 --- a/ldap/servers/slapd/mapping_tree.c +++ b/ldap/servers/slapd/mapping_tree.c @@ -748,7 +748,7 @@ mapping_tree_entry_add(Slapi_Entry *entry, mapping_tree_node **newnodep) be_names = (char **)slapi_ch_calloc(1, sizeof(char *)); be_states = (int *)slapi_ch_calloc(1, sizeof(int)); - tmp_backend_name = (char *)slapi_ch_strdup(DEFBACKEND_NAME); /* "NULL_CONTAINER" */ + tmp_backend_name = (char *)slapi_ch_strdup("default"); /* "NULL_CONTAINER" */ (be_names)[be_list_count] = tmp_backend_name; /* set backend as started by default */ @@ -2250,10 +2250,7 @@ slapi_mapping_tree_select_all(Slapi_PBlock *pb, Slapi_Backend **be_list, Slapi_E if (ret != LDAP_SUCCESS) { /* flag we have problems at least on part of the tree */ flag_partial_result = 1; - } else if ((((!slapi_sdn_issuffix(sdn, slapi_mtn_get_dn(node)) && !slapi_sdn_issuffix(slapi_mtn_get_dn(node), sdn))) || - ((node_list == mapping_tree_root) && node->mtn_private && (scope != LDAP_SCOPE_BASE))) && - (!be || strncmp(be->be_name, DEFBACKEND_NAME, 8))) - { + } else if ((((!slapi_sdn_issuffix(sdn, slapi_mtn_get_dn(node)) && !slapi_sdn_issuffix(slapi_mtn_get_dn(node), sdn))) || ((node_list == mapping_tree_root) && node->mtn_private && (scope != LDAP_SCOPE_BASE))) && (!be || strncmp(be->be_name, "default", 8))) { if (be && !be_isdeleted(be)) { /* wrong backend or referall, ignore it */ slapi_log_err(SLAPI_LOG_ARGS, "slapi_mapping_tree_select_all", diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h index a027926..3b7e58d 100644 --- a/ldap/servers/slapd/slap.h +++ b/ldap/servers/slapd/slap.h @@ -45,9 +45,6 @@ static char ptokPBE[34] = "Internal (Software) Token "; #define SLAPD_EXEMODE_DBVERIFY 12 #define SLAPD_EXEMODE_UPGRADEDNFORMAT 13 -#define DEFBACKEND_TYPE "default" -#define DEFBACKEND_NAME "DirectoryServerDefaultBackend" - #define LDAP_SYSLOG #include #define RLIM_TYPE int diff --git a/src/lib389/lib389/dbgen.py b/src/lib389/lib389/dbgen.py index 68455b4..a0cda94 100644 --- a/src/lib389/lib389/dbgen.py +++ b/src/lib389/lib389/dbgen.py @@ -113,13 +113,8 @@ usercertificate;binary:: MIIBvjCCASegAwIBAgIBAjANBgkqhkiG9w0BAQQFADAnMQ8wDQYD DBGEN_HEADER = """dn: {SUFFIX} objectClass: top objectClass: domain -<<<<<<< HEAD dc: example aci: (target=ldap:///{SUFFIX})(targetattr=*)(version 3.0; acl "acl1"; allow(write) userdn = "ldap:///self";) -======= -dc: {RDN} -aci: (target=ldap:///{SUFFIX})(targetattr=*)(version 3.0; acl "acl1"; allow(write) userdn = "ldap:///self";) ->>>>>>> 8fa838a4f... Ticket 49830 - Import fails if backend name is "default" aci: (target=ldap:///{SUFFIX})(targetattr=*)(version 3.0; acl "acl2"; allow(write) groupdn = "ldap:///cn=Directory Administrators, {SUFFIX}";) aci: (target=ldap:///{SUFFIX})(targetattr=*)(version 3.0; acl "acl3"; allow(read, search, compare) userdn = "ldap:///anyone";) @@ -150,7 +145,7 @@ ou: Payroll """ -def dbgen(instance, number, ldif_file, suffix, pseudol10n=False): +def dbgen(instance, number, ldif_file, suffix): familyname_file = os.path.join(instance.ds_paths.data_dir, 'dirsrv/data/dbgen-FamilyNames') givename_file = os.path.join(instance.ds_paths.data_dir, 'dirsrv/data/dbgen-GivenNames') familynames = [] @@ -161,11 +156,7 @@ def dbgen(instance, number, ldif_file, suffix, pseudol10n=False): givennames = [n.strip() for n in f] with open(ldif_file, 'w') as output: - rdn = suffix.split(",", 1)[0].split("=", 1)[1] - output.write(DBGEN_HEADER.format(SUFFIX=suffix, RDN=rdn)) - for ou in DBGEN_OUS: - ou = pseudolocalize(ou) if pseudol10n else ou - output.write(DBGEN_OU_TEMPLATE.format(SUFFIX=suffix, OU=ou)) + output.write(DBGEN_HEADER.format(SUFFIX=suffix)) for i in range(0, number): # Pick a random ou ou = random.choice(DBGEN_OUS) From 78d383d7628dc27f9378017c70d89c3726eade78 Mon Sep 17 00:00:00 2001 From: Viktor Ashirov Date: Mar 12 2019 06:37:17 +0000 Subject: [PATCH 2/3] Issue 49530 - Add pseudolocalization option for dbgen Bug Description: Pseudolocalization can be used to test matching rules and indexing of UTF-8 strings in various attributes. Fix Description: Add new function 'pseudlocalize' to utils module of lib389 that accepts string and returns pseudolocalized string. For example: "389 Directory Server" will become "③⑧⑨ Ðîŕéçţöŕý Šéŕṽéŕ" Add new optional argument 'pseudol10n' for dbgen module that is False by default. If True, attributes like cn, sn, title, description, etc will be pseudolocalized. https://pagure.io/389-ds-base/issue/49530 Reviewed by: lkrispen, tbordaz, spichugi (Thank you all!) (cherry picked from commit b6c1221eb131f67b44b6f3b09660fa3be56447bd) --- diff --git a/src/lib389/lib389/dbgen.py b/src/lib389/lib389/dbgen.py index a0cda94..e0099a7 100644 --- a/src/lib389/lib389/dbgen.py +++ b/src/lib389/lib389/dbgen.py @@ -8,6 +8,7 @@ # Replacement of the dbgen.pl utility +from lib389.utils import pseudolocalize import random import os import pwd @@ -95,7 +96,7 @@ roomNumber: 5164 carLicense: 21SJJAG l: {LOCATION} ou: {OU} -mail: {FIRST}.{LAST}@example.com +mail: {UID}@example.com postalAddress: 518, Dept #851, Room#{OU} title: {TITLE} usercertificate;binary:: MIIBvjCCASegAwIBAgIBAjANBgkqhkiG9w0BAQQFADAnMQ8wDQYD @@ -114,38 +115,20 @@ DBGEN_HEADER = """dn: {SUFFIX} objectClass: top objectClass: domain dc: example -aci: (target=ldap:///{SUFFIX})(targetattr=*)(version 3.0; acl "acl1"; allow(write) userdn = "ldap:///self";) +aci: (target=ldap:///{SUFFIX})(targetattr=*)(version 3.0; acl "acl1"; allow(write) userdn = "ldap:///self";) aci: (target=ldap:///{SUFFIX})(targetattr=*)(version 3.0; acl "acl2"; allow(write) groupdn = "ldap:///cn=Directory Administrators, {SUFFIX}";) aci: (target=ldap:///{SUFFIX})(targetattr=*)(version 3.0; acl "acl3"; allow(read, search, compare) userdn = "ldap:///anyone";) -dn: ou=Accounting,{SUFFIX} -objectClass: top -objectClass: organizationalUnit -ou: Accounting - -dn: ou=Product Development,{SUFFIX} -objectClass: top -objectClass: organizationalUnit -ou: Product Development - -dn: ou=Product Testing,{SUFFIX} -objectClass: top -objectClass: organizationalUnit -ou: Product Testing - -dn: ou=Human Resources,{SUFFIX} -objectClass: top -objectClass: organizationalUnit -ou: Human Resources +""" -dn: ou=Payroll,{SUFFIX} +DBGEN_OU_TEMPLATE = """dn: ou={OU},{SUFFIX} objectClass: top objectClass: organizationalUnit -ou: Payroll +ou: {OU} """ -def dbgen(instance, number, ldif_file, suffix): +def dbgen(instance, number, ldif_file, suffix, pseudol10n=False): familyname_file = os.path.join(instance.ds_paths.data_dir, 'dirsrv/data/dbgen-FamilyNames') givename_file = os.path.join(instance.ds_paths.data_dir, 'dirsrv/data/dbgen-GivenNames') familynames = [] @@ -157,6 +140,9 @@ def dbgen(instance, number, ldif_file, suffix): with open(ldif_file, 'w') as output: output.write(DBGEN_HEADER.format(SUFFIX=suffix)) + for ou in DBGEN_OUS: + ou = pseudolocalize(ou) if pseudol10n else ou + output.write(DBGEN_OU_TEMPLATE.format(SUFFIX=suffix, OU=ou)) for i in range(0, number): # Pick a random ou ou = random.choice(DBGEN_OUS) @@ -165,9 +151,16 @@ def dbgen(instance, number, ldif_file, suffix): # How do we subscript from a generator? initials = "%s. %s" % (first[0], last[0]) uid = "%s%s%s" % (first[0], last, i) - dn = "uid=%s,ou=%s,%s" % (uid, ou, suffix) l = random.choice(DBGEN_LOCATIONS) title = "%s %s" % (random.choice(DBGEN_TITLE_LEVELS), random.choice(DBGEN_POSITIONS)) + if pseudol10n: + ou = pseudolocalize(ou) + first = pseudolocalize(first) + last = pseudolocalize(last) + initials = pseudolocalize(initials) + l = pseudolocalize(l) + title = pseudolocalize(title) + dn = "uid=%s,ou=%s,%s" % (uid, ou, suffix) output.write(DBGEN_TEMPLATE.format( DN=dn, UID=uid, @@ -187,5 +180,3 @@ def dbgen(instance, number, ldif_file, suffix): uid = pwd.getpwnam(instance.userid).pw_uid gid = grp.getgrnam(instance.userid).gr_gid os.chown(ldif_file, uid, gid) - - diff --git a/src/lib389/lib389/utils.py b/src/lib389/lib389/utils.py index 70748a6..74a7d21 100644 --- a/src/lib389/lib389/utils.py +++ b/src/lib389/lib389/utils.py @@ -32,6 +32,7 @@ import socket import time import sys import filecmp +import six from socket import getfqdn from ldapurl import LDAPUrl from contextlib import closing @@ -75,6 +76,105 @@ searches = { '(&(objectclass=glue)(objectclass=extensibleobject))', ['dn']) } +# Map table for pseudolocalized strings +_chars = { + " ": six.u("\u2003"), + "!": six.u("\u00a1"), + "\"": six.u("\u2033"), + "#": six.u("\u266f"), + "$": six.u("\u20ac"), + "%": six.u("\u2030"), + "&": six.u("\u214b"), + "'": six.u("\u00b4"), + ")": six.u("}"), + "(": six.u("{"), + "*": six.u("\u204e"), + "+": six.u("\u207a"), + ",": six.u("\u060c"), + "-": six.u("\u2010"), + ".": six.u("\u00b7"), + "/": six.u("\u2044"), + "0": six.u("\u24ea"), + "1": six.u("\u2460"), + "2": six.u("\u2461"), + "3": six.u("\u2462"), + "4": six.u("\u2463"), + "5": six.u("\u2464"), + "6": six.u("\u2465"), + "7": six.u("\u2466"), + "8": six.u("\u2467"), + "9": six.u("\u2468"), + ":": six.u("\u2236"), + ";": six.u("\u204f"), + "<": six.u("\u2264"), + "=": six.u("\u2242"), + ">": six.u("\u2265"), + "?": six.u("\u00bf"), + "@": six.u("\u055e"), + "A": six.u("\u00c5"), + "B": six.u("\u0181"), + "C": six.u("\u00c7"), + "D": six.u("\u00d0"), + "E": six.u("\u00c9"), + "F": six.u("\u0191"), + "G": six.u("\u011c"), + "H": six.u("\u0124"), + "I": six.u("\u00ce"), + "J": six.u("\u0134"), + "K": six.u("\u0136"), + "L": six.u("\u013b"), + "M": six.u("\u1e40"), + "N": six.u("\u00d1"), + "O": six.u("\u00d6"), + "P": six.u("\u00de"), + "Q": six.u("\u01ea"), + "R": six.u("\u0154"), + "S": six.u("\u0160"), + "T": six.u("\u0162"), + "U": six.u("\u00db"), + "V": six.u("\u1e7c"), + "W": six.u("\u0174"), + "X": six.u("\u1e8a"), + "Y": six.u("\u00dd"), + "Z": six.u("\u017d"), + "[": six.u("\u2045"), + "\\": six.u("\u2216"), + "]": six.u("\u2046"), + "^": six.u("\u02c4"), + "_": six.u("\u203f"), + "`": six.u("\u2035"), + "a": six.u("\u00e5"), + "b": six.u("\u0180"), + "c": six.u("\u00e7"), + "d": six.u("\u00f0"), + "e": six.u("\u00e9"), + "f": six.u("\u0192"), + "g": six.u("\u011d"), + "h": six.u("\u0125"), + "i": six.u("\u00ee"), + "j": six.u("\u0135"), + "k": six.u("\u0137"), + "l": six.u("\u013c"), + "m": six.u("\u0271"), + "n": six.u("\u00f1"), + "o": six.u("\u00f6"), + "p": six.u("\u00fe"), + "q": six.u("\u01eb"), + "r": six.u("\u0155"), + "s": six.u("\u0161"), + "t": six.u("\u0163"), + "u": six.u("\u00fb"), + "v": six.u("\u1e7d"), + "w": six.u("\u0175"), + "x": six.u("\u1e8b"), + "y": six.u("\u00fd"), + "z": six.u("\u017e"), + "{": six.u("("), + "}": six.u(")"), + "|": six.u("\u00a6"), + "~": six.u("\u02de"), +} + # # Utilities # @@ -871,3 +971,13 @@ def ensure_dict_str(val): else: retdict[k] = ensure_str(val[k]) return retdict + + +def pseudolocalize(string): + pseudo_string = six.u("") + for char in string: + try: + pseudo_string += _chars[char] + except KeyError: + pseudo_string += char + return pseudo_string From da2bc5ef6ba5e5be916f388aaf13897a6ed6e815 Mon Sep 17 00:00:00 2001 From: Mark Reynolds Date: Mar 12 2019 06:37:17 +0000 Subject: [PATCH 3/3] Ticket 49830 - Import fails if backend name is "default" Bug Description: The server was previously reserving the backend name "default". If you tried to import on a backend with this name the import would skip all child entries Fix Description: Change the default backend name to something obscure, instead of "default". Also improved lib389's dbgen to generate the correct "dc" attribute value in the root node. https://pagure.io/389-ds-base/issue/49830 Reviewed by: spichugi(Thanks!) (cherry picked from commit 8fa838a4ffd4d0c15ae51cb21f246bb1f2dea2a1) --- diff --git a/dirsrvtests/tests/suites/import/regression_test.py b/dirsrvtests/tests/suites/import/regression_test.py index ad51721..d83d003 100644 --- a/dirsrvtests/tests/suites/import/regression_test.py +++ b/dirsrvtests/tests/suites/import/regression_test.py @@ -23,6 +23,52 @@ TEST_SUFFIX1 = "dc=importest1,dc=com" TEST_BACKEND1 = "importest1" TEST_SUFFIX2 = "dc=importest2,dc=com" TEST_BACKEND2 = "importest2" +TEST_DEFAULT_SUFFIX = "dc=default,dc=com" +TEST_DEFAULT_NAME = "default" + + +def test_import_be_default(topo): + """ Create a backend using the name "default". previously this name was + used int + + :id: 8e507beb-e917-4330-8cac-1ff0eee10508 + :feature: Import + :setup: Standalone instance + :steps: + 1. Create a test suffix using the be name of "default" + 2. Create an ldif for the "default" backend + 3. Import ldif + 4. Verify all entries were imported + :expectedresults: + 1. Success + 2. Success + 3. Success + 4. Success + """ + log.info('Adding suffix:{} and backend: {}...'.format(TEST_DEFAULT_SUFFIX, + TEST_DEFAULT_NAME)) + backends = Backends(topo.standalone) + backends.create(properties={BACKEND_SUFFIX: TEST_DEFAULT_SUFFIX, + BACKEND_NAME: TEST_DEFAULT_NAME}) + + log.info('Create LDIF file and import it...') + ldif_dir = topo.standalone.get_ldif_dir() + ldif_file = os.path.join(ldif_dir, 'default.ldif') + dbgen(topo.standalone, 5, ldif_file, TEST_DEFAULT_SUFFIX) + + log.info('Stopping the server and running offline import...') + topo.standalone.stop() + assert topo.standalone.ldif2db(TEST_DEFAULT_NAME, None, None, + None, ldif_file) + topo.standalone.start() + + log.info('Verifying entry count after import...') + entries = topo.standalone.search_s(TEST_DEFAULT_SUFFIX, + ldap.SCOPE_SUBTREE, + "(objectclass=*)") + assert len(entries) > 1 + + log.info('Test PASSED') def test_del_suffix_import(topo): diff --git a/ldap/servers/slapd/defbackend.c b/ldap/servers/slapd/defbackend.c index aa709da..b0465e2 100644 --- a/ldap/servers/slapd/defbackend.c +++ b/ldap/servers/slapd/defbackend.c @@ -23,8 +23,6 @@ /* * ---------------- Macros --------------------------------------------------- */ -#define DEFBACKEND_TYPE "default" - #define DEFBACKEND_OP_NOT_HANDLED 0 #define DEFBACKEND_OP_HANDLED 1 @@ -65,7 +63,7 @@ defbackend_init(void) /* * create a new backend */ - defbackend_backend = slapi_be_new(DEFBACKEND_TYPE, DEFBACKEND_TYPE, 1 /* Private */, 0 /* Do Not Log Changes */); + defbackend_backend = slapi_be_new(DEFBACKEND_TYPE, DEFBACKEND_NAME, 1 /* Private */, 0 /* Do Not Log Changes */); if ((rc = slapi_pblock_set(pb, SLAPI_BACKEND, defbackend_backend)) != 0) { errmsg = "slapi_pblock_set SLAPI_BACKEND failed"; goto cleanup_and_return; diff --git a/ldap/servers/slapd/mapping_tree.c b/ldap/servers/slapd/mapping_tree.c index 472a2f6..834949a 100644 --- a/ldap/servers/slapd/mapping_tree.c +++ b/ldap/servers/slapd/mapping_tree.c @@ -748,7 +748,7 @@ mapping_tree_entry_add(Slapi_Entry *entry, mapping_tree_node **newnodep) be_names = (char **)slapi_ch_calloc(1, sizeof(char *)); be_states = (int *)slapi_ch_calloc(1, sizeof(int)); - tmp_backend_name = (char *)slapi_ch_strdup("default"); /* "NULL_CONTAINER" */ + tmp_backend_name = (char *)slapi_ch_strdup(DEFBACKEND_NAME); /* "NULL_CONTAINER" */ (be_names)[be_list_count] = tmp_backend_name; /* set backend as started by default */ @@ -2250,7 +2250,10 @@ slapi_mapping_tree_select_all(Slapi_PBlock *pb, Slapi_Backend **be_list, Slapi_E if (ret != LDAP_SUCCESS) { /* flag we have problems at least on part of the tree */ flag_partial_result = 1; - } else if ((((!slapi_sdn_issuffix(sdn, slapi_mtn_get_dn(node)) && !slapi_sdn_issuffix(slapi_mtn_get_dn(node), sdn))) || ((node_list == mapping_tree_root) && node->mtn_private && (scope != LDAP_SCOPE_BASE))) && (!be || strncmp(be->be_name, "default", 8))) { + } else if ((((!slapi_sdn_issuffix(sdn, slapi_mtn_get_dn(node)) && !slapi_sdn_issuffix(slapi_mtn_get_dn(node), sdn))) || + ((node_list == mapping_tree_root) && node->mtn_private && (scope != LDAP_SCOPE_BASE))) && + (!be || strncmp(be->be_name, DEFBACKEND_NAME, 8))) + { if (be && !be_isdeleted(be)) { /* wrong backend or referall, ignore it */ slapi_log_err(SLAPI_LOG_ARGS, "slapi_mapping_tree_select_all", diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h index 3b7e58d..a027926 100644 --- a/ldap/servers/slapd/slap.h +++ b/ldap/servers/slapd/slap.h @@ -45,6 +45,9 @@ static char ptokPBE[34] = "Internal (Software) Token "; #define SLAPD_EXEMODE_DBVERIFY 12 #define SLAPD_EXEMODE_UPGRADEDNFORMAT 13 +#define DEFBACKEND_TYPE "default" +#define DEFBACKEND_NAME "DirectoryServerDefaultBackend" + #define LDAP_SYSLOG #include #define RLIM_TYPE int diff --git a/src/lib389/lib389/dbgen.py b/src/lib389/lib389/dbgen.py index e0099a7..a9c5834 100644 --- a/src/lib389/lib389/dbgen.py +++ b/src/lib389/lib389/dbgen.py @@ -114,7 +114,7 @@ usercertificate;binary:: MIIBvjCCASegAwIBAgIBAjANBgkqhkiG9w0BAQQFADAnMQ8wDQYD DBGEN_HEADER = """dn: {SUFFIX} objectClass: top objectClass: domain -dc: example +dc: {RDN} aci: (target=ldap:///{SUFFIX})(targetattr=*)(version 3.0; acl "acl1"; allow(write) userdn = "ldap:///self";) aci: (target=ldap:///{SUFFIX})(targetattr=*)(version 3.0; acl "acl2"; allow(write) groupdn = "ldap:///cn=Directory Administrators, {SUFFIX}";) aci: (target=ldap:///{SUFFIX})(targetattr=*)(version 3.0; acl "acl3"; allow(read, search, compare) userdn = "ldap:///anyone";) @@ -128,6 +128,7 @@ ou: {OU} """ + def dbgen(instance, number, ldif_file, suffix, pseudol10n=False): familyname_file = os.path.join(instance.ds_paths.data_dir, 'dirsrv/data/dbgen-FamilyNames') givename_file = os.path.join(instance.ds_paths.data_dir, 'dirsrv/data/dbgen-GivenNames') @@ -139,7 +140,8 @@ def dbgen(instance, number, ldif_file, suffix, pseudol10n=False): givennames = [n.strip() for n in f] with open(ldif_file, 'w') as output: - output.write(DBGEN_HEADER.format(SUFFIX=suffix)) + rdn = suffix.split(",", 1)[0].split("=", 1)[1] + output.write(DBGEN_HEADER.format(SUFFIX=suffix, RDN=rdn)) for ou in DBGEN_OUS: ou = pseudolocalize(ou) if pseudol10n else ou output.write(DBGEN_OU_TEMPLATE.format(SUFFIX=suffix, OU=ou))