namespace Jobs {
namespace WidgetInstall {
-
TaskAceCheck::TaskAceCheck(InstallerContext& context) :
DPL::TaskDecl<TaskAceCheck>(this),
m_context(context)
{
+ AddStep(&TaskAceCheck::StartStep);
AddStep(&TaskAceCheck::StepPrepareForAce);
AddStep(&TaskAceCheck::StepAceCheck);
AddStep(&TaskAceCheck::StepProcessAceResponse);
AddStep(&TaskAceCheck::StepCheckAceResponse);
+ AddStep(&TaskAceCheck::EndStep);
}
void TaskAceCheck::StepPrepareForAce()
void TaskAceCheck::StepAceCheck()
{
WrtDB::WidgetDAO dao(m_context.widgetConfig.tzAppid);
- LogInfo("StepAceCheck!");
+ LogDebug("StepAceCheck!");
// This widget does not use any device cap
if (m_context.featureLogic->isDone()) {
return;
}
- LogInfo("StepAceCheck!");
+ LogDebug("StepAceCheck!");
DPL::String deviceCap = m_context.featureLogic->getDevice();
- LogInfo("StepAceCheck!");
- LogInfo("DevCap is : " << deviceCap);
+ LogDebug("StepAceCheck!");
+ LogDebug("DevCap is : " << deviceCap);
std::string devCapStr = DPL::ToUTF8String(deviceCap);
ace_policy_result_t policyResult = ACE_DENY;
- ace_return_t ret = ace_get_policy_result(
- const_cast<const ace_resource_t>(devCapStr.c_str()),
- dao.getHandle(), //TODO: remove dao.getHandle()
- &policyResult);
- if (ACE_OK != ret) {
- ThrowMsg(Exceptions::NotAllowed, "Instalation failure. "
- "ACE check failure");
+
+ //TODO: remove dao.getHandle()
+ if (m_context.mode.installTime == InstallMode::InstallTime::PRELOAD) {
+ LogDebug("This widget is prealoaded. So ace check will be skiped");
+ policyResult = ACE_PERMIT;
+ } else {
+ ace_return_t ret = ace_get_policy_result(
+ const_cast<const ace_resource_t>(devCapStr.c_str()),
+ dao.getHandle(),
+ &policyResult);
+ if (ACE_OK != ret) {
+ ThrowMsg(Exceptions::AceCheckFailed, "Instalation failure. "
+ "ACE check failure");
+ }
}
- LogInfo("PolicyResult is : " << static_cast<int>(policyResult));
+ LogDebug("PolicyResult is : " << static_cast<int>(policyResult));
m_context.staticPermittedDevCaps.insert(std::make_pair(deviceCap,
- policyResult == ACE_PERMIT));
+ policyResult ==
+ ACE_PERMIT));
m_context.featureLogic->setAceResponse(policyResult != ACE_DENY);
}
{
WrtDB::WidgetDAO dao(m_context.widgetConfig.tzAppid);
if (m_context.widgetConfig.packagingType ==
- WrtDB::PKG_TYPE_HOSTED_WEB_APP) {
+ WrtDB::PKG_TYPE_HOSTED_WEB_APP)
+ {
return;
}
- LogInfo("StepProcessAceResponse");
+ LogDebug("StepProcessAceResponse");
m_context.featureLogic->next();
// No device caps left to process
if (m_context.featureLogic->isDone()) {
- LogInfo("All responses has been received from ACE.");
+ LogDebug("All responses has been received from ACE.");
// Data to convert to C API
std::vector<std::string> devCaps;
std::vector<bool> devCapsSmack;
// Saving static dev cap permissions
- FOREACH (cap, m_context.staticPermittedDevCaps) {
- LogInfo("staticPermittedDevCaps : " << cap->first
- << " smack: " << cap->second);
+ FOREACH(cap, m_context.staticPermittedDevCaps) {
+ LogDebug("staticPermittedDevCaps : " << cap->first
+ << " smack: " << cap->second);
std::string devCapStr = DPL::ToUTF8String(cap->first);
devCaps.push_back(devCapStr);
devCapsSmack.push_back(cap->second);
for (unsigned int i = 0; i < devCaps.size(); ++i) {
list.items[i].device_capability =
- const_cast<const ace_resource_t>(devCaps[i].c_str());
+ const_cast<const ace_resource_t>(devCaps[i].c_str());
list.items[i].smack_granted =
- devCapsSmack[i] ? ACE_TRUE : ACE_FALSE;
+ devCapsSmack[i] ? ACE_TRUE : ACE_FALSE;
}
- ace_return_t ret = ace_set_requested_dev_caps(dao.getHandle(), //TODO: remove dao.getHandle()
+ //TODO: remove dao.getHandle()
+ ace_return_t ret = ace_set_requested_dev_caps(dao.getHandle(),
&list);
if (ACE_OK != ret) {
- ThrowMsg(Exceptions::NotAllowed, "Instalation failure. "
- "ACE failure");
+ ThrowMsg(Exceptions::AceCheckFailed, "Instalation failure. "
+ "ACE failure");
}
- delete [] list.items;
+ delete[] list.items;
std::set<std::string> acceptedFeature;
auto it = m_context.featureLogic->resultBegin();
- for (;it != m_context.featureLogic->resultEnd(); ++it) {
+ for (; it != m_context.featureLogic->resultEnd(); ++it) {
if (!(it->rejected)) {
acceptedFeature.insert(DPL::ToUTF8String(it->name));
}
featureList.count = acceptedFeature.size();
featureList.items = new ace_string_t[featureList.count];
- size_t i=0;
+ size_t i = 0;
for (std::set<std::string>::const_iterator iter = acceptedFeature.begin();
- iter != acceptedFeature.end(); ++iter) {
+ iter != acceptedFeature.end(); ++iter)
+ {
LogDebug("Accepted feature item: " << iter->c_str());
featureList.items[i] = const_cast<char *>(iter->c_str());
i++;
}
- ret = ace_set_accepted_feature(dao.getHandle(), &featureList); //TODO: remove dao.getHandle()
+ //TODO: remove dao.getHandle()
+ ret = ace_set_accepted_feature(dao.getHandle(), &featureList);
- delete [] featureList.items;
+ delete[] featureList.items;
if (ACE_OK != ret) {
LogError("Error in ace_set_feature");
- ThrowMsg(Exceptions::NotAllowed, "Instalation failure. "
- "ace_set_feature failure.");
+ ThrowMsg(Exceptions::AceCheckFailed, "Instalation failure. "
+ "ace_set_feature failure.");
}
return;
}
- LogInfo("Next device cap.");
+ LogDebug("Next device cap.");
// Process next device cap
SwitchToStep(&TaskAceCheck::StepAceCheck);
}
void TaskAceCheck::StepCheckAceResponse()
{
- LogInfo("Checking ACE response");
+ LogDebug("Checking ACE response");
if (m_context.featureLogic->isRejected()) {
LogError("Installation failure. Some devCap was not accepted by ACE.");
- ThrowMsg(Exceptions::NotAllowed, "Instalation failure. "
+ ThrowMsg(
+ Exceptions::PrivilegeLevelViolation,
+ "Instalation failure. "
"Some deviceCap was not accepted by ACE.");
}
- LogInfo("Updating \"feature reject status\" in database!");
+ LogDebug("Updating \"feature reject status\" in database!");
auto it = m_context.featureLogic->resultBegin();
auto end = m_context.featureLogic->resultEnd();
- for(;it != end; ++it){
- LogInfo(" |- Feature: " << it->name << " has reject status: " << it->rejected);
+ for (; it != end; ++it) {
+ LogDebug(
+ " |- Feature: " << it->name << " has reject status: " <<
+ it->rejected);
if (it->rejected) {
WrtDB::WidgetDAO dao(m_context.widgetConfig.tzAppid);
dao.updateFeatureRejectStatus(*it);
}
}
- LogInfo("Installation continues...");
+ LogDebug("Installation continues...");
+}
+void TaskAceCheck::StartStep()
+{
+ LogDebug("--------- <TaskAceCheck> : START ----------");
+}
+
+void TaskAceCheck::EndStep()
+{
m_context.job->UpdateProgress(
InstallerContext::INSTALL_ACE_CHECK,
"Widget Access Control Check Finished");
-}
+ LogDebug("--------- <TaskAceCheck> : END ----------");
+}
} //namespace WidgetInstall
} //namespace Jobs