support NPRuntime for smack
authorSoyoung Kim <sy037.kim@samsung.com>
Thu, 26 Sep 2013 08:13:29 +0000 (17:13 +0900)
committerSoo-Hyun Choi <sh9.choi@samsung.com>
Tue, 29 Oct 2013 02:03:05 +0000 (11:03 +0900)
[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
src/jobs/widget_install/task_manifest_file.h
src/jobs/widget_install/task_smack.cpp
src/jobs/widget_install/task_smack.h
src/misc/widget_location.cpp
src/misc/widget_location.h

index 47898ff..c61645b 100755 (executable)
@@ -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");
index 20c65ab..afcb00d 100644 (file)
@@ -65,6 +65,7 @@ class TaskManifestFile :
     void stepCopyLiveboxFiles();
     void stepCopyAccountIconFiles();
     void stepGenerateManifest();
+    void stepCreateLinkNPPluginsFile();
 
     void stepAbortParseManifest();
 
index 5efa392..0114c4e 100644 (file)
@@ -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:\
index 18ce62c..0923b59 100644 (file)
@@ -40,6 +40,7 @@ class TaskSmack :
     void StepSetInstall();
     void StepSmackFolderLabeling();
     void StepSmackPrivilege();
+    void StepAddLabelNPRuntime();
     void StepRevokeForUpdate();
     void StepAbortSmack();
 
index 8ab5fef..7efb4c4 100644 (file)
@@ -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";
+}
index a3b3e74..92abbbc 100644 (file)
@@ -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
     /**