arrangement of directory creation.
authorSoyoung Kim <sy037.kim@samsung.com>
Thu, 22 Nov 2012 02:27:15 +0000 (11:27 +0900)
committerSoyoung Kim <sy037.kim@samsung.com>
Wed, 5 Dec 2012 05:31:45 +0000 (14:31 +0900)
[Issue#] N/A
[Problem] N/A
[Cause] N/A
[Solution] creation of private storage directory move to file manifacture task
from task_private_storage.
[SCMRequest] N/A

Change-Id: I11ce837f3b45d78e8abeafe1ade4e1545ed2f7d8

src/CMakeLists.txt
src/jobs/widget_install/job_widget_install.cpp
src/jobs/widget_install/task_file_manipulation.cpp
src/jobs/widget_install/task_file_manipulation.h
src/jobs/widget_install/task_private_storage.cpp [deleted file]
src/jobs/widget_install/task_private_storage.h [deleted file]
src/jobs/widget_install/task_recovery.cpp
src/jobs/widget_install/widget_install_context.h
src/jobs/widget_uninstall/task_remove_files.cpp
src/misc/widget_location.cpp
src/misc/widget_location.h

index 665095d..9cfd43e 100644 (file)
@@ -71,7 +71,6 @@ SET(INSTALLER_SOURCES
     ${INSTALLER_JOBS}/widget_install/task_ace_check.cpp
     ${INSTALLER_JOBS}/widget_install/task_manifest_file.cpp
     ${INSTALLER_JOBS}/widget_install/task_certify.cpp
-    ${INSTALLER_JOBS}/widget_install/task_private_storage.cpp
     ${INSTALLER_JOBS}/widget_install/task_prepare_files.cpp
     ${INSTALLER_JOBS}/widget_install/task_recovery.cpp
     ${INSTALLER_JOBS}/widget_install/task_install_ospsvc.cpp
index ef7fbe4..bd81286 100644 (file)
@@ -60,7 +60,6 @@
 #include <widget_install/task_ace_check.h>
 #include <widget_install/task_smack.h>
 #include <widget_install/task_manifest_file.h>
-#include <widget_install/task_private_storage.h>
 #include <widget_install/task_prepare_files.h>
 #include <widget_install/task_recovery.h>
 #include <widget_install/task_install_ospsvc.h>
@@ -192,8 +191,6 @@ JobWidgetInstall::JobWidgetInstall(std::string const &widgetPath,
         AddTask(new TaskFileManipulation(m_installerContext));
         // TODO: Update progress information for this task
 
-        AddTask(new TaskPrivateStorage(m_installerContext));
-
         //This is sort of quick solution, because ACE verdicts are based upon
         //data from DAO (DB). So AceCheck for now has to be AFTER DbUpdate
         //task.
index 2bd896b..2a1400d 100644 (file)
 #include <dpl/assert.h>
 #include <string>
 
+#define WEBAPP_DEFAULT_UID  5000
+#define WEBAPP_DEFAULT_GID  5000
+
+namespace {
+const mode_t PRIVATE_STORAGE_MODE = 0700;
+}
+
 using namespace WrtDB;
 
 namespace Jobs {
@@ -39,6 +46,7 @@ TaskFileManipulation::TaskFileManipulation(InstallerContext& context) :
     m_context(context)
 {
     AddStep(&TaskFileManipulation::StepCreateDirs);
+    AddStep(&TaskFileManipulation::StepCreatePrivateStorageDir);
     AddStep(&TaskFileManipulation::StepRenamePath);
 
     AddAbortStep(&TaskFileManipulation::StepAbortRenamePath);
@@ -59,11 +67,6 @@ void TaskFileManipulation::StepCreateDirs()
 
     WrtUtilMakeDir(widgetPath);
 
-    if (m_context.job->getInstallerStruct().m_preload) {
-        std::string privateDir = m_context.locations->getBasePrivateDir();
-        WrtUtilMakeDir(privateDir);
-    }
-
     // If package type is widget with osp service, we don't need to make bin
     // and src directory
     if (m_context.widgetConfig.packagingType == PKG_TYPE_HYBRID_WEB_APP) {
@@ -79,6 +82,48 @@ void TaskFileManipulation::StepCreateDirs()
         "Widget Directory Created");
 }
 
+void TaskFileManipulation::StepCreatePrivateStorageDir()
+{
+    std::string storagePath = m_context.locations->getPrivateStorageDir();
+
+    if (euidaccess(storagePath.c_str(), F_OK) != 0) {
+        if(!WrtUtilMakeDir(storagePath, PRIVATE_STORAGE_MODE)){
+            LogError("Failed to create directory for private storage");
+            ThrowMsg(Exceptions::InternalError,
+                    "Failed to create directory for private storage");
+        }
+        // '5000' is default uid, gid for applications.
+        // So installed applications should be launched as process of uid '5000'.
+        // the process can access private directory 'data' of itself.
+        if(chown(storagePath.c_str(),
+                 WEBAPP_DEFAULT_UID,
+                 WEBAPP_DEFAULT_GID) != 0)
+        {
+            ThrowMsg(Exceptions::InternalError,
+                 "Chown to invaild user");
+        }
+    } else if (euidaccess(storagePath.c_str(), W_OK | R_OK | X_OK) == 0) {
+        LogInfo("Private storage already exists.");
+        // Even if private directory already is created, private dircetory
+        // should change owner.
+        if(chown(storagePath.c_str(),
+                 WEBAPP_DEFAULT_UID,
+                 WEBAPP_DEFAULT_GID) != 0)
+        {
+            ThrowMsg(Exceptions::InternalError,
+                 "Chown to invaild user");
+        }
+        if(chmod(storagePath.c_str(), PRIVATE_STORAGE_MODE) != 0) {
+            ThrowMsg(Exceptions::InternalError,
+                 "chmod to 0700");
+        }
+
+    } else {
+        ThrowMsg(Exceptions::InternalError,
+                 "No access to private storage.");
+    }
+}
+
 void TaskFileManipulation::StepRenamePath()
 {
     std::string instDir;
index 162dbbf..429b0fb 100644 (file)
@@ -36,6 +36,7 @@ class TaskFileManipulation :
 
     void StepCreateDirs();
     void StepRenamePath();
+    void StepCreatePrivateStorageDir();
 
     void StepAbortRenamePath();
 
diff --git a/src/jobs/widget_install/task_private_storage.cpp b/src/jobs/widget_install/task_private_storage.cpp
deleted file mode 100644 (file)
index 853db0a..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/**
- * @file    installer_task_private_storage.cpp
- * @author  Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
- * @version 1.0
- * @brief   Implementation file for installer task private storage.
- */
-#include "task_private_storage.h"
-
-#include <pwd.h>
-#include <grp.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <string>
-
-#include <dpl/log/log.h>
-#include <dpl/errno_string.h>
-
-#include <dpl/wrt-dao-ro/widget_config.h>
-#include <dpl/utils/wrt_utility.h>
-#include <widget_install/job_widget_install.h>
-#include <widget_install/widget_install_context.h>
-#include <widget_install/widget_install_errors.h>
-
-#define WEBAPP_DEFAULT_UID  5000
-#define WEBAPP_DEFAULT_GID  5000
-
-namespace {
-const mode_t PRIVATE_STORAGE_MODE = 0700;
-}
-
-namespace Jobs {
-namespace WidgetInstall {
-TaskPrivateStorage::TaskPrivateStorage(InstallerContext& context) :
-    DPL::TaskDecl<TaskPrivateStorage>(this),
-    m_context(context)
-{
-    AddStep(&TaskPrivateStorage::StepCreateDirectory);
-}
-
-void TaskPrivateStorage::StepCreateDirectory()
-{
-    using namespace WrtDB;
-
-    LogInfo("Step: Creating private storage directory.");
-
-    m_context.installStep =
-        InstallerContext::INSTALL_CREATE_PRIVATE_STORAGE;
-
-    std::ostringstream widgetDataPath;
-    DPL::OptionalString pkgname = m_context.widgetConfig.pkgname;
-    if(!pkgname.IsNull()) {
-        widgetDataPath << m_context.locations->getBasePrivateDir() << "/";
-    } else {
-        ThrowMsg(Exceptions::InternalError, "No Package name exists.");
-    }
-
-    if (euidaccess(widgetDataPath.str().c_str(), W_OK | X_OK) != 0) {
-        ThrowMsg(Exceptions::InternalError, DPL::GetErrnoString());
-    }
-
-    std::ostringstream storagePath;
-    storagePath << widgetDataPath.str().c_str()
-                << GlobalConfig::GetWidgetPrivateStoragePath();
-
-    if (euidaccess(storagePath.str().c_str(), F_OK) != 0) {
-        if(!WrtUtilMakeDir(storagePath.str(), PRIVATE_STORAGE_MODE)){
-            LogError("Failed to create directory for private storage");
-            ThrowMsg(Exceptions::InternalError,
-                    "Failed to create directory for private storage");
-        }
-        // '5000' is default uid, gid for applications.
-        // So installed applications should be launched as process of uid '5000'.
-        // the process can access private directory 'data' of itself.
-        if(chown(storagePath.str().c_str(),
-                 WEBAPP_DEFAULT_UID,
-                 WEBAPP_DEFAULT_GID) != 0)
-        {
-            ThrowMsg(Exceptions::InternalError,
-                 "Chown to invaild user");
-        }
-    } else if (euidaccess(storagePath.str().c_str(), W_OK | R_OK | X_OK) == 0) {
-        LogInfo("Private storage already exists.");
-        // Even if private directory already is created, private dircetory
-        // should change owner.
-        if(chown(storagePath.str().c_str(),
-                 WEBAPP_DEFAULT_UID,
-                 WEBAPP_DEFAULT_GID) != 0)
-        {
-            ThrowMsg(Exceptions::InternalError,
-                 "Chown to invaild user");
-        }
-        if(chmod(storagePath.str().c_str(), PRIVATE_STORAGE_MODE) != 0) {
-            ThrowMsg(Exceptions::InternalError,
-                 "chmod to 0700");
-        }
-
-    } else {
-        ThrowMsg(Exceptions::InternalError,
-                 "No access to private storage.");
-    }
-
-    m_context.job->UpdateProgress(
-        InstallerContext::INSTALL_CREATE_PRIVATE_STORAGE,
-        "Private storage created."
-        );
-}
-} //namespace WidgetInstall
-} //namespace Jobs
diff --git a/src/jobs/widget_install/task_private_storage.h b/src/jobs/widget_install/task_private_storage.h
deleted file mode 100644 (file)
index e919f6b..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- *    Licensed under the Apache License, Version 2.0 (the "License");
- *    you may not use this file except in compliance with the License.
- *    You may obtain a copy of the License at
- *
- *        http://www.apache.org/licenses/LICENSE-2.0
- *
- *    Unless required by applicable law or agreed to in writing, software
- *    distributed under the License is distributed on an "AS IS" BASIS,
- *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *    See the License for the specific language governing permissions and
- *    limitations under the License.
- */
-/**
- * @file    task_private_storage.h
- * @author  Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
- * @version 1.0
- * @brief   Header file for installer task private storage.
- */
-#ifndef INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_PRIVATESTORAGE_H
-#define INSTALLER_CORE_JOS_WIDGET_INSTALL_TASK_PRIVATESTORAGE_H
-
-#include <dpl/task.h>
-
-class InstallerContext;
-
-namespace Jobs {
-namespace WidgetInstall {
-class TaskPrivateStorage : public DPL::TaskDecl<TaskPrivateStorage>
-{
-  public:
-    explicit TaskPrivateStorage(InstallerContext& context);
-
-  private:
-    void StepCreateDirectory();
-
-  private:
-    InstallerContext& m_context;
-};
-} //namespace WidgetInstall
-} //namespace Jobs
-
-#endif
index 1b922db..bd844ae 100644 (file)
@@ -72,10 +72,6 @@ void TaskRecovery::StepCreateCheckFile()
         m_context.installInfo = infoPath.str();
 
         LogDebug("Create file : " << m_context.installInfo);
-        m_context.job->UpdateProgress(
-                InstallerContext::INSTALL_LINK_DEPENDS_DIRECTORY,
-                "depends directory linked."
-                );
     } else {
         ThrowMsg(Exceptions::InternalError, "Fail to create file for recovery.");
     }
index 4fa010b..cc3e668 100755 (executable)
@@ -65,8 +65,6 @@ struct InstallerContext
         INSTALL_BACKUP_EXEC,                           /* For Update */
         INSTALL_NEW_DB_INSERT,                         /* For Update */
 
-        INSTALL_CREATE_PRIVATE_STORAGE,
-        INSTALL_LINK_DEPENDS_DIRECTORY,
         INSTALL_ACE_PREPARE,
         INSTALL_ACE_CHECK,
         INSTALL_SMACK_ENABLE,
index d258d0c..1bc1984 100644 (file)
@@ -62,7 +62,7 @@ void TaskRemoveFiles::StepRemoveInstallationDirectory()
     if(!WrtUtilRemove(widgetDir)){
         LogWarning("Removing widget installation directory failed");
     }
-    std::string dataDir = m_context.locations->getBasePrivateDir();
+    std::string dataDir = m_context.locations->getUserDataRootDir();
     if(!WrtUtilRemove(dataDir)){
         LogWarning(dataDir + " is already removed");
     }
index 3686afc..31b5d17 100644 (file)
@@ -147,6 +147,18 @@ std::string WidgetLocation::getBackupExecFile() const
     return getBackupBinaryDir() + "/" + m_pkgname;
 }
 
+std::string WidgetLocation::getUserDataRootDir() const
+{
+    return std::string(WrtDB::GlobalConfig::GetWidgetUserDataPath()) +
+        "/" + m_pkgname;
+}
+
+std::string WidgetLocation::getPrivateStorageDir() const
+{
+    return getUserDataRootDir() + "/" +
+        WrtDB::GlobalConfig::GetWidgetPrivateStoragePath();
+}
+
 std::string WidgetLocation::getTemporaryPackageDir() const
 {
     return m_temp->getTempPath();
@@ -210,12 +222,6 @@ void WidgetLocation::registerExternalLocation(const std::string & file)
     m_externals.push_back(file);
 }
 
-std::string WidgetLocation::getBasePrivateDir() const
-{
-    return std::string(WrtDB::GlobalConfig::GetWidgetUserDataPath()) +
-        "/" + m_pkgname;
-}
-
 WrtDB::ExternalLocationList WidgetLocation::listExternalLocations() const
 {
     return m_externals;
index 64408f9..3d4801c 100644 (file)
@@ -36,6 +36,7 @@
  *
  * /opt/apps/[package_name]
  *           \_____________ /data
+ *           \_____________ /data/share
  *           \_____________ /bin
  *           \_____________ /bin/[id_of_installed_package]
  *           \_____________ /res/wgt/
@@ -111,7 +112,8 @@ public:
     std::string getBackupSourceDir() const;              // /opt/apps/[package]/backup/res/wgt
     std::string getBackupBinaryDir() const;              // /opt/apps/[package]/backup/bin
     std::string getBackupExecFile() const;              // /opt/apps/[package]/backup/bin/[package]
-    std::string getBasePrivateDir() const;                  // /opt/apps
+    std::string getUserDataRootDir() const;             // /opt/usr/apps/[package]
+    std::string getPrivateStorageDir() const;                 // /opt/usr/apps/[package]/data
 
     // Temporary paths
     /**