From ccb47876d9ddb9ce936b1f6485bd6e8296f85b63 Mon Sep 17 00:00:00 2001 From: Soyoung Kim Date: Thu, 26 Sep 2013 17:13:29 +0900 Subject: [PATCH] support NPRuntime for smack [Issue#] N/A [Feature] Add label and soft link for NPRuntime. [Cause] N/A [Solution] 1. Add symbolc link for NPRuntime for npplugins. - /usr/bin/PluginProcess -> package root/bin/[appid].npruntime 2. Add smack label to symbolic link : [pkgid].npruntime [SCMRequest] Needed by https://review.tizendev.org/gerrit/#/c/245402/ Change-Id: I414f1cbfc913dfc73bea1d308d80a21fe28d7fe4 --- src/jobs/widget_install/task_manifest_file.cpp | 20 ++++++++++++++++++++ src/jobs/widget_install/task_manifest_file.h | 1 + src/jobs/widget_install/task_smack.cpp | 16 ++++++++++++++++ src/jobs/widget_install/task_smack.h | 1 + src/misc/widget_location.cpp | 10 ++++++++++ src/misc/widget_location.h | 2 ++ 6 files changed, 50 insertions(+) diff --git a/src/jobs/widget_install/task_manifest_file.cpp b/src/jobs/widget_install/task_manifest_file.cpp index 47898ff..c61645b 100755 --- a/src/jobs/widget_install/task_manifest_file.cpp +++ b/src/jobs/widget_install/task_manifest_file.cpp @@ -118,6 +118,7 @@ TaskManifestFile::TaskManifestFile(InstallerContext &inCont) : AddStep(&TaskManifestFile::stepCopyLiveboxFiles); AddStep(&TaskManifestFile::stepCopyAccountIconFiles); AddStep(&TaskManifestFile::stepCreateExecFile); + AddStep(&TaskManifestFile::stepCreateLinkNPPluginsFile); AddStep(&TaskManifestFile::stepGenerateManifest); AddAbortStep(&TaskManifestFile::stepAbortIconFiles); } else { @@ -125,6 +126,7 @@ TaskManifestFile::TaskManifestFile(InstallerContext &inCont) : AddStep(&TaskManifestFile::stepCopyLiveboxFiles); AddStep(&TaskManifestFile::stepCopyAccountIconFiles); AddStep(&TaskManifestFile::stepCreateExecFile); + AddStep(&TaskManifestFile::stepCreateLinkNPPluginsFile); AddStep(&TaskManifestFile::stepGenerateManifest); } } @@ -206,6 +208,24 @@ void TaskManifestFile::stepCreateExecFile() "Widget execfile creation Finished"); } +void TaskManifestFile::stepCreateLinkNPPluginsFile() +{ + _D("stepCreateLinkNPPluginsFile"); + if (0 == access(m_context.locations->getNPPluginsDir().c_str(), F_OK)) { + _D("This webapp has NPPlugins"); + std::string pluginsExec = "/usr/bin/PluginProcess"; + errno = 0; + if (symlink(pluginsExec.c_str(), + m_context.locations->getNPPluginsExecFile().c_str()) != 0) { + int error = errno; + if (error) { + _E("Failed to create symbolic link for npplugins : %ls", + DPL::GetErrnoString(error).c_str()); + } + } + } +} + void TaskManifestFile::stepCopyIconFiles() { _D("CopyIconFiles"); diff --git a/src/jobs/widget_install/task_manifest_file.h b/src/jobs/widget_install/task_manifest_file.h index 20c65ab..afcb00d 100644 --- a/src/jobs/widget_install/task_manifest_file.h +++ b/src/jobs/widget_install/task_manifest_file.h @@ -65,6 +65,7 @@ class TaskManifestFile : void stepCopyLiveboxFiles(); void stepCopyAccountIconFiles(); void stepGenerateManifest(); + void stepCreateLinkNPPluginsFile(); void stepAbortParseManifest(); diff --git a/src/jobs/widget_install/task_smack.cpp b/src/jobs/widget_install/task_smack.cpp index 5efa392..0114c4e 100644 --- a/src/jobs/widget_install/task_smack.cpp +++ b/src/jobs/widget_install/task_smack.cpp @@ -63,6 +63,7 @@ TaskSmack::TaskSmack(InstallerContext& context) : AddStep(&TaskSmack::StepSetInstall); AddStep(&TaskSmack::StepSmackFolderLabeling); AddStep(&TaskSmack::StepSmackPrivilege); + AddStep(&TaskSmack::StepAddLabelNPRuntime); AddStep(&TaskSmack::EndStep); AddAbortStep(&TaskSmack::StepAbortSmack); @@ -197,6 +198,21 @@ void TaskSmack::StepSmackPrivilege() #endif } +void TaskSmack::StepAddLabelNPRuntime() +{ + _D("----------------> SMACK:\ + Jobs::WidgetInstall::TaskSmack::StepAddLabelNPRuntime()"); + if (0 == access(m_context.locations->getNPPluginsDir().c_str(), F_OK)) { + if (PC_OPERATION_SUCCESS != + perm_app_setup_path(DPL::ToUTF8String(m_context.widgetConfig.tzPkgid).c_str(), + m_context.locations->getNPPluginsExecFile().c_str(), + PERM_APP_PATH_NPRUNTIME)) { + _E("failed to set smack execute label to %s", + m_context.locations->getNPPluginsExecFile().c_str()); + } + } +} + void TaskSmack::StepRevokeForUpdate() { _D("----------------> SMACK:\ diff --git a/src/jobs/widget_install/task_smack.h b/src/jobs/widget_install/task_smack.h index 18ce62c..0923b59 100644 --- a/src/jobs/widget_install/task_smack.h +++ b/src/jobs/widget_install/task_smack.h @@ -40,6 +40,7 @@ class TaskSmack : void StepSetInstall(); void StepSmackFolderLabeling(); void StepSmackPrivilege(); + void StepAddLabelNPRuntime(); void StepRevokeForUpdate(); void StepAbortSmack(); diff --git a/src/misc/widget_location.cpp b/src/misc/widget_location.cpp index 8ab5fef..7efb4c4 100644 --- a/src/misc/widget_location.cpp +++ b/src/misc/widget_location.cpp @@ -283,3 +283,13 @@ std::string WidgetLocation::getBackupSharedTrustedDir() const { return getBackupSharedDir() + "/trusted"; } + +std::string WidgetLocation::getNPPluginsExecFile() const +{ + return getBinaryDir() + "/" + m_appid + ".npruntime"; +} + +std::string WidgetLocation::getNPPluginsDir() const +{ + return getSourceDir() + "/plugins"; +} diff --git a/src/misc/widget_location.h b/src/misc/widget_location.h index a3b3e74..92abbbc 100644 --- a/src/misc/widget_location.h +++ b/src/misc/widget_location.h @@ -137,6 +137,8 @@ class WidgetLocation std::string getBackupSharedDir() const; // /opt/usr/apps/[package].backup/shared std::string getBackupSharedDataDir() const; // /opt/usr/apps/[package].backup/shared/data std::string getBackupSharedTrustedDir() const; // /opt/usr/apps/[package].backup/shared/trusted + std::string getNPPluginsDir() const; // /opt/usr/apps/[package]/res/wgt/plugins + std::string getNPPluginsExecFile() const; // /opt/usr/apps/[package]/bin/{execfile} // Temporary paths /** -- 2.7.4