Return update fail if encryption setting is changed during rds update
authorSoyoung Kim <sy037.kim@samsung.com>
Wed, 8 May 2013 03:55:25 +0000 (12:55 +0900)
committerSoyoung Kim <sy037.kim@samsung.com>
Wed, 8 May 2013 04:16:11 +0000 (13:16 +0900)
[Issue#] N_SE-36589
[Problem] resource is not readable when web app launched.
[Cause] if encryiption setting is changed, web app should be reinstall not rds update.
[Solution] return fail during rds update.
[SCMRequest] N/A

Change-Id: I5a05a66a820609dab575de1da923f1e92ca5708c

src/jobs/job_exception_error.h
src/jobs/widget_install/job_widget_install.cpp
src/jobs/widget_install/job_widget_install.h
src/jobs/widget_install/task_update_files.cpp
src/jobs/widget_install/widget_install_errors.h

index 9aebb74..1caba99 100644 (file)
@@ -77,6 +77,7 @@ enum Type
     ErrorInstallOspServcie,                 ///< Failure in installing osp service
     ErrorPluginInstallationFailed,          ///< failure in plugin installation
     ErrorWidgetUninstallationFailed,        ///< failure in uninstallation
+    ErrorNotSupportRDSUpdate,               ///< failure in rds update
 
     ErrorUnknown = 140,                     ///< do not use this error code.
 };
index aa46a4e..72c2332 100644 (file)
@@ -90,6 +90,7 @@ const size_t PACKAGE_ID_LENGTH = 10;
 
 static const DPL::String SETTING_VALUE_ENCRYPTION = L"encryption";
 static const DPL::String SETTING_VALUE_ENCRYPTION_ENABLE = L"enable";
+static const DPL::String SETTING_VALUE_ENCRYPTION_DISABLE = L"disable";
 const DPL::String SETTING_VALUE_INSTALLTOEXT_NAME =
     L"install-location";
 const DPL::String SETTING_VALUE_INSTALLTOEXT_PREPER_EXT =
@@ -139,6 +140,9 @@ class InstallerTaskFail :
         } else if (m_result == ConfigureResult::Failed_DrmError) {
             ThrowMsg(Jobs::WidgetInstall::Exceptions::DRMFailed,
                     "drm failed");
+        } else if (m_result == ConfigureResult::Failed_NotSupportRDSUpdate) {
+            ThrowMsg(Jobs::WidgetInstall::Exceptions::NotSupportRDSUpdate,
+                    "RDS update failed");
         } else {
             ThrowMsg(Jobs::WidgetInstall::Exceptions::NotAllowed,
                     "widget installation or update not allowed!");
@@ -480,6 +484,9 @@ ConfigureResult JobWidgetInstall::ConfigureInstallation(
             // Already installed TizenAppId. return failed
             return ConfigureResult::Failed_AlreadyInstalled;
         }
+        if (!checkSupportRDSUpdate(configData)) {
+            return ConfigureResult::Failed_NotSupportRDSUpdate;
+        }
         m_installerContext.isUpdateMode = true;
     }
     Catch(WidgetDAOReadOnly::Exception::WidgetNotExist) {
@@ -1104,5 +1111,40 @@ bool JobWidgetInstall::DecryptDRMWidget(std::string /*widgetPath*/,
     /* TODO */
     return false;
 }
+
+bool JobWidgetInstall::checkSupportRDSUpdate(const WrtDB::ConfigParserData
+        &configInfo)
+{
+    if (m_installerContext.mode.command ==
+            InstallMode::Command::REINSTALL)
+    {
+        DPL::String configValue = SETTING_VALUE_ENCRYPTION_DISABLE;
+        DPL::String dbValue = SETTING_VALUE_ENCRYPTION_DISABLE;
+
+        WidgetDAOReadOnly dao(m_installerContext.widgetConfig.tzAppid);
+        WrtDB::WidgetSettings widgetSettings;
+        dao.getWidgetSettings(widgetSettings);
+
+        FOREACH(it, widgetSettings) {
+            if (it->settingName == SETTING_VALUE_ENCRYPTION) {
+                dbValue = it->settingValue;
+            }
+        }
+
+        FOREACH(data, configInfo.settingsList)
+        {
+            if (data->m_name == SETTING_VALUE_ENCRYPTION) 
+            {
+                configValue = data->m_value;
+            }
+        }
+        if (configValue != dbValue) {
+            LogError("Not Support RDS mode because of encryption setting");
+            return false;
+        }
+    }
+
+    return true;
+}
 } //namespace WidgetInstall
 } //namespace Jobs
index 549c80d..7d5862d 100644 (file)
@@ -48,6 +48,7 @@ enum class ConfigureResult
     Failed_AlreadyInstalled,
     Failed_WidgetRunning,
     Failed_DrmError,
+    Failed_NotSupportRDSUpdate,
 };
 
 class JobWidgetInstall :
@@ -97,6 +98,7 @@ class JobWidgetInstall :
     bool validateTizenPackageID(const WrtDB::TizenPkgId &tizenPkgId);
     ConfigureResult checkWidgetUpdate(const WidgetUpdateInfo &update);
     void setApplicationType(const WrtDB::ConfigParserData &configInfo);
+    bool checkSupportRDSUpdate(const WrtDB::ConfigParserData &configInfo);
 
   public:
     /**
index 69b7053..12af068 100644 (file)
@@ -71,6 +71,9 @@ void TaskUpdateFiles::StepBackupDirectory()
     LogDebug("backup resource directory path : " << backPath);
     std::string pkgPath = m_context.locations->getPackageInstallationDir();
 
+    if (0 == access(backPath.c_str(), F_OK)) {
+        WrtUtilRemove(backPath);
+    }
     LogDebug("copy : " << pkgPath << " to " << backPath);
     if ((rename(pkgPath.c_str(), backPath.c_str())) != 0) {
         LogError("Failed to rename " << pkgPath << " to " << backPath);
index 9e3f8c9..eb1a25e 100644 (file)
@@ -89,6 +89,7 @@ DECLARE_JOB_EXCEPTION(Base, AceCheckFailed, ErrorAceCheckFailed)
 DECLARE_JOB_EXCEPTION(Base, EncryptionFailed, ErrorEncryptionFailed)
 DECLARE_JOB_EXCEPTION(Base, InstallOspsvcFailed, ErrorInstallOspServcie)
 DECLARE_JOB_EXCEPTION(Base, PrivilegeLevelViolation, ErrorPrivilegeLevelViolation)
+DECLARE_JOB_EXCEPTION(Base, NotSupportRDSUpdate, ErrorNotSupportRDSUpdate)
 } //namespace
 } //namespace
 } //namespace