]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-ldbm/alias.c
Removed unnecessary definition that is already in core.schema.
[openldap] / servers / slapd / back-ldbm / alias.c
index d328cc8d17536b25354c9fa4e735f798ef0e83e2..93efcf6ca45a9db797a3cf4fa02107b4df496643 100644 (file)
@@ -13,8 +13,8 @@
 #include "portable.h"
 
 #include <stdio.h>
-#include <string.h>
-#include <ac/socket.h>         /* Get struct sockaddr for slap.h */
+#include <ac/string.h>
+#include <ac/socket.h>
 #include "slap.h"
 #include "back-ldbm.h"
 #include "proto-back-ldbm.h"
@@ -31,7 +31,6 @@ Entry *derefAlias_r ( Backend     *be,
   struct ldbminfo *li = (struct ldbminfo *) be->be_private; /* to free cache entries */
   Attribute *a;
   int       depth;
-  char      **pastAliases;
   char      *matched;
   Entry     *origDN = e;
 
@@ -75,7 +74,7 @@ Entry *derefAlias_r ( Backend     *be,
        Debug( LDAP_DEBUG_TRACE, 
               "<= %s alias is same as current %s\n", 
               oldDN, newDN, 0 );
-       send_ldap_result( conn, op, LDAP_ALIAS_PROBLEM, "",
+       send_ldap_result( conn, op, LDAP_ALIAS_DEREF_PROBLEM, "",
                          "Circular alias" );
        free (newDN);
        free (oldDN);
@@ -87,7 +86,7 @@ Entry *derefAlias_r ( Backend     *be,
        Debug( LDAP_DEBUG_TRACE, 
               "<= %s alias is same as original %s\n", 
               oldDN, origDN->e_ndn, 0 );
-       send_ldap_result( conn, op, LDAP_ALIAS_PROBLEM, "",
+       send_ldap_result( conn, op, LDAP_ALIAS_DEREF_PROBLEM, "",
                          "Circular alias" );
        free (newDN);
        free (oldDN);
@@ -278,15 +277,17 @@ char *derefDN ( Backend     *be,
    * e.g. if we had started with dn = o=MyAliasedOrg,c=MyCountry the dn would match
    * and the above loop complete but we would still be left with an aliased DN.
    */
-  if ( (eNew = dn2entry_r( be, newDN, &matched )) != NULL) {
-    if ((eDeref = derefAlias_r( be, conn, op, eNew )) != NULL) {
-      free (newDN);
-      newDN = ch_strdup (eDeref->e_dn);
+  if (newDN != NULL) {
+    if ( (eNew = dn2entry_r( be, newDN, &matched )) != NULL) {
+      if ((eDeref = derefAlias_r( be, conn, op, eNew )) != NULL) {
+        free (newDN);
+        newDN = ch_strdup (eDeref->e_dn);
+        /* free reader lock */
+        cache_return_entry_r(&li->li_cache, eDeref);
+      }
       /* free reader lock */
-      cache_return_entry_r(&li->li_cache, eDeref);
+      cache_return_entry_r(&li->li_cache, eNew);
     }
-    /* free reader lock */
-    cache_return_entry_r(&li->li_cache, eNew);
   }
   if (matched != NULL) free(matched);