osaf/services/saf/amf/amfd/ctcstype.cc    |  24 ++++++++++++++++
 osaf/services/saf/amf/amfd/imm.cc         |   7 ++--
 osaf/services/saf/amf/amfd/include/util.h |   1 +
 osaf/services/saf/amf/amfd/util.cc        |  45 +++++++++++++++++++++++++++++++
 4 files changed, 74 insertions(+), 3 deletions(-)


Note: This patch 1 of 2 was floated by Hans F. against the ticket #986.
This patch will not be pushed as a part of #1302.

AMF allows to create a SaAmfCtCsType object although the SaAmfCSType object
referred to does not exist.

Fix by looking up the SaAmfCSType DN in the SaAmfCSType database.

This patch will protect the creation of invalid SaAmfCtCsType and
configuration will not be added into the system.

diff --git a/osaf/services/saf/amf/amfd/ctcstype.cc 
b/osaf/services/saf/amf/amfd/ctcstype.cc
--- a/osaf/services/saf/amf/amfd/ctcstype.cc
+++ b/osaf/services/saf/amf/amfd/ctcstype.cc
@@ -20,8 +20,10 @@
 #include <immutil.h>
 #include <logtrace.h>
 
+#include <include/util.h>
 #include <comp.h>
 #include <imm.h>
+#include <include/csi.h>
 
 AmfDb<std::string, AVD_CTCS_TYPE> *ctcstype_db = NULL;
 
@@ -35,6 +37,28 @@ static int is_config_valid(const SaNameT
 {
        SaUint32T uint32;
        char *parent;
+       SaNameT cstype_dn;
+
+       if (get_child_dn_from_ass_dn(dn, &cstype_dn) != 0) {
+               report_ccb_validation_error(opdata, "malformed DN '%s'", 
dn->value);
+               return 0;
+       }
+
+       if (cstype_db->find(Amf::to_string(&cstype_dn)) == NULL) {
+               if (opdata == NULL) {
+                       report_ccb_validation_error(opdata,
+                               "SaAmfCSType object '%s' does not exist in 
model",
+                               cstype_dn.value);
+                       return 0;
+               }
+
+               if (ccbutil_getCcbOpDataByDN(opdata->ccbId, &cstype_dn) == 
NULL) {
+                       report_ccb_validation_error(opdata,
+                               "SaAmfCSType object '%s' does not exist in 
model or CCB",
+                               cstype_dn.value);
+                       return 0;
+               }
+       }
 
        /* Second comma should be parent */
        if ((parent = strchr((char*)dn->value, ',')) == NULL) {
diff --git a/osaf/services/saf/amf/amfd/imm.cc 
b/osaf/services/saf/amf/amfd/imm.cc
--- a/osaf/services/saf/amf/amfd/imm.cc
+++ b/osaf/services/saf/amf/amfd/imm.cc
@@ -1403,6 +1403,10 @@ unsigned int avd_imm_config_get(void)
        ** reported either. Off line tools can do this better.
        */
 
+       /* SaAmfCSType needed by validation of SaAmfCtCsType */
+       if (avd_cstype_config_get() != SA_AIS_OK)
+               goto done;
+
        /* SaAmfCompType indirectly needed by SaAmfSUType */
        if (avd_comptype_config_get() != SA_AIS_OK)
                goto done;
@@ -1421,9 +1425,6 @@ unsigned int avd_imm_config_get(void)
        if (avd_svctype_config_get() != SA_AIS_OK)
                goto done;
 
-       if (avd_cstype_config_get() != SA_AIS_OK)
-               goto done;
-
        if (avd_compglobalattrs_config_get() != SA_AIS_OK)
                goto done;
 
diff --git a/osaf/services/saf/amf/amfd/include/util.h 
b/osaf/services/saf/amf/amfd/include/util.h
--- a/osaf/services/saf/amf/amfd/include/util.h
+++ b/osaf/services/saf/amf/amfd/include/util.h
@@ -96,6 +96,7 @@ struct avd_comp_tag;
 struct avd_comp_csi_rel_tag;
 struct avd_csi_tag;
 
+int get_child_dn_from_ass_dn(const SaNameT *ass_dn, SaNameT *child_dn);
 void avd_d2n_reboot_snd(struct avd_avnd_tag *node);
 bool admin_op_is_valid(SaImmAdminOperationIdT opId, AVSV_AMF_CLASS_ID 
class_id);
 void amflog(int priority, const char *format, ...);
diff --git a/osaf/services/saf/amf/amfd/util.cc 
b/osaf/services/saf/amf/amfd/util.cc
--- a/osaf/services/saf/amf/amfd/util.cc
+++ b/osaf/services/saf/amf/amfd/util.cc
@@ -1823,3 +1823,48 @@ bool admin_op_is_valid(SaImmAdminOperati
        return valid;
 }
 
+ 
+ /**
+  * Gets child DN from an association DN
+  *   "safDepend=safSi=SC2-NoRed\,safApp=OpenSAF,safSi=SC-2N,safApp=OpenSAF"
+  * @param ass_dn association DN [in]
+  * @param child_dn [out]
+  * @return 0 at success
+  */
+ int get_child_dn_from_ass_dn(const SaNameT *ass_dn, SaNameT *child_dn)
+ {
+       SaNameT _ass_dn = *ass_dn;
+ 
+       /* find first comma and step past it */
+       char *p = strchr((char *)_ass_dn.value, ',');
+       if (p == NULL)
+               return -1;
+ 
+       p++;
+ 
+       /* find second comma, an error if not found */
+       p = strchr(p, ',');
+       if (p == NULL)
+               return -1;
+ 
+       *p = '\0';  /* null terminate at comma before parent */
+ 
+       /* Skip past the RDN tag */
+       p = strchr((char *)_ass_dn.value, '=');
+       if (p == NULL)
+               return -1;
+ 
+       p++;
+ 
+       /* copy and skip back slash */
+       int i = 0;
+       while (*p) {
+               if (*p != '\\')
+                       child_dn->value[i++] = *p;
+               p++;
+       }
+ 
+       child_dn->value[i] = '\0';
+       child_dn->length = i;
+       return 0;
+ }

------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to