From 260c6f24f02dfa2a0e8c1a6ac91e4af703b68fb6 Mon Sep 17 00:00:00 2001 From: Tomasz Iwanek Date: Mon, 24 Jun 2013 09:59:10 +0200 Subject: [PATCH 1/1] [Release] wrt-installer_0.1.90 Change-Id: I2385f253150bf0eb45fac30eeb92e37387870884 --- configuration/config.xml | 3 +- configuration/packaging-configuration.xsd | 11 ++- configuration/widgets.tizen.xsd | 17 ++++- packaging/wrt-installer.spec | 2 +- src/jobs/widget_install/job_widget_install.cpp | 10 +++ src/jobs/widget_install/task_smack.cpp | 92 +++++++++--------------- src/jobs/widget_install/task_widget_config.cpp | 66 ++++++++++++++--- src/jobs/widget_install/widget_install_context.h | 12 +--- src/jobs/widget_install/widget_install_errors.h | 1 + 9 files changed, 132 insertions(+), 82 deletions(-) mode change 100755 => 100644 src/jobs/widget_install/task_widget_config.cpp diff --git a/configuration/config.xml b/configuration/config.xml index f33ce7e..d4a6df7 100644 --- a/configuration/config.xml +++ b/configuration/config.xml @@ -1,6 +1,7 @@ - + hello + hello diff --git a/configuration/packaging-configuration.xsd b/configuration/packaging-configuration.xsd index de55b49..f1a1520 100644 --- a/configuration/packaging-configuration.xsd +++ b/configuration/packaging-configuration.xsd @@ -4,6 +4,7 @@ + + @@ -77,6 +80,8 @@ + + @@ -89,6 +94,8 @@ + + @@ -135,6 +142,8 @@ + + diff --git a/configuration/widgets.tizen.xsd b/configuration/widgets.tizen.xsd index f930778..0d8233a 100644 --- a/configuration/widgets.tizen.xsd +++ b/configuration/widgets.tizen.xsd @@ -130,9 +130,20 @@ - - - + + + + + + + + + + + + + + diff --git a/packaging/wrt-installer.spec b/packaging/wrt-installer.spec index 79adeb4..a52926b 100644 --- a/packaging/wrt-installer.spec +++ b/packaging/wrt-installer.spec @@ -1,7 +1,7 @@ #git:framework/web/wrt-installer Name: wrt-installer Summary: Installer for tizen Webruntime -Version: 0.1.88 +Version: 0.1.90 Release: 1 Group: Development/Libraries License: Apache License, Version 2.0 diff --git a/src/jobs/widget_install/job_widget_install.cpp b/src/jobs/widget_install/job_widget_install.cpp index 9757223..4bbfe02 100644 --- a/src/jobs/widget_install/job_widget_install.cpp +++ b/src/jobs/widget_install/job_widget_install.cpp @@ -320,6 +320,11 @@ ConfigureResult JobWidgetInstall::prepareInstallation( LogError("Failed to unzip for widget"); result = ConfigureResult::Failed_DrmError; } + Catch(Exceptions::MissingConfig) + { + LogError("Failed to localize config.xml"); + result = ConfigureResult::Failed_InvalidConfig; + } return result; } @@ -656,6 +661,11 @@ ConfigParserData JobWidgetInstall::getWidgetDataFromXML( } } + if(!DPL::Utils::Path(configFile).Exists()) + { + ThrowMsg(Exceptions::MissingConfig, "Config file not exists"); + } + parser.Parse(configFile, ElementParserPtr( new RootParser(configInfo, diff --git a/src/jobs/widget_install/task_smack.cpp b/src/jobs/widget_install/task_smack.cpp index 31ab408..86dfbfd 100644 --- a/src/jobs/widget_install/task_smack.cpp +++ b/src/jobs/widget_install/task_smack.cpp @@ -91,8 +91,9 @@ void TaskSmack::StepSmackFolderLabeling() 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()); } @@ -100,40 +101,41 @@ void TaskSmack::StepSmackFolderLabeling() /* 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()); } @@ -211,7 +213,6 @@ void TaskSmack::StepAbortSmack() #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()); @@ -237,16 +238,11 @@ void TaskSmack::StepSetEndofInstallation() 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 */ @@ -264,40 +260,20 @@ bool TaskSmack::setLabelForSharedDir(const char* pkgId) 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 diff --git a/src/jobs/widget_install/task_widget_config.cpp b/src/jobs/widget_install/task_widget_config.cpp old mode 100755 new mode 100644 index 00c5fa0..b8db386 --- a/src/jobs/widget_install/task_widget_config.cpp +++ b/src/jobs/widget_install/task_widget_config.cpp @@ -415,22 +415,71 @@ void TaskWidgetConfig::ProcessAppControlInfo() void TaskWidgetConfig::ProcessSecurityModel() { + // 0104. If the "required_version" specified in the Web Application's + // configuration is 2.2 or higher and if the Web Application's + // configuration is "CSP-compatible configuration", then the WRT MUST be + // set to "CSP-based security mode". Otherwise, the WRT MUST be set to + // "WARP-based security mode". + // 0105. A Web Application configuration is "CSP-compatible configuration" + // if the configuration includes one or more of + // / + // / + // elements. + bool isSecurityModelV1 = false; bool isSecurityModelV2 = false; + std::string securityModelV2supportedVersion = "2.2"; WrtDB::ConfigParserData &data = m_installContext.widgetConfig.configInfo; + // Parse required version + long majorWidget = 0, minorWidget = 0, microWidget = 0; + if (!parseVersionString(DPL::ToUTF8String(*data.tizenMinVersionRequired), + majorWidget, + minorWidget, + microWidget)) + { + ThrowMsg(Exceptions::NotAllowed, "Wrong version string"); + } + + // Parse since version (CSP & allow-navigation start to support since 2.2) + long majorSupported = 0, minorSupported = 0, microSupported = 0; + if (!parseVersionString(securityModelV2supportedVersion, + majorSupported, + minorSupported, + microSupported)) + { + ThrowMsg(Exceptions::NotAllowed, "Wrong version string"); + } + + if (majorWidget < majorSupported || + (majorWidget == majorSupported && minorWidget < minorSupported) || + (majorWidget == majorSupported && minorWidget == minorSupported + && microWidget < microSupported)) + { + // Under 2.2, clear v2 data + data.cspPolicy = DPL::OptionalString::Null; + data.cspPolicyReportOnly = DPL::OptionalString::Null; + data.allowNavigationInfoList.clear(); + } else { + // More than 2.2, if v2 is defined, clear v1 data + if (!data.cspPolicy.IsNull() || + !data.cspPolicyReportOnly.IsNull() || + !data.allowNavigationInfoList.empty()) + { + data.accessInfoSet.clear(); + } + } + // WARP is V1 if (!data.accessInfoSet.empty()) { isSecurityModelV1 = true; } - // CSP is V2 - if (!data.cspPolicy.IsNull() || !data.cspPolicyReportOnly.IsNull()) { - isSecurityModelV2 = true; - } - - // allow-navigation is V2 - if (!data.allowNavigationInfoList.empty()) { + // CSP & allow-navigation is V2 + if (!data.cspPolicy.IsNull() || + !data.cspPolicyReportOnly.IsNull() || + !data.allowNavigationInfoList.empty()) + { isSecurityModelV2 = true; } @@ -550,8 +599,9 @@ void TaskWidgetConfig::StepVerifyLivebox() boxType.c_str(), boxSize, boxSizeCnt); for(int i = 0; i < boxSizeCnt; i++) { - delete[] boxSize[i]; + free(boxSize[i]); } + free(boxSize); if(!chkSize) { LogError("Invalid boxSize"); diff --git a/src/jobs/widget_install/widget_install_context.h b/src/jobs/widget_install/widget_install_context.h index 402005a..a19f3bb 100644 --- a/src/jobs/widget_install/widget_install_context.h +++ b/src/jobs/widget_install/widget_install_context.h @@ -52,29 +52,21 @@ struct InstallerContext INSTALL_RDS_DELTA_CHECK, INSTALL_RDS_PREPARE, - INSTALL_UNZIP_FILES, INSTALL_WIDGET_CONFIG1, INSTALL_WIDGET_CONFIG2, INSTALL_DIGSIG_CHECK, INSTALL_CERT_CHECK, INSTALL_ECRYPTION_FILES, + INSTALL_CREATE_BACKUP_DIR, /* For Update */ INSTALL_DIR_CREATE, INSTALL_RENAME_PATH, - - INSTALL_CREATE_BACKUP_DIR, /* For Update */ - INSTALL_BACKUP_RES_FILES, /* For Update */ - INSTALL_BACKUP_EXEC, /* For Update */ - INSTALL_BACKUP_ICONFILE, /* For Update */ INSTALL_COPY_ICONFILE, INSTALL_COPY_LIVEBOX_FILES, INSTALL_CREATE_EXECFILE, INSTALL_CREATE_MANIFEST, - INSTALL_CREATE_SHORTCUT, - INSTALL_SET_CERTINFO, INSTALL_INSTALL_OSPSVC, - INSTALL_REMOVE_BACKUP_FILE, - INSTALL_PLUGINS_COPY, + INSTALL_SET_CERTINFO, INSTALL_NEW_DB_INSERT, INSTALL_ACE_PREPARE, INSTALL_ACE_CHECK, diff --git a/src/jobs/widget_install/widget_install_errors.h b/src/jobs/widget_install/widget_install_errors.h index a76637f..89be530 100644 --- a/src/jobs/widget_install/widget_install_errors.h +++ b/src/jobs/widget_install/widget_install_errors.h @@ -43,6 +43,7 @@ DECLARE_JOB_EXCEPTION(Base, ExtractFileFailed, ErrorPackageInvalid) DECLARE_JOB_EXCEPTION(Base, EmptyPluginsDirectory, ErrorPackageInvalid) DECLARE_JOB_EXCEPTION(Base, PluginsSubdirectory, ErrorPackageInvalid) DECLARE_JOB_EXCEPTION(Base, RDSDeltaFailure, ErrorPackageInvalid) +DECLARE_JOB_EXCEPTION(Base, MissingConfig, ErrorPackageInvalid) DECLARE_JOB_EXCEPTION(Base, PackageLowerVersion, ErrorPackageLowerVersion) -- 2.7.4