diff options
author | Noriko Hosoi <nhosoi@redhat.com> | 2010-01-22 09:47:52 -0800 |
---|---|---|
committer | Noriko Hosoi <nhosoi@jiji.localdomain> | 2010-01-22 10:36:16 -0800 |
commit | b5e653a844af60596f9bc6b16349ee902ddb51f5 (patch) | |
tree | d22f47113e303de236e9a9b01376cb6e3d14486f /ldap/admin | |
parent | 4d93699a71acb061c5787d2b8b61a0417ce02808 (diff) | |
download | ds-b5e653a844af60596f9bc6b16349ee902ddb51f5.tar.gz ds-b5e653a844af60596f9bc6b16349ee902ddb51f5.tar.xz ds-b5e653a844af60596f9bc6b16349ee902ddb51f5.zip |
Allow modrdn to move subtree and rename non-leaf node
This patch includes
- replacing the entrydn index with the entryrdn index
- replacing a full DN in each entry in the DB with an RDN
- extending Slapi_Entry, entry2str, and str2entry to absorb the changes
made on the entry
- adding DN/RDN helper functions
- adding DN cache
- adding a utility and a migration script to convert the DN format database
to the RDN format
- extending a database dump utility dbscan to support the entryrdn
- slapi_dn_syntax_check by nkinder@redhat.com is added to check the dn before
modify operations
- big fix for 171338 - Enhancement: winsync modrdn not synced
In addition to the above, compile warnings and memory leaks found in testing
the new feature are fixed.
For more details, see the feature design document at:
http://directory.fedoraproject.org/wiki/Subtree_Rename
and bugzilla at:
https://bugzilla.redhat.com/show_bug.cgi?id=171338
Diffstat (limited to 'ldap/admin')
-rw-r--r-- | ldap/admin/src/scripts/90subtreerename.pl | 52 | ||||
-rw-r--r-- | ldap/admin/src/scripts/DSUpdate.pm.in | 2 | ||||
-rwxr-xr-x | ldap/admin/src/scripts/template-dn2rdn.in | 24 |
3 files changed, 77 insertions, 1 deletions
diff --git a/ldap/admin/src/scripts/90subtreerename.pl b/ldap/admin/src/scripts/90subtreerename.pl new file mode 100644 index 00000000..e4746d7b --- /dev/null +++ b/ldap/admin/src/scripts/90subtreerename.pl @@ -0,0 +1,52 @@ +use Mozilla::LDAP::Conn; +use Mozilla::LDAP::Utils qw(normalizeDN); +use Mozilla::LDAP::API qw(:constant ldap_url_parse ldap_explode_dn); + +sub runinst { + my ($inf, $inst, $dseldif, $conn) = @_; + + my @errs; + + my $ent0 = $conn->search("cn=config", "base", "(objectclass=*)"); + if (!$ent0) { + return ('error_finding_config_entry', 'cn=config', + $conn->getErrorString()); + } + my $rundir = $ent0->getValues('nsslapd-rundir'); + + # Check if the server is up or not + my $pidfile = $rundir . "/" . $inst . ".pid"; + if (-e $pidfile) { + return (); # server is running; do nothing. + } + + my $ent1 = $conn->search("cn=config,cn=ldbm database,cn=plugins,cn=config", + "base", "(objectclass=*)"); + if (!$ent1) { + return ('error_finding_config_entry', + 'cn=config,cn=ldbm database,cn=plugins,cn=config', + $conn->getErrorString()); + } + + # Get the value of nsslapd-subtree-rename-switch. + my $need_update = 0; + my $switch = $ent1->getValues('nsslapd-subtree-rename-switch'); + if ("" eq $switch) { + $ent1->addValue('nsslapd-subtree-rename-switch', "on"); + $need_update = 1; + } elsif ("off" eq $switch || "OFF" eq $switch) { + $ent1->setValues('nsslapd-subtree-rename-switch', "on"); + $need_update = 1; + } + + if (1 == $need_update) { + $conn->update($ent1); + # Convert the database format from entrydn to entryrdn + my $instdir = $ent0->getValue('nsslapd-instancedir'); + my $prog = $instdir . "/dn2rdn"; + my $output = `$prog 2>&1`; + my $stat = $?; + } + + return (); +} diff --git a/ldap/admin/src/scripts/DSUpdate.pm.in b/ldap/admin/src/scripts/DSUpdate.pm.in index 20bb40d1..3792afe2 100644 --- a/ldap/admin/src/scripts/DSUpdate.pm.in +++ b/ldap/admin/src/scripts/DSUpdate.pm.in @@ -449,7 +449,7 @@ sub initInfFromInst { $inf->{slapd}->{bak_dir} = $entry->getValue('nsslapd-bakdir'); } if (!$inf->{slapd}->{config_dir}) { - $inf->{slapd}->{config_dir} = $configdir; + $inf->{slapd}->{config_dir} = $configdir."/".$inst; } if (!$inf->{slapd}->{inst_dir}) { $inf->{slapd}->{inst_dir} = $entry->getValue('nsslapd-instancedir'); diff --git a/ldap/admin/src/scripts/template-dn2rdn.in b/ldap/admin/src/scripts/template-dn2rdn.in new file mode 100755 index 00000000..f8232df1 --- /dev/null +++ b/ldap/admin/src/scripts/template-dn2rdn.in @@ -0,0 +1,24 @@ +#!/bin/sh + +prefix="{{DS-ROOT}}" +if [ "$prefix" = "/" ] ; then + prefix="" +fi +LD_LIBRARY_PATH=$prefix/{{SERVER-DIR}}:$prefix@nss_libdir@:$prefix@libdir@ +if [ -n "$prefix" ] ; then + LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:@nss_libdir@" +fi +export LD_LIBRARY_PATH +SHLIB_PATH=$LD_LIBRARY_PATH +export SHLIB_PATH + +cd {{SERVERBIN-DIR}} +if [ $# -eq 0 ] +then + bak_dir={{BAK-DIR}}/reindex_`date +%Y_%m_%d_%H_%M_%S` + ./ns-slapd upgradedb -D {{CONFIG-DIR}} -f -r -a "$bak_dir" +else + echo "Usage: dn2rdn" + exit 1 +fi + |