andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
dc8c34
From e7c1daf76b8c443b848ea988c3772f2be41eed0c Mon Sep 17 00:00:00 2001
dc8c34
From: Nathan Kinder <nkinder@redhat.com>
dc8c34
Date: Fri, 4 Jan 2013 11:41:48 -0800
dc8c34
Subject: [PATCH] Ticket 549 - DNA plugin no longer reports additional info
dc8c34
 when range is depleted
dc8c34
dc8c34
When the DNA plug-in was modified to allocate range values at the
dc8c34
bepreop phase, it stopped returning detailed error strings to the
dc8c34
client when the range was depleted.
dc8c34
dc8c34
This patch allows our bepreop functions to fill in the error string
dc8c34
that the caller can return to the client.
dc8c34
(cherry picked from commit 3b177a768a48857f9dcb891a7dd3c8f8d9a220a4)
dc8c34
---
dc8c34
 ldap/servers/plugins/dna/dna.c | 32 ++++++++++++++++++++++++++++----
dc8c34
 1 file changed, 28 insertions(+), 4 deletions(-)
dc8c34
dc8c34
diff --git a/ldap/servers/plugins/dna/dna.c b/ldap/servers/plugins/dna/dna.c
dc8c34
index 66d4a05..36dd936 100644
dc8c34
--- a/ldap/servers/plugins/dna/dna.c
dc8c34
+++ b/ldap/servers/plugins/dna/dna.c
dc8c34
@@ -2759,7 +2759,7 @@ dna_create_valcheck_filter(struct configEntry *config_entry, PRUint64 value, cha
dc8c34
 /* This function is called at BEPREOP timing to add uid/gidNumber 
dc8c34
  * if modtype is missing */
dc8c34
 static int
dc8c34
-_dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e)
dc8c34
+_dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e, char **errstr)
dc8c34
 {
dc8c34
     int ret = 0;
dc8c34
     PRCList *list = NULL;
dc8c34
@@ -2886,6 +2886,10 @@ _dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e)
dc8c34
                         if (LDAP_SUCCESS != ret) {
dc8c34
                             slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
dc8c34
                                             "dna_pre_op: no more values available!!\n");
dc8c34
+                            /* Set an error string to be returned to the client. */
dc8c34
+                            *errstr = slapi_ch_smprintf("Allocation of a new value for range"
dc8c34
+                                               " %s failed! Unable to proceed.",
dc8c34
+                                               config_entry->dn);
dc8c34
                             slapi_unlock_mutex(config_entry->lock);
dc8c34
                             break;
dc8c34
                         }
dc8c34
@@ -2895,6 +2899,10 @@ _dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e)
dc8c34
                         if (LDAP_SUCCESS != ret){
dc8c34
                             slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
dc8c34
                                             "dna_pre_op: failed to allocate a new ID\n");
dc8c34
+                            /* Set an error string to be returned to the client. */
dc8c34
+                            *errstr = slapi_ch_smprintf("Allocation of a new value for range"
dc8c34
+                                               " %s failed! Unable to proceed.",
dc8c34
+                                               config_entry->dn);
dc8c34
                             slapi_unlock_mutex(config_entry->lock);
dc8c34
                             break;
dc8c34
                         }
dc8c34
@@ -2902,6 +2910,10 @@ _dna_pre_op_add(Slapi_PBlock *pb, Slapi_Entry *e)
dc8c34
                         /* dna_first_free_value() failed for some unknown reason */
dc8c34
                         slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
dc8c34
                                         "dna_pre_op: failed to allocate a new ID!!\n");
dc8c34
+                        /* Set an error string to be returned to the client. */
dc8c34
+                        *errstr = slapi_ch_smprintf("Allocation of a new value for range"
dc8c34
+                                               " %s failed! Unable to proceed.",
dc8c34
+                                               config_entry->dn);
dc8c34
                         slapi_unlock_mutex(config_entry->lock);
dc8c34
                         break;
dc8c34
                     }
dc8c34
@@ -2943,7 +2955,7 @@ bail:
dc8c34
 /* This function is called at BEPREOP timing to add uid/gidNumber 
dc8c34
  * if modtype is missing */
dc8c34
 static int
dc8c34
-_dna_pre_op_modify(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Mods *smods)
dc8c34
+_dna_pre_op_modify(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Mods *smods, char **errstr)
dc8c34
 {
dc8c34
     int ret = 0;
dc8c34
     PRCList *list = NULL;
dc8c34
@@ -3144,6 +3156,10 @@ _dna_pre_op_modify(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Mods *smods)
dc8c34
                         if (LDAP_SUCCESS != ret) {
dc8c34
                             slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
dc8c34
                                             "dna_pre_op: no more values available!!\n");
dc8c34
+                            /* Set an error string to be returned to the client. */
dc8c34
+                            *errstr = slapi_ch_smprintf("Allocation of a new value for range"
dc8c34
+                                               " %s failed! Unable to proceed.",
dc8c34
+                                               config_entry->dn);
dc8c34
                             slapi_unlock_mutex(config_entry->lock);
dc8c34
                             break;
dc8c34
                         }
dc8c34
@@ -3153,6 +3169,10 @@ _dna_pre_op_modify(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Mods *smods)
dc8c34
                         if (LDAP_SUCCESS != ret){
dc8c34
                             slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
dc8c34
                                             "dna_pre_op: failed to allocate a new ID\n");
dc8c34
+                            /* Set an error string to be returned to the client. */
dc8c34
+                            *errstr = slapi_ch_smprintf("Allocation of a new value for range"
dc8c34
+                                               " %s failed! Unable to proceed.",
dc8c34
+                                               config_entry->dn);
dc8c34
                             slapi_unlock_mutex(config_entry->lock);
dc8c34
                             break;
dc8c34
                         }
dc8c34
@@ -3160,6 +3180,10 @@ _dna_pre_op_modify(Slapi_PBlock *pb, Slapi_Entry *e, Slapi_Mods *smods)
dc8c34
                         /* dna_first_free_value() failed for some unknown reason */
dc8c34
                         slapi_log_error(SLAPI_LOG_FATAL, DNA_PLUGIN_SUBSYSTEM,
dc8c34
                                         "dna_pre_op: failed to allocate a new ID!!\n");
dc8c34
+                        /* Set an error string to be returned to the client. */
dc8c34
+                        *errstr = slapi_ch_smprintf("Allocation of a new value for range"
dc8c34
+                                           " %s failed! Unable to proceed.",
dc8c34
+                                           config_entry->dn);
dc8c34
                         slapi_unlock_mutex(config_entry->lock);
dc8c34
                         break;
dc8c34
                     }
dc8c34
@@ -3287,9 +3311,9 @@ dna_pre_op(Slapi_PBlock * pb, int modtype)
dc8c34
         }
dc8c34
     } else {
dc8c34
         if (LDAP_CHANGETYPE_ADD == modtype) {
dc8c34
-            ret = _dna_pre_op_add(pb, test_e);
dc8c34
+            ret = _dna_pre_op_add(pb, test_e, &errstr);
dc8c34
         } else {
dc8c34
-            if((ret = _dna_pre_op_modify(pb, test_e, smods))){
dc8c34
+            if((ret = _dna_pre_op_modify(pb, test_e, smods, &errstr))){
dc8c34
             	slapi_mods_free(&smods);
dc8c34
             }
dc8c34
         }
dc8c34
-- 
dc8c34
1.7.11.7
dc8c34