osaf/services/saf/amf/amfd/ctcstype.cc | 14 +++++++++
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, 64 insertions(+), 3 deletions(-)
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.
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,18 @@ 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) {
+ report_ccb_validation_error(opdata,
+ "SaAmfCSType object '%s' does not exist",
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
@@ -1363,6 +1363,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;
@@ -1381,9 +1385,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);
void amflog(int priority, const char *format, ...);
void d2n_msg_free(AVD_DND_MSG *msg);
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
@@ -1717,3 +1717,48 @@ void amflog(int priority, const char *fo
saflog(priority, amfSvcUsrName, "%s", str);
}
}
+
+/**
+ * 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;
+}
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds. Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel