From e4d035158d53f55a36b51ba06ebfe7fa6b90f3dd Mon Sep 17 00:00:00 2001 From: "hb.min" Date: Wed, 8 May 2013 21:04:59 +0900 Subject: [PATCH] Fix privilege-checker to retrieve privacy information Change-Id: Ibe1078383d300b3f69ce3da5da21d369c781ea87 Signed-off-by: hb.min --- include/Parser.h | 9 +++++---- src/Parser.cpp | 36 +++++++++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/include/Parser.h b/include/Parser.h index 87a3bab..77b1bbd 100644 --- a/include/Parser.h +++ b/include/Parser.h @@ -34,10 +34,11 @@ public: private: static int SetPrivilegeDb(PrivilegeInfo* pPrivilegeInfo); static int SetPrivacyDb(PrivacyInfo* pPrivilegeInfo); - static int ParseStringInfo (xmlDocPtr stringInfoDoc, xmlNodePtr currentDoc, StringInfo** ppStringInfo); - static int ParsePrivilege (xmlDocPtr privilegeDoc, xmlNodePtr currentDoc); - static int ParsePrivilegeList (xmlDocPtr privilegeListDoc, xmlNodePtr currentDoc); - static int ParsePrivacyList (xmlDocPtr privacyListDoc, xmlNodePtr currentDoc); + static int ParseStringInfo(xmlDocPtr stringInfoDoc, xmlNodePtr currentDoc, StringInfo** ppStringInfo); + static int ParsePrivilege(xmlDocPtr privilegeDoc, xmlNodePtr currentDoc); + static int ParsePrivilegeList(xmlDocPtr privilegeListDoc, xmlNodePtr currentDoc); + static int ParsePrivacy(xmlDocPtr privacyDoc, xmlNodePtr currentDoc); + static int ParsePrivacyList(xmlDocPtr privacyListDoc, xmlNodePtr currentDoc); }; diff --git a/src/Parser.cpp b/src/Parser.cpp index 633b691..18e0f55 100644 --- a/src/Parser.cpp +++ b/src/Parser.cpp @@ -192,7 +192,7 @@ Parser::ParsePrivilegeList (xmlDocPtr privilegeListDoc, xmlNodePtr currentDoc) } int -Parser::ParsePrivacyList (xmlDocPtr privacyListDoc, xmlNodePtr currentDoc) +Parser::ParsePrivacy(xmlDocPtr privacyDoc, xmlNodePtr currentDoc) { LOGI("enter"); int res = PRIV_CHECKER_SUCCESS; @@ -207,11 +207,11 @@ Parser::ParsePrivacyList (xmlDocPtr privacyListDoc, xmlNodePtr currentDoc) { if ((!xmlStrcmp(currentDoc->name, (const xmlChar *)"id"))) { - pPrivacyInfo->pId = xmlNodeListGetString(privacyListDoc, currentDoc->xmlChildrenNode, 1); + pPrivacyInfo->pId = xmlNodeListGetString(privacyDoc, currentDoc->xmlChildrenNode, 1); } else if ((!xmlStrcmp(currentDoc->name, (const xmlChar *)"string_info"))) { - res = ParseStringInfo(privacyListDoc, currentDoc, &(pPrivacyInfo->pStringInfo)); + res = ParseStringInfo(privacyDoc, currentDoc, &(pPrivacyInfo->pStringInfo)); TryCatch(res == PRIV_CHECKER_SUCCESS, , "[%s] Propagated.", Util::GetErrorMessage(res)); } else @@ -247,6 +247,36 @@ CATCH: } +int +Parser::ParsePrivacyList (xmlDocPtr privacyListDoc, xmlNodePtr currentDoc) +{ + LOGI("enter"); + int res = PRIV_CHECKER_SUCCESS; + + currentDoc = currentDoc->xmlChildrenNode; + while (currentDoc != NULL) + { + if (currentDoc->type == XML_ELEMENT_NODE) + { + if ((!xmlStrcmp(currentDoc->name, (const xmlChar *)"privacy"))) + { + res = ParsePrivacy(privacyListDoc, currentDoc); + TryReturn(res == PRIV_CHECKER_SUCCESS, , res, "[%s] Propagated.", Util::GetErrorMessage(res)); + } + else + { + LOGE("[PRIV_CHECKER_ERROR_INVALID_ARG] Invalid policy type: %s", currentDoc->name); + res = PRIV_CHECKER_ERROR_INVALID_ARG; + return res; + } + } + currentDoc = currentDoc->next; + } + + LOGI("leave"); + return res; +} + int Parser::ParseExtendedPolicy(char *docName) -- 2.34.1