diff options
author | Jan Synacek <jsynacek@redhat.com> | 2013-02-14 15:27:17 +0100 |
---|---|---|
committer | Jan Synacek <jsynacek@redhat.com> | 2013-02-14 16:00:03 +0100 |
commit | 459197d2c4f39fea944299cdc22994b294d446c5 (patch) | |
tree | 4b997d65d7af052d46e296a78320aac66f2d3b96 /src | |
parent | 01a81cf733f25bbe8d988e557672b539e9fc3c1b (diff) | |
download | openlmi-providers-459197d2c4f39fea944299cdc22994b294d446c5.tar.gz openlmi-providers-459197d2c4f39fea944299cdc22994b294d446c5.tar.xz openlmi-providers-459197d2c4f39fea944299cdc22994b294d446c5.zip |
LogicalFile: update RootDirectory
Diffstat (limited to 'src')
-rw-r--r-- | src/logicalfile/LMI_RootDirectoryProvider.c | 62 |
1 files changed, 43 insertions, 19 deletions
diff --git a/src/logicalfile/LMI_RootDirectoryProvider.c b/src/logicalfile/LMI_RootDirectoryProvider.c index 4bcedf0..179d146 100644 --- a/src/logicalfile/LMI_RootDirectoryProvider.c +++ b/src/logicalfile/LMI_RootDirectoryProvider.c @@ -24,6 +24,23 @@ static const CMPIBroker* _cb; +static int check_valid_classes(const CMPIObjectPath *o) +{ + const char *VALID_CLASSES[] = { + "LMI_UnixDirectory", + "Linux_ComputerSystem", + NULL + }; + int found = 0; + for (int i = 0; VALID_CLASSES[i]; i++) { + if (CMClassPathIsA(_cb, o, VALID_CLASSES[i], NULL)) { + found++; + break; + } + } + return found; +} + static CMPIStatus associators( CMPIAssociationMI* mi, const CMPIContext* cc, @@ -42,6 +59,13 @@ static CMPIStatus associators( const char *ns = KNameSpace(cop); const char *comp_ccname = get_system_creation_class_name(); + /* + * allow only LMI_UnixDirectory and Linux_ComputerSystem + * XXX + */ + if (!check_valid_classes(cop)) { + CMReturn(CMPI_RC_OK); + } if (CMClassPathIsA(_cb, cop, LMI_UnixDirectory_ClassName, &st)) { /* got LMI_UnixDirectory */ @@ -98,10 +122,18 @@ static CMPIStatus references( const char *path = KChars(pathd.value.string); const char *ccname = KChars(cd.value.string); + /* + * allow only LMI_UnixDirectory and Linux_ComputerSystem + * XXX + */ + if (!check_valid_classes(cop)) { + CMReturn(CMPI_RC_OK); + } + LMI_RootDirectory_Init(&lmi_rd, _cb, ns); if (!strcmp(ccname, LMI_UnixDirectory_ClassName)) { - /* UnixDirectory */ + /* got UnixDirectory */ /* ignore this association if the directory is not root */ if (strcmp(path, "/")) { CMReturn(CMPI_RC_OK); @@ -110,7 +142,6 @@ static CMPIStatus references( if (st.rc != CMPI_RC_OK) { return st; } - LMI_RootDirectory_SetObjectPath_PartComponent(&lmi_rd, cop); CIM_ComputerSystemRef cim_csr; @@ -119,32 +150,25 @@ static CMPIStatus references( CIM_ComputerSystemRef_Set_CreationClassName(&cim_csr, comp_ccname); o = CIM_ComputerSystemRef_ToObjectPath(&cim_csr, &st); CMSetClassName(o, comp_ccname); - if (names) { - LMI_RootDirectory_SetObjectPath_GroupComponent(&lmi_rd, o); - o = LMI_RootDirectory_ToObjectPath(&lmi_rd, &st); - CMReturnObjectPath(cr, o); - } else { - ci = _cb->bft->getInstance(_cb, cc, o, properties, &st); - CMReturnInstance(cr, ci); - } + LMI_RootDirectory_SetObjectPath_GroupComponent(&lmi_rd, o); } else { - /* Linux_ComputerSystem */ + /* got Linux_ComputerSystem */ LMI_RootDirectory_SetObjectPath_GroupComponent(&lmi_rd, cop); LMI_UnixDirectory lmi_ud; LMI_UnixDirectory_Init(&lmi_ud, _cb, ns); fill_logicalfile(LMI_UnixDirectory, &lmi_ud, "/", LMI_UnixDirectory_ClassName); o = LMI_UnixDirectory_ToObjectPath(&lmi_ud, &st); - if (names) { - LMI_RootDirectory_SetObjectPath_PartComponent(&lmi_rd, o); - o = LMI_RootDirectory_ToObjectPath(&lmi_rd, &st); - CMReturnObjectPath(cr, o); - } else { - ci = _cb->bft->getInstance(_cb, cc, o, properties, &st); - CMReturnInstance(cr, ci); - } + LMI_RootDirectory_SetObjectPath_PartComponent(&lmi_rd, o); } + if (names) { + o = LMI_RootDirectory_ToObjectPath(&lmi_rd, &st); + CMReturnObjectPath(cr, o); + } else { + ci = LMI_RootDirectory_ToInstance(&lmi_rd, &st); + CMReturnInstance(cr, ci); + } CMReturn(CMPI_RC_OK); } |