[389-devel] Please review: add support for ldif files with changetype: add

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





From 7950cbb484f6b517cd00fec4cdde93fc305ca01c Mon Sep 17 00:00:00 2001
From: Rich Megginson <rmeggins@xxxxxxxxxx>
Date: Mon, 27 Jun 2011 10:50:00 -0600
Subject: [PATCH 2/3] add support for ldif files with changetype: add

IPA config files use changetype: add to add new files.  This was not
supported by the DS ConfigFile directive or other LDIF processing.
Now, if we see that the entry has changetype: add, we process it as if
it had no changetype at all, which is to add the entry.  Remove
the changetype: from the entry before adding.
---
 ldap/admin/src/scripts/DSUtil.pm.in |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/ldap/admin/src/scripts/DSUtil.pm.in b/ldap/admin/src/scripts/DSUtil.pm.in
index d330d0b..16f46b6 100644
--- a/ldap/admin/src/scripts/DSUtil.pm.in
+++ b/ldap/admin/src/scripts/DSUtil.pm.in
@@ -306,7 +306,7 @@ sub check_and_add_entry
     } else {
         debug(3, "check_and_add_entry: Entry not found " . $aentry->{dn} .
               " error " . $conn->getErrorString() . "\n");
-        if (@ctypes) { # uh oh - attempt to del/mod an entry that doesn't exist
+        if (@ctypes and !("add" eq lc($ctypes[0]))) { # uh oh - attempt to del/mod an entry that doesn't exist
             debug(3, "check_and_add_entry: attepting to @ctypes the entry " . $aentry->{dn} .
                   " that does not exist\n");
             return 1; # ignore - return success
@@ -323,7 +323,7 @@ sub check_and_add_entry
         my $OP_DEL = 3;
         # $op stores either of the above $OP_ values
         my $op = $OP_NONE;
-        if ( 0 > $#ctypes )    # aentry: complete entry
+        if ( (0 > $#ctypes) or ("add" eq lc($ctypes[0])) )    # aentry: complete entry
         {
             $op = $OP_ADD; # just add the entry
         }
@@ -351,6 +351,10 @@ sub check_and_add_entry
 
         if ( $OP_ADD == $op )
         {
+            if ("add" eq lc($ctypes[0])) {
+                # remove the changetype: add from the entry
+                $aentry->remove('changetype');
+            }
             $conn->add($aentry);
             my $rc = $conn->getErrorCode();
             if ( $rc != 0 )
-- 
1.7.1

--
389-devel mailing list
389-devel@xxxxxxxxxxxxxxxxxxxxxxx
https://admin.fedoraproject.org/mailman/listinfo/389-devel

[Index of Archives]     [Fedora Directory Announce]     [Fedora Users]     [Older Fedora Users Mail]     [Fedora Advisory Board]     [Fedora Security]     [Fedora Devel Java]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Mentors]     [Fedora Package Review]     [Fedora Art]     [Fedora Music]     [Fedora Packaging]     [CentOS]     [Fedora SELinux]     [Big List of Linux Books]     [KDE Users]     [Fedora Art]     [Fedora Docs]

  Powered by Linux