{
if (packageId == NULL) {
LOGE("Package ID is NULL");
- printf("Package ID is NULL");
return -EINVAL;
}
LOGD("PKGMGR_PARSER_PLUGIN_INSTALL() called with [%s].", packageId);
- printf("PKGMGR_PARSER_PLUGIN_INSTALL() called with [%s].", packageId);
uid_t user_id = getuid();
LOGD("user_id is %d.", user_id);
- printf("user_id is %d.", user_id);
int ret = 0;
xmlNodePtr curPtr = xmlFirstElementChild(xmlDocGetRootElement(docPtr));
if (curPtr == NULL) {
LOGE("Failed to get the element. xmlFirstElementChild() returned NULL.");
- printf("Failed to get the element. xmlFirstElementChild() returned NULL.");
return -EINVAL;
}
- else {
- LOGD("Succeeded to get the element. xmlFirstElementChild().");
- printf("Succeeded to get the element. xmlFirstElementChild().");
- }
curPtr = curPtr->xmlChildrenNode;
if (curPtr == NULL) {
LOGE("No privileges");
- printf("No privileges");
return -EINVAL;
}
xmlChar* pPrivilege = xmlNodeListGetString(docPtr, curPtr->xmlChildrenNode, 1);
if (pPrivilege == NULL) {
LOGE("Failed to get privilege value.");
- printf("Failed to get privilege value.");
return -EINVAL;
} else {
privilegeList.push_back(std::string( reinterpret_cast<char*> (pPrivilege)));
LOGD("Succeeded to get privilege value.");
- printf("Succeeded to get privilege value.");
}
}
curPtr = curPtr->next;
ppPrivilegeList[i] = (char*)calloc(strlen(iter->c_str()) + 1, sizeof(char));
if (ppPrivilegeList[i] == NULL) {
LOGE("Failed allocate memory.");
- printf("Failed allocate memory.");
destroy_char_list(ppPrivilegeList, privilegeList.size() + 1);
return -ENOMEM;
}
- else {
- LOGD("Succeeded allocate memory.");
- printf("Succeeded allocate memory.");
- }
memcpy(ppPrivilegeList[i], iter->c_str(), strlen(iter->c_str()));
++iter;
}
while (*ppPrivilegeList[0] != '\0') {
LOGD("privilege in the List: %s", *ppPrivilegeList);
- printf("privilege in the List: %s", *ppPrivilegeList);
privilege_List.push_back(std::string(*ppPrivilegeList++));
}
ret = pInst->PgAddMonitorPolicy(user_id, std::string(packageId), privilege_List, monitor_policy);
if (ret != PRIV_GUARD_ERROR_SUCCESS) {
LOGE("Failed to add monitor policy: [%d]", ret);
- printf("Failed to add monitor policy: [%d]", ret);
// return -EIO;
return 0;
}
- else {
- LOGD("Succeeded to add monitor policy: [%d]", ret);
- printf("Succeeded to add monitor policy: [%d]", ret);
- }
if (temp)
destroy_char_list(temp, privilegeList.size() + 1);