Modify compatibility manager
authorDuyoung Jang <duyoung.jang@samsung.com>
Fri, 28 Jun 2013 06:24:46 +0000 (15:24 +0900)
committerDuyoung Jang <duyoung.jang@samsung.com>
Fri, 28 Jun 2013 06:24:46 +0000 (15:24 +0900)
Change-Id: I718e87cbb0bb0c89b455c2c79a15497806684faf
Signed-off-by: Duyoung Jang <duyoung.jang@samsung.com>
inc/InstallerDefs.h
src/Manager/CompatibilityManager.cpp
src/Manager/SmackManager.cpp
src/Manager/SmackManager.h
src/Util/InstallerUtil.cpp
src/Util/InstallerUtil.h

index 769cab1..cdf00e0 100755 (executable)
@@ -23,7 +23,7 @@
 
 #include "InstallerUtil.h"
 
-#define OSP_INSTALLER_VERSION "version=[20130625.1]"
+#define OSP_INSTALLER_VERSION "version=[20130628.1]"
 
 #define DIR_BIN                                L"/bin"
 #define DIR_INFO                       L"/info"
index e695c27..cbb28b0 100755 (executable)
@@ -255,8 +255,8 @@ CompatibilityManager::LinkOspSharePath(const String& rootPath, const PackageId&
        unlink(ospSharePkgIdPath);
        unlink(ospShare2PkgIdPath);
 
-       InstallerUtil::CreateSymlink(ospAppSharePath, ospSharePkgIdPath);
-       InstallerUtil::CreateSymlink(ospAppShare2Path, ospShare2PkgIdPath);
+       InstallerUtil::CreateSymlink(ospAppSharePath, ospSharePkgIdPath, false);
+       InstallerUtil::CreateSymlink(ospAppShare2Path, ospShare2PkgIdPath, false);
 
        return true;
 }
@@ -550,7 +550,7 @@ CompatibilityManager::CreateSymbolicLink(void)
 
        for (unsigned int i = 0; i < sizeof(linkDirList) / sizeof(struct _LinkDir); ++i)
        {
-               InstallerUtil::CreateSymlink(linkDirList[i].srcPath, linkDirList[i].destPath);
+               InstallerUtil::CreateSymlink(linkDirList[i].srcPath, linkDirList[i].destPath, false);
        }
 
        AppLog("[Tizen::Io] CreateSymbolicLink() succeeded.");
index 49f3619..6b53753 100755 (executable)
@@ -135,15 +135,15 @@ SmackManager::AddLabelDir(const String& label, const String& dirPath, bool rootD
        std::unique_ptr<char[]> pRealPath(_StringConverter::CopyToCharArrayN(realPath));
        TryReturn(pRealPath, false, "pRealPath is null");
 
-       if ((rootDirectory == true) || (realPath.Contains(L"/shared/res") == true))
+       if ((rootDirectory == true) || (dirPath.Contains(L"/shared/res") == true))
        {
                res = AddLabelDir("_", pRealPath.get());
        }
-       else if ((realPath.Contains(L"/shared/data") == true) || (realPath.Contains(L"/shared/trusted") == true))
+       else if ((dirPath.Contains(L"/shared/data") == true) || (dirPath.Contains(L"/shared/trusted") == true))
        {
                AddLabelSharedDir(L"", realPath);
        }
-       else if (realPath.Contains(L"shared") == true)
+       else if (dirPath.Contains(L"shared") == true)
        {
                res = AddLabelDir("*", pRealPath.get());
        }
@@ -159,6 +159,32 @@ SmackManager::AddLabelDir(const String& label, const String& dirPath, bool rootD
 }
 
 bool
+SmackManager::AddLabelSymlink(const String& label, const String& symlink)
+{
+       if (__isSmackEnable == false)
+       {
+               return true;
+       }
+
+       int res = 0;
+
+       std::unique_ptr<char[]> pPath(_StringConverter::CopyToCharArrayN(symlink));
+       TryReturn(pPath, false, "pPath is null.");
+
+       if (InstallerUtil::IsSymlink(symlink) == true)
+       {
+               res = AddLabelDir("_", pPath.get());
+       }
+       else
+       {
+               AppLog("[%ls] is not symlink.", pPath.get());
+               return false;
+       }
+
+       return true;
+}
+
+bool
 SmackManager::AddLabelSharedDir(const PackageId& packageId, const String& dirPath)
 {
        if (__isSmackEnable == false)
index 2a3f7e3..561c66a 100755 (executable)
@@ -38,6 +38,7 @@ public:
        bool Uninstall(const Tizen::App::PackageId& packageId);
 
        bool AddLabelDir(const Tizen::Base::String& label, const Tizen::Base::String& dirPath, bool rootDirectory = false);
+       bool AddLabelSymlink(const Tizen::Base::String& label, const Tizen::Base::String& symlink);
        bool AddLabelSharedDir(const Tizen::App::PackageId& packageId, const Tizen::Base::String& dirPath);
        bool AddSharedDirReaders(const Tizen::Base::String& label);
        bool AddFriend(const Tizen::App::PackageId& packageId1, const Tizen::App::PackageId& packageId2);
index 7be47c6..e07ee81 100755 (executable)
@@ -237,7 +237,7 @@ InstallerUtil::GetRealPath(const String& filePath, String& realPath)
 }
 
 bool
-InstallerUtil::CreateSymlink(const String& oldPath, const String& newPath)
+InstallerUtil::CreateSymlink(const String& oldPath, const String& newPath, bool SmackLabelToRealPath)
 {
        int err = -1;
        bool res = false;
@@ -260,7 +260,15 @@ InstallerUtil::CreateSymlink(const String& oldPath, const String& newPath)
 
        SmackManager smackManager;
        String label("_");
-       smackManager.AddLabelDir(label, newPath);
+
+       if (SmackLabelToRealPath == true)
+       {
+               smackManager.AddLabelDir(label, newPath);
+       }
+       else
+       {
+               smackManager.AddLabelSymlink(label, newPath);
+       }
 
        AppLog("CreateSymlink(): [%ls] -> [%ls]", newPath.GetPointer(), oldPath.GetPointer());
 
index 3246364..82c3d4e 100755 (executable)
@@ -56,7 +56,7 @@ public:
        static bool IsSymlink(const Tizen::Base::String& filePath);
        static bool GetRealPath(const Tizen::Base::String& filePath, Tizen::Base::String& realPath);
 
-       static bool CreateSymlink(const Tizen::Base::String& oldPath, const Tizen::Base::String& newPath);
+       static bool CreateSymlink(const Tizen::Base::String& oldPath, const Tizen::Base::String& newPath, bool SmackLabelToRealPath = true);
        static bool ChangeMode(const Tizen::Base::String& filePath, int mode);
        static bool     ChangeOwner(const Tizen::Base::String& filePath);
        static bool     ChangeDirectoryPermission(const Tizen::Base::String& filePath, int mode, bool appOwner);