Use real path of skel dir. 15/110415/4
authorjin-gyu.kim <jin-gyu.kim@samsung.com>
Mon, 16 Jan 2017 10:08:19 +0000 (19:08 +0900)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Tue, 17 Jan 2017 12:32:14 +0000 (13:32 +0100)
- Real path of skel dir can be diffrent based on target types.
- Convert skel dir in getSkelPkgDir to the real path.
- Add error handling in getSkelPkgDir

Change-Id: Ifdd94a07f69da091a8f07b7fd55223fd157284b6

src/common/config.cpp
src/common/include/service_impl.h
src/common/service_impl.cpp

index 75b7f4a..2f38867 100644 (file)
@@ -39,7 +39,7 @@ const std::string PRIVILEGE_APPSHARING_ADMIN = "http://tizen.org/privilege/notex
 const std::string PRIVILEGE_SHM              = "http://tizen.org/privilege/internal/shm";
 
 const std::string APPS_LABELS_FILE = "apps-labels";
-const std::string SKEL_DIR = "/opt/etc/skel";
+const std::string SKEL_DIR = "/etc/skel";
 
 const std::string PRIVACY_POLICY_DESC = "Ask user";
 #ifdef ASKUSER_ENABLED
index 3cb51a2..46c9f24 100644 (file)
@@ -261,7 +261,7 @@ private:
                               app_install_type installType,
                               std::string &userPkgDir);
 
-    static void getSkelPkgDir(const std::string &pkgName,
+    static bool getSkelPkgDir(const std::string &pkgName,
                               std::string &skelPkgDir);
 
     static void setRequestDefaultValues(uid_t& uid, int& installationType);
index 1951ef4..e180f0a 100644 (file)
@@ -307,15 +307,22 @@ bool ServiceImpl::getUserPkgDir(const uid_t &uid,
     return true;
 }
 
-void ServiceImpl::getSkelPkgDir(const std::string &pkgName,
+bool ServiceImpl::getSkelPkgDir(const std::string &pkgName,
                                 std::string &skelPkgDir)
 {
     std::string app = TizenPlatformConfig::getEnv(TZ_USER_APP);
     std::string home = TizenPlatformConfig::getEnv(TZ_USER_HOME);
+    std::string real_skel_dir = std::move(realPath(Config::SKEL_DIR));
+    if (app.empty() || home.empty() || real_skel_dir.empty()) {
+        LogError("Unable to get skel pkg dir.");
+        return false;
+    }
 
     skelPkgDir.assign(app);
-    skelPkgDir.replace(0, home.length(), Config::SKEL_DIR);
+    skelPkgDir.replace(0, home.length(), real_skel_dir);
     skelPkgDir.append("/").append(pkgName);
+
+    return true;
 }
 
 void ServiceImpl::setRequestDefaultValues(uid_t& uid, int& installationType)
@@ -402,7 +409,8 @@ int ServiceImpl::labelPaths(const pkg_paths &paths,
             pathsOK = pathsCheck(paths, {pkgBasePath});
         else {
             std::string skelPkgBasePath;
-            getSkelPkgDir(pkgName, skelPkgBasePath);
+            if (!getSkelPkgDir(pkgName, skelPkgBasePath))
+                return SECURITY_MANAGER_ERROR_SERVER_ERROR;
             pathsOK = pathsCheck(paths, {pkgBasePath, skelPkgBasePath});
         }