Fixed shared directory's owner
authorSoyoung Kim <sy037.kim@samsung.com>
Tue, 4 Jun 2013 06:42:32 +0000 (15:42 +0900)
committerSoyoung Kim <sy037.kim@samsung.com>
Tue, 4 Jun 2013 06:44:41 +0000 (15:44 +0900)
[Issue#] N/A
[Problem] N/A
[Cause] N/A
[Solution] Fixed shared directory's owner.
[SCMRequest] N/A

Change-Id: I3b0f8f33942c6dee81f5039a829eb5056745be52

src/jobs/widget_install/task_file_manipulation.cpp

index fbbae03..fa229cd 100644 (file)
@@ -43,7 +43,7 @@
 
 namespace {
 const mode_t PRIVATE_STORAGE_MODE = 0700;
-const mode_t SHARE_MODE = 0705;
+const mode_t SHARED_STORAGE_MODE = 0755;
 }
 
 using namespace WrtDB;
@@ -99,12 +99,12 @@ bool _FolderCopy(std::string source, std::string dest)
     return true;
 }
 
-void changeOwnerForDirectory(std::string storagePath) {
+void changeOwnerForDirectory(std::string storagePath, mode_t mode) {
     if (euidaccess(storagePath.c_str(), F_OK) != 0) {
-        if (!WrtUtilMakeDir(storagePath, PRIVATE_STORAGE_MODE)) {
-            LogError("Failed to create directory for private storage");
+        if (!WrtUtilMakeDir(storagePath, mode)) {
+            LogError("Failed to create directory : " << storagePath);
             ThrowMsg(Jobs::WidgetInstall::Exceptions::FileOperationFailed,
-                     "Failed to create directory for private storage");
+                     "Failed to create directory : " << storagePath);
         }
         // '5000' is default uid, gid for applications.
         // So installed applications should be launched as process of uid
@@ -118,7 +118,7 @@ void changeOwnerForDirectory(std::string storagePath) {
                      "Chown to invaild user");
         }
     } else if (euidaccess(storagePath.c_str(), W_OK | R_OK | X_OK) == 0) {
-        LogInfo("Private storage already exists.");
+        LogInfo(storagePath << " already exists.");
         // Even if private directory already is created, private dircetory
         // should change owner.
         if (chown(storagePath.c_str(),
@@ -128,7 +128,7 @@ void changeOwnerForDirectory(std::string storagePath) {
             ThrowMsg(Jobs::WidgetInstall::Exceptions::FileOperationFailed,
                      "Chown to invaild user");
         }
-        if (chmod(storagePath.c_str(), PRIVATE_STORAGE_MODE) != 0) {
+        if (chmod(storagePath.c_str(), mode) != 0) {
             ThrowMsg(Jobs::WidgetInstall::Exceptions::FileOperationFailed,
                      "chmod to 0700");
         }
@@ -216,11 +216,11 @@ void TaskFileManipulation::StepCreatePrivateStorageDir()
                     "Error occurs copy private strage files");
         }
     }
-    changeOwnerForDirectory(storagePath);
+    changeOwnerForDirectory(storagePath, PRIVATE_STORAGE_MODE);
 
     std::string tempStoragePath = m_context.locations->getPrivateTempStorageDir();
     LogDebug("Create temp private storage directory : " << tempStoragePath);
-    changeOwnerForDirectory(tempStoragePath);
+    changeOwnerForDirectory(tempStoragePath, PRIVATE_STORAGE_MODE);
 }
 
 void TaskFileManipulation::StepRenamePath()
@@ -291,7 +291,7 @@ void TaskFileManipulation::StepLinkForPreload()
                 ThrowMsg(Exceptions::FileOperationFailed,
                         "Symbolic link creating is not done.");
             }
-            changeOwnerForDirectory(dataDir);
+            changeOwnerForDirectory(dataDir, PRIVATE_STORAGE_MODE);
         }
 
         if (m_context.widgetConfig.packagingType != PKG_TYPE_HYBRID_WEB_APP) {
@@ -435,8 +435,10 @@ void TaskFileManipulation::StepCreateSharedFolder()
         }
     } else {
         WrtUtilMakeDir(m_context.locations->getSharedResourceDir());
-        WrtUtilMakeDir(m_context.locations->getSharedDataDir());
-        WrtUtilMakeDir(m_context.locations->getSharedTrustedDir());
+        changeOwnerForDirectory(m_context.locations->getSharedDataDir(),
+                SHARED_STORAGE_MODE);
+        changeOwnerForDirectory(m_context.locations->getSharedTrustedDir(),
+                SHARED_STORAGE_MODE);
     }
 }
 } //namespace WidgetInstall