${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
#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>
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.
#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 {
m_context(context)
{
AddStep(&TaskFileManipulation::StepCreateDirs);
+ AddStep(&TaskFileManipulation::StepCreatePrivateStorageDir);
AddStep(&TaskFileManipulation::StepRenamePath);
AddAbortStep(&TaskFileManipulation::StepAbortRenamePath);
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) {
"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;
void StepCreateDirs();
void StepRenamePath();
+ void StepCreatePrivateStorageDir();
void StepAbortRenamePath();
+++ /dev/null
-/*
- * 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
+++ /dev/null
-/*
- * 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
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.");
}
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,
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");
}
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();
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;
*
* /opt/apps/[package_name]
* \_____________ /data
+ * \_____________ /data/share
* \_____________ /bin
* \_____________ /bin/[id_of_installed_package]
* \_____________ /res/wgt/
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
/**