#git:framework/web/wrt-installer
Name: wrt-installer
Summary: Installer for tizen Webruntime
-Version: 0.1.97
+Version: 0.1.98
Release: 1
Group: Development/Libraries
License: Apache License, Version 2.0
ConfigParserData& m_data;
};
-class LinkParser : public ElementParser
-{
- public:
- virtual ActionFunc GetElementParser(const DPL::String& /*ns*/,
- const DPL::String& /*name*/)
- {
- return &DenyAllParser::Create;
- }
-
- virtual void Accept(const XmlAttribute& attribute)
- {
- if (m_properNamespace) {
- LogDebug("attribute");
- if (attribute.name == L"rel") {
- if (attribute.value != L"describedby") {
- ThrowMsg(Exception::ParseError,
- "rel attribute must have describedby value");
- }
- } else if (attribute.name == L"type") {} else if (attribute.name ==
- L"href")
- {
- LogDebug("here is href");
- m_href = attribute.value;
- } else {
- ThrowMsg(Exception::ParseError,
- "unknown attribute '" +
- DPL::ToUTF8String(attribute.name) +
- "' in link element");
- }
- }
- }
-
- virtual void Accept(const Element& element)
- {
- if (element.ns ==
- ConfigurationNamespace::WacWidgetNamespaceNameForLinkElement)
- {
- m_properNamespace = true;
- }
- LogDebug("element");
- }
-
- virtual void Accept(const Text&)
- {
- if (m_properNamespace) {
- LogDebug("text");
- ThrowMsg(Exception::ParseError, "link element must be empty");
- }
- }
-
- virtual void Verify()
- {
- if (!m_href) {
- ThrowMsg(Exception::ParseError,
- "link element must have href attribute");
- }
-
- LibIri::Wrapper iri(DPL::ToUTF8String(*m_href).c_str());
- if (!iri.Validate()) { // TODO: Better uri validator ?
- ThrowMsg(Exception::ParseError,
- "href attribute must be a valid iri/uri/url");
- }
- }
-
- LinkParser(ConfigParserData& data) :
- ElementParser(),
- m_properNamespace(false),
- m_data(data),
- m_href(DPL::OptionalString::Null)
- {}
-
- private:
- bool m_properNamespace;
- ConfigParserData& m_data;
- DPL::OptionalString m_href;
-};
-
class SettingParser : public ElementParser
{
public:
DPL::MakeDelegate(this, &WidgetParser::OnContentElement);
m_map[L"preference"] =
DPL::MakeDelegate(this, &WidgetParser::OnPreferenceElement);
- m_map[L"link"] = DPL::MakeDelegate(this, &WidgetParser::OnLinkElement);
m_map[L"setting"] =
DPL::MakeDelegate(this, &WidgetParser::OnSettingElement);
m_map[L"application"] = DPL::MakeDelegate(
return ElementParserPtr(new PreferenceParser(m_data));
}
-ElementParserPtr WidgetParser::OnLinkElement()
-{
- return ElementParserPtr(new LinkParser(m_data));
-}
-
ElementParserPtr WidgetParser::OnSettingElement()
{
return ElementParserPtr(new SettingParser(m_data));
namespace ConfigurationNamespace {
static const DPL::String W3CWidgetNamespaceName =
L"http://www.w3.org/ns/widgets";
-static const DPL::String WacWidgetNamespaceNameForLinkElement =
- L"http://wacapps.net/ns/widgets#";
-static const DPL::String WacWidgetNamespaceName =
- L"http://wacapps.net/ns/widgets";
static const DPL::String TizenWebAppNamespaceName =
L"http://tizen.org/ns/widgets";
}
namespace PluginsPrefix {
const char * const W3CPluginsPrefix = "http://www.w3.org/";
-const char * const WACPluginsPrefix = "http://wacapps.net/api/";
const char * const TIZENPluginsPrefix = "http://tizen.org/api/";
}
ElementParserPtr OnContentElement();
ElementParserPtr OnPreferenceElement();
ElementParserPtr OnAccessElement();
- ElementParserPtr OnLinkElement();
ElementParserPtr OnSettingElement();
ElementParserPtr OnApplicationElement();
ElementParserPtr OnSplashElement();
{
LogDebug("Updating Ace database");
struct widget_info wi;
- DPL::OptionalString os;
switch (widgetConfig.webAppType.appType) {
- case WrtDB::APP_TYPE_WAC20:
- wi.type = WAC20;
- break;
case WrtDB::APP_TYPE_TIZENWEBAPP:
wi.type = Tizen;
break;
WidgetDAOReadOnly dao(widgetHandle);
WidgetType type = dao.getWidgetType();
- if (type == WrtDB::APP_TYPE_WAC20) {
- wi.type = WAC20;
- } else if (type == WrtDB::APP_TYPE_TIZENWEBAPP) {
+ if (type == WrtDB::APP_TYPE_TIZENWEBAPP) {
wi.type = Tizen;
} else {
LogError("Unknown application type");
"Config.xml has more than one valid namespace");
}
widgetAppType = APP_TYPE_TIZENWEBAPP;
- } else if (
- *iterator ==
- ConfigurationNamespace::WacWidgetNamespaceNameForLinkElement ||
- *iterator ==
- ConfigurationNamespace::WacWidgetNamespaceName)
- {
- if (widgetAppType != APP_TYPE_UNKNOWN &&
- widgetAppType != APP_TYPE_WAC20)
- {
- LogError("To many namespaces declared in configuration fileB.");
- ThrowMsg(Exceptions::WidgetConfigFileInvalid,
- "Config.xml has more than one valid namespace");
- }
- widgetAppType = APP_TYPE_WAC20;
} else {
LogDebug("Namespace ignored.");
}
SignatureFileInfoSet::reverse_iterator iter = signatureFiles.rbegin();
LogInfo("Number of signatures: " << signatureFiles.size());
- bool complianceMode = GlobalDAOReadOnly::getComplianceMode();
-
for (; iter != signatureFiles.rend(); ++iter) {
LogInfo("Checking signature with id=" << iter->getFileNumber());
SignatureData data(widgetPath + iter->getFileName(),
xml.initialize(data, GlobalConfig::GetSignatureXmlSchema());
xml.read(data);
- WrtSignatureValidator::AppType appType =
- WrtSignatureValidator::WAC20;
-
- if (m_contextData.widgetConfig.webAppType ==
- APP_TYPE_TIZENWEBAPP)
- {
- appType = WrtSignatureValidator::TIZEN;
- }
-
WrtSignatureValidator::Result result;
WrtSignatureValidator validator(
- appType,
+ WrtSignatureValidator::TIZEN,
!GlobalSettings::
OCSPTestModeEnabled(),
!GlobalSettings::
CrlTestModeEnabled(),
- complianceMode);
+ false);
result = validator.check(data, widgetPath);
#include <dpl/localization/LanguageTagsProvider.h>
#define DEFAULT_ICON_NAME "icon.png"
+#define DEFAULT_PREVIEW_NAME "preview.png"
using namespace WrtDB;
if (preview.empty()) {
continue;
}
- // copy preview image to shared directory
sourceFile << m_context.locations->getSourceDir() << "/";
sourceFile << preview;
targetFile << m_context.locations->getSharedDataDir() << "/";
targetFile << (**boxIt).m_liveboxId << ".";
- targetFile << DPL::ToUTF8String((*sizeIt).m_size) << ".preview.png";
+ targetFile << DPL::ToUTF8String((*sizeIt).m_size) << "." << DEFAULT_PREVIEW_NAME;
- DPL::FileInput input(sourceFile.str());
- DPL::FileOutput output(targetFile.str());
- DPL::Copy(&input, &output);
+ DynamicBoxFileCopy(sourceFile.str(), targetFile.str());
// clear stream objects
sourceFile.str("");
if (icon.empty()) {
continue;
}
- // copy icon to shared directory
sourceFile << m_context.locations->getSourceDir() << "/";
sourceFile << icon;
targetFile << m_context.locations->getSharedDataDir() << "/";
- targetFile << (**boxIt).m_liveboxId << ".icon.png";
+ targetFile << (**boxIt).m_liveboxId << "." << DEFAULT_ICON_NAME;
- DPL::FileInput input(sourceFile.str());
- DPL::FileOutput output(targetFile.str());
- DPL::Copy(&input, &output);
+ DynamicBoxFileCopy(sourceFile.str(), targetFile.str());
// clear stream objects
sourceFile.str("");
targetFile.str("");
}
-
m_context.job->UpdateProgress(
InstallerContext::INSTALL_COPY_LIVEBOX_FILES,
"Livebox files copy Finished");
}
+void TaskManifestFile::DynamicBoxFileCopy(const std::string& sourceFile,
+ const std::string& targetFile)
+{
+ Try
+ {
+ DPL::FileInput input(sourceFile);
+ DPL::FileOutput output(targetFile);
+ DPL::Copy(&input, &output);
+ }
+ Catch(DPL::Exception)
+ {
+ LogError("Copying Dynamic Box File Failed. " << sourceFile
+ << " to " << targetFile);
+ ReThrowMsg(Exceptions::DynamicBoxFailed, "Dynamic Box File Copy Failed.");
+ }
+}
+
void TaskManifestFile::stepBackupIconFiles()
{
LogDebug("Backup Icon Files");
const DPL::OptionalString& tag,
const DPL::String& language,
bool & defaultIconSaved);
+ void DynamicBoxFileCopy(const std::string& sourceFile,
+ const std::string& targetFile);
//for widget update
void backupIconFiles();
#include <stdio.h>
#include <fstream>
+#include <unistd.h>
#include <dpl/task.h>
#include <dpl/string.h>
Jobs::WidgetInstall::TaskSmack::SmackFolderLabelingStep()");
#ifdef WRT_SMACK_ENABLED
/* /opt/usr/apps/[pkgid] directory's label is "_" */
- if (PC_OPERATION_SUCCESS != app_label_dir("_",
- m_context.locations->getPackageInstallationDir().c_str())) {
+ if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
+ m_context.locations->getPackageInstallationDir().c_str(),
+ APP_PATH_ANY_LABEL, "_")) {
LogWarning("Add label to " <<
m_context.locations->getPackageInstallationDir());
}
/* res directory */
std::string resDir = m_context.locations->getPackageInstallationDir() +
"/res";
- if (PC_OPERATION_SUCCESS != app_label_dir(m_pkgId,
- resDir.c_str())) {
+
+ if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId, resDir.c_str(),
+ APP_PATH_PRIVATE)) {
LogWarning("Add label to " << resDir);
}
+ /* data directory */
+ if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
+ m_context.locations->getPrivateStorageDir().c_str(),
+ APP_PATH_PRIVATE)) {
+ LogWarning("Add label to " << m_context.locations->getPrivateStorageDir());
+ }
+
/* for prealod */
if (m_context.mode.installTime == InstallMode::InstallTime::PRELOAD &&
m_context.mode.extension != InstallMode::ExtensionType::DIR)
{
- if (PC_OPERATION_SUCCESS != app_label_dir("_",
- m_context.locations->getUserDataRootDir().c_str())) {
- LogWarning("Add label to " << m_context.locations->getUserDataRootDir());
+ if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
+ m_context.locations->getUserDataRootDir().c_str(),
+ APP_PATH_GROUP_RW, "_")) {
}
}
- /* data directory */
- if (PC_OPERATION_SUCCESS !=
- app_label_dir(m_pkgId,
- m_context.locations->getPrivateStorageDir().c_str()))
- {
- LogWarning("Add label to " << m_context.locations->getPrivateStorageDir());
- }
-
/* tmp directory */
- if (PC_OPERATION_SUCCESS !=
- app_label_dir(m_pkgId,
- m_context.locations->getPrivateTempStorageDir().c_str()))
+ if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
+ m_context.locations->getPrivateTempStorageDir().c_str(),
+ APP_PATH_PRIVATE))
{
LogWarning("Add label to " << m_context.locations->getPrivateTempStorageDir());
}
/* bin directory */
- if (PC_OPERATION_SUCCESS != app_label_dir(m_pkgId,
- m_context.locations->getBinaryDir().c_str())) {
+ if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
+ m_context.locations->getBinaryDir().c_str(),
+ APP_PATH_PRIVATE)) {
LogWarning("Add label to " << m_context.locations->getBinaryDir());
}
#ifdef WRT_SMACK_ENABLED
/* TODO :
std::string id = DPL::ToUTF8String(m_context.widgetConfig.tzAppid);
- std::string id = DPL::ToUTF8String(m_context.widgetConfig.tzPkgid);
char* appId = NULL;
appId = (char*)calloc(1, id.length() + 1);
snprintf(appId, id.length() + 1, "%s", id.c_str());
bool TaskSmack::setLabelForSharedDir(const char* pkgId)
{
- /* shared directory */
- if (PC_OPERATION_SUCCESS != app_label_dir("*",
- m_context.locations->getSharedRootDir().c_str())) {
- return false;
- }
-
/* shared/res directory */
- if (PC_OPERATION_SUCCESS != app_label_dir("_",
- m_context.locations->getSharedResourceDir().c_str())) {
- return false;
+ if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
+ m_context.locations->getSharedResourceDir().c_str(),
+ APP_PATH_ANY_LABEL, "_")) {
+ LogWarning("Add label to " << m_context.locations->getSharedResourceDir());
}
/* shared/trusted directory */
LogDebug("sha1 label string : " << sha1String);
- if (PC_OPERATION_SUCCESS != app_label_shared_dir(pkgId,
- sha1String.c_str(),
- m_context.locations->getSharedTrustedDir().c_str())) {
- return false;
+ if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
+ m_context.locations->getSharedTrustedDir().c_str(),
+ APP_PATH_GROUP_RW, sha1String.c_str())) {
+ LogWarning("Add label to " << m_context.locations->getBinaryDir());
}
}
/* shared/data directory */
- std::string dataLabel = std::string(pkgId) + "_shareddata";
- TizenPkgIdList pkgList = WidgetDAOReadOnly::getTizenPkgidList();
- const char** pList = new (std::nothrow) const char*[pkgList.size() + 1];
-
- int index = 0;
- FOREACH(app, pkgList) {
- std::string id = DPL::ToUTF8String(*app);
- char *pId = new char[id.size() + 1];
- snprintf(pId, id.length() + 1, "%s", id.c_str());
- pList[index++] = pId;
+ if (PC_OPERATION_SUCCESS != app_setup_path(m_pkgId,
+ m_context.locations->getSharedDataDir().c_str(),
+ APP_PATH_PUBLIC_RO)) {
+ LogWarning("Add label to " << m_context.locations->getSharedDataDir());
}
- pList[index] = NULL;
- if (PC_OPERATION_SUCCESS != app_label_shared_dir(pkgId,
- dataLabel.c_str(),
- m_context.locations->getSharedDataDir().c_str())) {
- freeList(pList);
- return false;
- }
- if (PC_OPERATION_SUCCESS != app_label_shared_dir(pkgId,
- "*",
- m_context.locations->getSharedDataDir().c_str())) {
- freeList(pList);
- return false;
- }
- freeList(pList);
return true;
}
} //namespace WidgetInstall
if (strstr(feature, PluginsPrefix::TIZENPluginsPrefix) == feature) {
// Tizen WebApp feature
featureType = APP_TYPE_TIZENWEBAPP;
- } else if (strstr(feature, PluginsPrefix::WACPluginsPrefix) == feature) {
- // WAC 2.0 feature
- featureType = APP_TYPE_WAC20;
} else if (strstr(feature, PluginsPrefix::W3CPluginsPrefix) == feature) {
// W3C standard feature
// Both WAC and TIZEN WebApp are possible to use W3C plugins
std::string version;
if (appType == WrtDB::AppType::APP_TYPE_TIZENWEBAPP) {
version = WrtDB::GlobalConfig::GetTizenVersion();
- } else if (appType == WrtDB::AppType::APP_TYPE_WAC20) {
- version = WrtDB::GlobalConfig::GetWACVersion();
} else {
LogWarning("Invaild AppType");
return false;
DECLARE_JOB_EXCEPTION(Base, RemovingFileFailure, ErrorFatalError)
DECLARE_JOB_EXCEPTION(Base, CreateVconfFailure, ErrorFatalError)
DECLARE_JOB_EXCEPTION(Base, CopyIconFailed, ErrorFatalError)
+DECLARE_JOB_EXCEPTION(Base, DynamicBoxFailed, ErrorFatalError)
DECLARE_JOB_EXCEPTION(Base, FileOperationFailed, ErrorFatalError)
DECLARE_JOB_EXCEPTION(Base, InstallToExternalFailed, ErrorFatalError)
DECLARE_JOB_EXCEPTION(Base, BackupFailed, ErrorFatalError)
#include <dpl/wrt-dao-ro/global_config.h>
#include <task_commons.h>
#include <sys/stat.h>
+#include <dlfcn.h>
using namespace WrtDB;
namespace {
+const char *const DRM_LIB_PATH = "/usr/lib/libdrm-service-core-tizen.so";
+
struct PathAndFilePair
{
std::string path;
}
}
-std::string WidgetUnzip::decryptDrmPackage(const std::string &source)
+bool WidgetUnzip::isDRMPackage(const std::string &source)
+{
+ LogDebug("Enter : isDRMPackage()");
+ int ret = 0;
+ void* pHandle = NULL;
+ char* pErrorMsg = NULL;
+ int (*drm_oem_sapps_is_drm_file)(const char* pDcfPath, int dcfPathLen);
+
+ pHandle = dlopen(DRM_LIB_PATH, RTLD_LAZY | RTLD_GLOBAL);
+ if (!pHandle) {
+ LogError("dlopen failed : " << source << " [" << dlerror() << "]");
+ return false;
+ }
+
+ drm_oem_sapps_is_drm_file = reinterpret_cast <int (*)(const char*, int)>
+ (dlsym(pHandle, "drm_oem_sapps_is_drm_file"));
+ pErrorMsg = dlerror();
+ if ((pErrorMsg != NULL) || (drm_oem_sapps_is_drm_file == NULL)) {
+ LogError("dlopen failed : " << source << " [" << dlerror() << "]");
+ dlclose(pHandle);
+ return false;
+ }
+
+ ret = drm_oem_sapps_is_drm_file(source.c_str(), source.length());
+ dlclose(pHandle);
+ if (1 == ret) {
+ LogInfo(source << " is DRM file");
+ return true;
+ }
+ LogInfo(source << " isn't DRM file");
+ return false;
+}
+
+bool WidgetUnzip::decryptDRMPackage(const std::string &source, const std::string
+ &decryptedSource)
+{
+ LogDebug("Enter : decryptDRMPackage()");
+ int ret = 0;
+ void* pHandle = NULL;
+ char* pErrorMsg = NULL;
+ int (*drm_oem_sapps_decrypt_package)(const char* pDcfPath, int dcfPathLen,
+ const char* pDecryptedFile, int decryptedFileLen);
+
+ pHandle = dlopen(DRM_LIB_PATH, RTLD_LAZY | RTLD_GLOBAL);
+ if (!pHandle) {
+ LogError("dlopen failed : " << source << " [" << dlerror() << "]");
+ return false;
+ }
+
+ drm_oem_sapps_decrypt_package = reinterpret_cast <int (*)(const char*, int,
+ const char*, int)>
+ (dlsym(pHandle, "drm_oem_sapps_decrypt_package"));
+ pErrorMsg = dlerror();
+ if ((pErrorMsg != NULL) || (drm_oem_sapps_decrypt_package == NULL)) {
+ LogError("dlopen failed : " << source << " [" << dlerror() << "]");
+ dlclose(pHandle);
+ return false;
+ }
+
+ ret = drm_oem_sapps_decrypt_package(source.c_str(), source.length(),
+ decryptedSource.c_str(), decryptedSource.length());
+ dlclose(pHandle);
+ if (1 == ret) {
+ LogInfo(source << " is decrypted : " << decryptedSource);
+ return true;
+ }
+ return false;
+}
+
+std::string WidgetUnzip::getDecryptedPackage(const std::string &source)
{
LogInfo("Check DRM...");
- // TODO : check drm
+ if (isDRMPackage(source)) {
+ std::string decryptedFile;
+ size_t found = source.find_last_of(".wgt");
+ if (found == std::string::npos) {
+ decryptedFile += source + "_tmp.wgt";
+ } else {
+ decryptedFile += source.substr(0, source.find_last_not_of(".wgt") +
+ 1) + "_tmp.wgt";
+ }
+
+ LogDebug("decrypted file name : " << decryptedFile);
+ if (decryptDRMPackage(source, decryptedFile)) {
+ LogError("Failed decrypt drm file");
+ ThrowMsg(Exceptions::DrmDecryptFailed, source);
+ }
+ return decryptedFile;
+ }
return source;
}
std::string wgtFile;
Try
{
- wgtFile = decryptDrmPackage(source);
+ wgtFile = getDecryptedPackage(source);
LogDebug("wgtFile : " << wgtFile);
m_zip.reset(new DPL::ZipInput(wgtFile));
void unzipProgress(const std::string &destination);
void ExtractFile(DPL::ZipInput::File *input, const std::string
&destFileName);
- std::string decryptDrmPackage(const std::string &source);
+ bool isDRMPackage(const std::string &source);
+ bool decryptDRMPackage(const std::string &source, const std::string
+ &decryptedSource);
+ std::string getDecryptedPackage(const std::string &source);
};
*/
#include "widget_location.h"
+#include <unistd.h>
#include <dpl/utils/wrt_utility.h>
#include <dpl/wrt-dao-ro/global_config.h>
#include <dpl/assert.h>