Sync to tizen_2.1 branch
authorDuyoung Jang <duyoung.jang@samsung.com>
Mon, 10 Jun 2013 01:52:04 +0000 (10:52 +0900)
committerDuyoung Jang <duyoung.jang@samsung.com>
Mon, 10 Jun 2013 01:59:06 +0000 (10:59 +0900)
Change-Id: Idaf4251b2ea71167c875df80187f038c3bcaf434
Signed-off-by: Duyoung Jang <duyoung.jang@samsung.com>
12 files changed:
inc/InstallerDefs.h
src/Context/InstallationContext.cpp
src/Context/InstallationContext.h
src/Manager/InstallerManager.cpp
src/Manager/PermissionManager.cpp
src/Manager/SignatureManager.cpp
src/Manager/SmackManager.cpp
src/Manager/SmackManager.h
src/Step/PackageCheckStep.cpp
src/Util/InstallerUtil.cpp
src/Util/InstallerUtil.h
src/XmlHandler/ManifestHandler.cpp

index a4fa821..0300064 100755 (executable)
@@ -23,7 +23,7 @@
 
 #include "InstallerUtil.h"
 
-#define OSP_INSTALLER_VERSION "version=[20130528.1]"
+#define OSP_INSTALLER_VERSION "version=[20130610.1]"
 
 #define DIR_BIN                                L"/bin"
 #define DIR_INFO                       L"/info"
@@ -362,4 +362,13 @@ enum PrivilegeLevel
 
 };
 
+enum SmackDirType
+{
+       SMACK_DIR_TYPE_PRIVATE,
+       SMACK_DIR_TYPE_GROUP_RW,
+       SMACK_DIR_TYPE_PUBLIC_RO,
+       SMACK_DIR_TYPE_SETTINGS_RW,
+
+};
+
 #endif // _INSTALLER_DEFS_H_
index 621543a..27b6bf8 100755 (executable)
@@ -52,7 +52,6 @@ InstallationContext::InstallationContext(void)
 ,__isVerificationMode(false)
 ,__isUpdated(false)
 ,__isAppSetting(false)
-,__isAntiVirus(false)
 ,__isCsc(false)
 ,__isUninstallable(false)
 ,__isVirtualRoot(false)
index d6f939d..592b39e 100755 (executable)
@@ -100,7 +100,6 @@ public:
        bool __isVerificationMode;
        bool __isUpdated;
        bool __isAppSetting;
-       bool __isAntiVirus;
        bool __isCsc;
        bool __isUninstallable;
        bool __isVirtualRoot;
index 6f229ed..1c42b91 100755 (executable)
@@ -981,6 +981,12 @@ InstallerManager::Request(const String& path, InstallerOperation operation, Inst
        {
                InstallerUtil::Remove(DIR_OSP_APPLICATIONS_TEMP);
        }
+
+       if (File::IsFileExist(DIR_MEMORYCARD_OSP_APPLICATIONS_TEMP) == true)
+       {
+               InstallerUtil::Remove(DIR_MEMORYCARD_OSP_APPLICATIONS_TEMP);
+       }
+
        pInstallManager = InstallerManager::GetInstance();
        TryCatch(pInstallManager, errorType = INSTALLER_ERROR_INTERNAL_STATE, "pInstallManager is null.");
 
@@ -1017,6 +1023,11 @@ CATCH:
                InstallerUtil::Remove(DIR_OSP_APPLICATIONS_TEMP);
        }
 
+       if (File::IsFileExist(DIR_MEMORYCARD_OSP_APPLICATIONS) == true)
+       {
+               InstallerUtil::Remove(DIR_MEMORYCARD_OSP_APPLICATIONS);
+       }
+
        return errorType;
 }
 
@@ -1272,6 +1283,16 @@ InstallerManager::RequestMove(const PackageId& packageId, int moveType)
                        continue;
                }
 
+               if (entry.IsDirectory() == false)
+               {
+                       continue;
+               }
+
+               if (entryName.StartsWith(L".", 0) == true)
+               {
+                       continue;
+               }
+
                int length = 0;
                app2ext_dir_details* pDirDetails = null;
 
index 8973340..55948c7 100755 (executable)
@@ -78,22 +78,22 @@ PermissionManager::SetDirectory(InstallationContext* pContext)
        // appRoot/bin
        destPath = appRootPath + DIR_BIN;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE | PERM_EXECUTE, false);
-       smackManager.AddLabelDir(packageId, destPath);
+       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PRIVATE);
 
        // appRoot/info
        destPath = appRootPath + DIR_INFO;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, false);
-       smackManager.AddLabelDir(packageId, destPath);
+       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PRIVATE);
 
        // appRoot/res
        destPath = appRootPath + DIR_RES;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, false);
-       smackManager.AddLabelDir(packageId, destPath);
+       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PRIVATE);
 
        // appRoot/lib
        destPath = appRootPath + DIR_LIB;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE | PERM_EXECUTE, false);
-       smackManager.AddLabelDir(packageId, destPath);
+       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PRIVATE);
 
        // appRoot/shared
        destPath = appRootPath + DIR_SHARED;
@@ -103,7 +103,6 @@ PermissionManager::SetDirectory(InstallationContext* pContext)
                TryReturn(!IsFailed(r), INSTALLER_ERROR_INTERNAL_STATE, "Directory::Create() failed");
        }
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, false);
-       smackManager.AddLabelDir(packageId, destPath);
 
        // appRoot/shared/res
        destPath = appRootPath + DIR_SHARED_RES;
@@ -113,22 +112,21 @@ PermissionManager::SetDirectory(InstallationContext* pContext)
                InstallerUtil::CreateSymlink(iconPath, destPath);
        }
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, false);
-       smackManager.AddLabelDir(packageId, destPath);
 
        // appRoot/shared/data
        destPath = appRootPath + DIR_SHARED_DATA;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, true);
-       smackManager.AddLabelSharedDir(packageId, destPath);
+       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PUBLIC_RO);
 
        // appRoot/shared/trusted
        destPath = appRootPath + DIR_SHARED_TRUSTED;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, true);
-       smackManager.AddLabelSharedDir(packageId, destPath);
+       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_GROUP_RW);
 
        // appRoot/contents
        destPath = appRootPath + DIR_CONTENTS;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, false);
-       smackManager.AddLabelDir(packageId, destPath);
+       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PRIVATE);
 
        // appRoot/setting
        destPath = appRootPath + DIR_SETTING;
@@ -137,10 +135,6 @@ PermissionManager::SetDirectory(InstallationContext* pContext)
                String appVersion = pContext->__version;
                String srcPath;
                String settingXmlPath;
-               String label = "*";
-               //String label = packageId;
-               //label.Append("_setting");
-
                srcPath = destPath + L"/setting." + appVersion + L".xml";
                settingXmlPath = destPath + L"/setting.xml";
 
@@ -148,7 +142,7 @@ PermissionManager::SetDirectory(InstallationContext* pContext)
                InstallerUtil::CreateSymlink(srcPath, settingXmlPath);
 
                InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE | PERM_WRITE, false);
-               smackManager.AddLabelDir(label, destPath);
+               smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_SETTINGS_RW);
        }
 
        // appRoot/data
@@ -159,7 +153,7 @@ PermissionManager::SetDirectory(InstallationContext* pContext)
                TryReturn(!IsFailed(r), false, "Directory::Create() failed");
        }
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, true);
-       smackManager.AddLabelDir(packageId, destPath);
+       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PRIVATE);
 
        String apiVersion = pContext->__apiVersion;
 
@@ -366,52 +360,50 @@ PermissionManager::ApplyPermissionForRds(InstallationContext* pContext)
        // appRoot/bin
        destPath = appRootPath + DIR_BIN;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE | PERM_EXECUTE, false);
-       smackManager.AddLabelDir(packageId, destPath);
+       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PRIVATE);
 
        // appRoot/info
        destPath = appRootPath + DIR_INFO;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, false);
-       smackManager.AddLabelDir(packageId, destPath);
+       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PRIVATE);
 
        // appRoot/res
        destPath = appRootPath + DIR_RES;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, false);
-       smackManager.AddLabelDir(packageId, destPath);
+       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PRIVATE);
 
        // appRoot/lib
        destPath = appRootPath + DIR_LIB;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE | PERM_EXECUTE, false);
-       smackManager.AddLabelDir(packageId, destPath);
+       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PRIVATE);
 
        // appRoot/shared
        destPath = appRootPath + DIR_SHARED;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, false);
-       smackManager.AddLabelDir(packageId, destPath);
 
        // appRoot/shared/res
        destPath = appRootPath + DIR_SHARED_RES;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, false);
-       smackManager.AddLabelSharedDir(packageId, destPath);
 
        // appRoot/shared/data
        destPath = appRootPath + DIR_SHARED_DATA;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, true);
-       smackManager.AddLabelSharedDir(packageId, destPath);
+       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PUBLIC_RO);
 
        // appRoot/shared/trusted
        destPath = appRootPath + DIR_SHARED_TRUSTED;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, true);
-       smackManager.AddLabelSharedDir(packageId, destPath);
+       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_GROUP_RW);
 
        // appRoot/setting
        destPath = appRootPath + DIR_SETTING;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE | PERM_WRITE, false);
-       smackManager.AddLabelDir(packageId, destPath);
+       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_SETTINGS_RW);
 
        // appRoot/data
        destPath = appRootPath + DIR_DATA;
        InstallerUtil::ChangeDirectoryPermission(destPath, PERM_BASE, true);
-       smackManager.AddLabelDir(packageId, destPath);
+       smackManager.SetupPath(packageId, destPath, SMACK_DIR_TYPE_PRIVATE);
 
        return true;
 }
index cc3cdd1..a28e1c6 100755 (executable)
@@ -101,6 +101,13 @@ SignatureManager::ValidateSignatures()
                int sigFileNumber = iter->getFileNumber();
                AppLog("SignatureFiles: file=[%s]", iter->getFileName().c_str());
                AppLog("SignatureFiles: number=[%d]", sigFileNumber);
+
+               if (sigFileNumber > SIGNATURE_FILE_NUMBER_DISTRIBUTOR2)
+               {
+                       AppLog("SignatureFiles: skip!");
+                       continue;
+               }
+
                ValidationCore::SignatureData data(rootPath + iter->getFileName(), iter->getFileNumber());
 
                try {
@@ -130,7 +137,6 @@ SignatureManager::ValidateSignatures()
                                        }
                                        else if (sigFileNumber == SIGNATURE_FILE_NUMBER_DISTRIBUTOR2)
                                        {
-                                               __pContext->__pDistributorCertList2->Add(new String(value.c_str()));
                                                AppLog("Default distributor2 cert value=[%s]", value.c_str());
                                        }
                                }
@@ -142,8 +148,23 @@ SignatureManager::ValidateSignatures()
 
                        AppLog("validator.check() start >>");
                        valRes = validator.check(data, rootPath);
-                       TryReturn(valRes == ValidationCore::SignatureValidator::SIGNATURE_VERIFIED, false, "validator.check() is failed, valRes=[%d]", (int)valRes);
-                       AppLog("Signature validator.check success, file=[%s], number=[%d]", iter->getFileName().c_str(), iter->getFileNumber());
+                       if (sigFileNumber == SIGNATURE_FILE_NUMBER_DISTRIBUTOR2)
+                       {
+                               if (valRes == ValidationCore::SignatureValidator::SIGNATURE_VERIFIED)
+                               {
+                                       AppLog("Signature validator.check success, file=[%s], number=[%d]", iter->getFileName().c_str(), iter->getFileNumber());
+                               }
+                               else
+                               {
+                                       AppLog("Signature validator.check failed, but it's ok, file=[%s], number=[%d]", iter->getFileName().c_str(), iter->getFileNumber());
+                                       __pContext->__pDistributorCertList2->RemoveAll();
+                               }
+                       }
+                       else
+                       {
+                               TryReturn(valRes == ValidationCore::SignatureValidator::SIGNATURE_VERIFIED, false, "validator.check() is failed, valRes=[%d]", (int)valRes);
+                               AppLog("Signature validator.check success, file=[%s], number=[%d]", iter->getFileName().c_str(), iter->getFileNumber());
+                       }
 
                        ValidationCore::CertificatePtr pRootCert = data.getRootCaCertificatePtr();
                        TryReturn(pRootCert, false, "__pRootPath is null.");
@@ -164,7 +185,7 @@ SignatureManager::ValidateSignatures()
                                        AppLog("CertStoreIdType = [%d]", (int)certStoreIdType);
                                        __pContext->__rootCertType = (RootCertificateType)certStoreIdType;
                                }
-                               else if (sigFileNumber == SIGNATURE_FILE_NUMBER_DISTRIBUTOR2)
+                               else if ((sigFileNumber == SIGNATURE_FILE_NUMBER_DISTRIBUTOR2) && (valRes == ValidationCore::SignatureValidator::SIGNATURE_VERIFIED))
                                {
                                        __pContext->__pDistributorCertList2->Add(new String(value.c_str()));
                                        AppLog("Default root distributor2 cert value=[%s]", value.c_str());
@@ -173,10 +194,20 @@ SignatureManager::ValidateSignatures()
                }
                catch (ValidationCore::ParserSchemaException::Base)
                {
+                       if (sigFileNumber == SIGNATURE_FILE_NUMBER_DISTRIBUTOR2)
+                       {
+                               AppLog("ValidationCore::ParserSchemaException::Base occurred, but it's ok for DISTRIBUTOR2.");
+                               continue;
+                       }
                        TryReturn(0, false, "ParserSchemaException::Base exception occurred.");
                }
                catch (DPL::Exception)
                {
+                       if (sigFileNumber == SIGNATURE_FILE_NUMBER_DISTRIBUTOR2)
+                       {
+                               AppLog("DPL::Exception occurred, but it's ok for DISTRIBUTOR2.");
+                               continue;
+                       }
                        TryReturn(0, false, "DPL::Exception exception occurred.");
                }
        }
@@ -571,22 +602,29 @@ SignatureManager::SetDistributorCertValue(void* pHandle, IListT<String *>* pCert
                }
                else if (sigFileNumber == 2)
                {
-                       if (i == 0)
-                       {
-                               certType = PM_SET_DISTRIBUTOR2_SIGNER_CERT;
-                       }
-                       else if (i == 1)
-                       {
-                               certType = PM_SET_DISTRIBUTOR2_INTERMEDIATE_CERT;
-                       }
-                       else if (i == 2)
+                       if (pCertList->GetCount() == 1)
                        {
                                certType = PM_SET_DISTRIBUTOR2_ROOT_CERT;
                        }
                        else
                        {
-                               AppLog("Invalid certificate type[%d]", i);
-                               break;
+                               if (i == 0)
+                               {
+                                       certType = PM_SET_DISTRIBUTOR2_SIGNER_CERT;
+                               }
+                               else if (i == 1)
+                               {
+                                       certType = PM_SET_DISTRIBUTOR2_INTERMEDIATE_CERT;
+                               }
+                               else if (i == 2)
+                               {
+                                       certType = PM_SET_DISTRIBUTOR2_ROOT_CERT;
+                               }
+                               else
+                               {
+                                       AppLog("Invalid certificate type[%d]", i);
+                                       break;
+                               }
                        }
                }
 
index 7fb2e99..464074f 100755 (executable)
@@ -81,11 +81,7 @@ SmackManager::Install(const PackageId& packageId)
        TryReturn(pPackageId, false, "pPackageId is null.");
 
        res = Install(pPackageId.get());
-
-       if (__pContext->__isAntiVirus == true)
-       {
-               RegisterAv(pPackageId.get());
-       }
+       TryReturn(res == 0, false, "Install() failed.");
 
        return true;
 }
@@ -154,6 +150,7 @@ SmackManager::AddLabelDir(const String& label, const String& dirPath, bool rootD
        return true;
 }
 
+#if 0
 bool
 SmackManager::AddLabelSharedDir(const PackageId& packageId, const String& dirPath)
 {
@@ -240,7 +237,9 @@ SmackManager::AddLabelSharedDir(const PackageId& packageId, const String& dirPat
 
        return true;
 }
+#endif
 
+#if 0
 bool
 SmackManager::AddSharedDirReaders(const String& label)
 {
@@ -335,6 +334,7 @@ CATCH:
 
        return res;
 }
+#endif
 
 bool
 SmackManager::AddFriend(const Tizen::App::PackageId& packageId1, const Tizen::App::PackageId& packageId2)
@@ -423,6 +423,86 @@ SmackManager::RevokePermissions(const PackageId& packageId)
 }
 
 bool
+SmackManager::SetupPath(const PackageId& packageId, const String& dirPath, SmackDirType type)
+{
+       int res = 0;
+       String realPath;
+
+       std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(packageId));
+       TryReturn(pPackageId, false, "pPackageId is null.");
+
+       std::unique_ptr<char[]> pPath(_StringConverter::CopyToCharArrayN(dirPath));
+       TryReturn(pPath, false, "pPath is null.");
+
+       if (InstallerUtil::IsSymlink(dirPath) == true)
+       {
+               AddLabelDir("_", pPath.get());
+               InstallerUtil::GetRealPath(dirPath, realPath);
+       }
+       else
+       {
+               realPath = dirPath;
+       }
+
+       std::unique_ptr<char[]> pRealPath(_StringConverter::CopyToCharArrayN(realPath));
+       TryReturn(pRealPath, false, "pRealPath is null.");
+
+       if (type == SMACK_DIR_TYPE_GROUP_RW)
+       {
+               String groupId;
+
+               if (__pContext->__isVerificationMode == true)
+               {
+                       Sha1Hash hash;
+                       String base64Value;
+                       result r = E_SUCCESS;
+
+                       IListT<String *>* pAuthorCertList = __pContext->__pAuthorCertList;
+                       TryReturn(pAuthorCertList, false, "pAuthorCertList is null.");
+
+                       String* pEntity = null;
+                       r = pAuthorCertList->GetAt(0, pEntity);
+                       TryReturn(!IsFailed(r), false, "pAuthorCertList->GetAt() is failed.");
+                       TryReturn(pEntity, false, "pEntity is null.");
+
+                       std::unique_ptr<ByteBuffer> pEncodedData(StringUtil::DecodeBase64StringN(*pEntity));
+                       TryReturn(pEncodedData, false, "pEncodedData is null.");
+
+                       std::unique_ptr<ByteBuffer> pHashValue(hash.GetHashN(*pEncodedData.get()));
+                       TryReturn(pHashValue, false, "pHashValue is null.");
+
+                       r = StringUtil::EncodeToBase64String(*pHashValue, base64Value);
+                       TryReturn(!IsFailed(r), false, "EncodeToBase64String() is failed.");
+
+                       // in smack, '/' is not allowed for label.
+                       r = base64Value.Replace(L"/", L"#");
+                       TryReturn(!IsFailed(r), false, "base64Value.Replace() is failed.");
+
+                       std::unique_ptr<char[]> pHashEncodedValue(_StringConverter::CopyToCharArrayN(base64Value));
+                       TryReturn(pHashEncodedValue, false, "pHashEncodedValue is null.");
+
+                       groupId = pHashEncodedValue.get();
+                       AppLog("pHashEncodedValue = [%s]", pHashEncodedValue.get());
+               }
+               else
+               {
+                       groupId = __pContext->__packageId;
+               }
+
+               std::unique_ptr<char[]> pGroupId(_StringConverter::CopyToCharArrayN(groupId));
+               TryReturn(pGroupId, false, "pGroupId is null.");
+
+               res = SetupPath(pPackageId.get(), pRealPath.get(), (int) type, pGroupId.get());
+       }
+       else
+       {
+               res = SetupPath(pPackageId.get(), pRealPath.get(), (int) type);
+       }
+
+       return true;
+}
+
+bool
 SmackManager::IsSmackEnable()
 {
        result r;
@@ -546,6 +626,7 @@ SmackManager::AddLabelDir(const char* pLabel, const char* pDirPath)
        return 0;
 }
 
+#if 0
 int
 SmackManager::AddLabelSharedDir(const char* pLabel, const char* pSharedLabel, const char* pDirPath)
 {
@@ -578,7 +659,9 @@ SmackManager::AddLabelSharedDir(const char* pLabel, const char* pSharedLabel, co
 
        return 0;
 }
+#endif
 
+#if 0
 int
 SmackManager::AddSharedDirReaders(const char* pSharedLabel, const char** ppAppList)
 {
@@ -611,6 +694,7 @@ SmackManager::AddSharedDirReaders(const char* pSharedLabel, const char** ppAppLi
 
        return 0;
 }
+#endif
 
 int
 SmackManager::AddFriend(const char* pPackageId1, const char* pPackageId2)
@@ -712,37 +796,45 @@ SmackManager::RevokePermissions(const char* pPackageId)
 }
 
 int
-SmackManager::RegisterAv(const char* pPackageId)
+SmackManager::SetupPath(const char* pPackageId, const char* pDirPath, int appPathType, const char* pGroupId)
 {
        int ret = 0;
        void* pHandle = null;
        char* pErrorMsg = null;
-       int (*app_register_av)(const char*) = null;
+       int (*app_setup_path)(const char*, const char*, int, ...) = null;
 
        pHandle = dlopen("libprivilege-control.so.0", RTLD_LAZY | RTLD_GLOBAL);
        if (!pHandle)
        {
-               AppLog("RegisterAv(): dlopen() failed. [%s]", dlerror());
+               AppLog("dlopen() failed. [%s]", dlerror());
                return -1;
        }
 
-       app_register_av = reinterpret_cast <int (*)(const char*)>(dlsym(pHandle, "app_register_av"));
+       app_setup_path = reinterpret_cast <int (*)(const char*, const char*, int, ...)>(dlsym(pHandle, "app_setup_path"));
        pErrorMsg = dlerror();
-       if ((pErrorMsg != null) || (app_register_av == null))
+       if ((pErrorMsg != null) || (app_setup_path == null))
        {
-               AppLog("RegisterAv(): dlsym() failed. [%s]", pErrorMsg);
+               AppLog("dlsym() failed. [%s]", pErrorMsg);
                dlclose(pHandle);
                return -1;
        }
 
-       AppLog("[smack] app_register_av(%s)", pPackageId);
-       ret = app_register_av(pPackageId);
-       AppLog("[smack] app_register_av(%s), result = [%d]", pPackageId, ret);
+       if (pGroupId == null)
+       {
+               AppLog("[smack] app_setup_path(%s, %s, %d)", pPackageId, pDirPath, appPathType);
+               ret = app_setup_path(pPackageId, pDirPath, appPathType);
+               AppLog("[smack] app_setup_path(), result = [%d]", ret);
+       }
+       else
+       {
+               AppLog("[smack] app_setup_path(%s, %s, %d, %s)", pPackageId, pDirPath, appPathType, pGroupId);
+               ret = app_setup_path(pPackageId, pDirPath, appPathType, pGroupId);
+               AppLog("[smack] app_setup_path(), result = [%d]", ret);
+       }
 
        dlclose(pHandle);
 
        return ret;
-
 }
 
 ArrayList*
index 2a3f7e3..79b2c9b 100755 (executable)
@@ -38,13 +38,15 @@ public:
        bool Uninstall(const Tizen::App::PackageId& packageId);
 
        bool AddLabelDir(const Tizen::Base::String& label, const Tizen::Base::String& dirPath, bool rootDirectory = false);
-       bool AddLabelSharedDir(const Tizen::App::PackageId& packageId, const Tizen::Base::String& dirPath);
-       bool AddSharedDirReaders(const Tizen::Base::String& label);
+       //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);
 
        bool EnablePermissions(const Tizen::App::PackageId& packageId);
        bool RevokePermissions(const Tizen::App::PackageId& packageId);
 
+       bool SetupPath(const Tizen::App::PackageId& packageId, const Tizen::Base::String& dirPath, SmackDirType type);
+
 private:
        bool IsSmackEnable();
 
@@ -52,14 +54,14 @@ private:
        int Uninstall(const char* pPackageId);
 
        int AddLabelDir(const char* pLabel, const char* pDirPath);
-       int AddLabelSharedDir(const char* pLabel, const char* pSharedLabel, const char* pDirPath);
-       int AddSharedDirReaders(const char* pSharedLabel, const char** ppAppList);
+       //int AddLabelSharedDir(const char* pLabel, const char* pSharedLabel, const char* pDirPath);
+       //int AddSharedDirReaders(const char* pSharedLabel, const char** ppAppList);
        int AddFriend(const char* pPackageId1, const char* pPackageId2);
 
        int EnablePermissions(const char* pPackageId, int appType, const char** ppPermissions, bool persistent);
        int RevokePermissions(const char* pPackageId);
 
-       int RegisterAv(const char* pPackageId);
+       int SetupPath(const char* pPackageId, const char* pDirPath, int appPathType, const char* pGroupId = null);
 
        Tizen::Base::Collection::ArrayList* GetPreloadedAppListN() const;
 
index 72c545e..2b8fc12 100755 (executable)
@@ -115,8 +115,20 @@ PackageCheckStep::OnStatePackageCheck(void)
        if (InstallerUtil::IsDrmFile(packagePath) == true)
        {
                bool res = false;
-               res = InstallerUtil::DecryptPackage(packagePath);
+               String decryptedPath("/opt/usr/apps/tmp/");
+               decryptedPath.Append(__pContext->__packageId);
+               decryptedPath.Append("_dec.tpk");
+
+               if (File::IsFileExist(decryptedPath) == true)
+               {
+                       File::Remove(decryptedPath);
+               }
+
+               res = InstallerUtil::DecryptPackage(packagePath, decryptedPath);
                TryReturn(res == true, INSTALLER_ERROR_DRM, "InstallerUtil::DecryptPackage() failed");
+
+               __pContext->__packagePath = decryptedPath;
+               packagePath = decryptedPath;
        }
 
        FileUnzipper unzipper;
index 611f28c..5c7413e 100755 (executable)
@@ -21,6 +21,7 @@
 
 #include <sys/stat.h>
 #include <dirent.h>
+#include <dlfcn.h>
 #include <errno.h>
 #include <unistd.h>
 #include <unique_ptr.h>
@@ -371,13 +372,92 @@ InstallerUtil::ChangeDirectoryPermission(const String& filePath, int mode, bool
 bool
 InstallerUtil::IsDrmFile(const String& path)
 {
-       return false;
+       int ret = 0;
+       void* pHandle = null;
+       char* pErrorMsg = null;
+       int (*drm_oem_sapps_is_drm_file)(const char* pDcfPath, int dcfPathLen);
+
+       pHandle = dlopen("/usr/lib/libdrm-service-core-sapps.so.0", RTLD_LAZY | RTLD_GLOBAL);
+       if (!pHandle)
+       {
+               AppLog("dlopen() failed. [%ls][%s]", path.GetPointer(), dlerror());
+               return false;
+       }
+
+       drm_oem_sapps_is_drm_file = reinterpret_cast <int (*)(const char*, int)>(dlsym(pHandle, "drm_oem_sapps_is_drm_file"));
+       pErrorMsg = dlerror();
+       if ((pErrorMsg != null) || (drm_oem_sapps_is_drm_file == null))
+       {
+               AppLog("dlsym() failed. [%ls][%s]", path.GetPointer(), pErrorMsg);
+               dlclose(pHandle);
+               return false;
+       }
+
+       std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(path));
+       TryReturn(pFilePath, false, "pFilePath is null.");
+
+       AppLog("[drm] drm_oem_sapps_is_drm_file(%s, %d)", pFilePath.get(), strlen(pFilePath.get()));
+       ret = drm_oem_sapps_is_drm_file(pFilePath.get(), strlen(pFilePath.get()));
+       AppLog("[drm] drm_oem_sapps_is_drm_file(), result = [%d]", ret);
+
+       dlclose(pHandle);
+
+       if (ret == 1)
+       {
+               AppLog("file[%ls] is DRM file.", path.GetPointer());
+               return true;
+       }
+       else
+       {
+               return false;
+       }
 }
 
 bool
-InstallerUtil::DecryptPackage(const String& packagePath)
+InstallerUtil::DecryptPackage(const String& path, const String& decryptedPath)
 {
-       return true;
+       int ret = 0;
+       void* pHandle = null;
+       char* pErrorMsg = null;
+       int (*drm_oem_sapps_decrypt_package)(const char* pDcfPath, int dcfPathLen, const char* pDecryptedFile, int decryptedFileLen);
+
+       pHandle = dlopen("/usr/lib/libdrm-service-core-sapps.so.0", RTLD_LAZY | RTLD_GLOBAL);
+       if (!pHandle)
+       {
+               AppLog("dlopen() failed. [%ls][%s]", path.GetPointer(), dlerror());
+               return false;
+       }
+
+       drm_oem_sapps_decrypt_package = reinterpret_cast <int (*)(const char*, int, const char*, int)>(dlsym(pHandle, "drm_oem_sapps_decrypt_package"));
+       pErrorMsg = dlerror();
+       if ((pErrorMsg != null) || (drm_oem_sapps_decrypt_package == null))
+       {
+               AppLog("dlsym() failed. [%ls][%s]", path.GetPointer(), pErrorMsg);
+               dlclose(pHandle);
+               return false;
+       }
+
+       std::unique_ptr<char[]> pFilePath(_StringConverter::CopyToCharArrayN(path));
+       TryReturn(pFilePath, false, "pFilePath is null.");
+
+       std::unique_ptr<char[]> pDecryptedPath(_StringConverter::CopyToCharArrayN(decryptedPath));
+       TryReturn(pDecryptedPath, false, "pDecryptedPath is null.");
+
+       AppLog("[drm] drm_oem_sapps_decrypt_package(%s, %d, %s, %d)", pFilePath.get(), strlen(pFilePath.get()), pDecryptedPath.get(), strlen(pDecryptedPath.get()));
+       ret = drm_oem_sapps_decrypt_package(pFilePath.get(), strlen(pFilePath.get()), pDecryptedPath.get(), strlen(pDecryptedPath.get()));
+       AppLog("[drm] drm_oem_sapps_decrypt_package(), result = [%d]", ret);
+
+       dlclose(pHandle);
+
+       if (ret == 1)
+       {
+               AppLog("[%ls] -> [%ls] is decrypted.", path.GetPointer(), decryptedPath.GetPointer());
+               return true;
+       }
+       else
+       {
+               return false;
+       }
 }
 
 String
index 974b9bc..37a35d1 100755 (executable)
@@ -62,7 +62,7 @@ public:
        static bool     ChangeDirectoryPermission(const Tizen::Base::String& filePath, int mode, bool appOwner);
 
        static bool IsDrmFile(const Tizen::Base::String& path);
-       static bool DecryptPackage(const Tizen::Base::String& packagePath);
+       static bool DecryptPackage(const Tizen::Base::String& path, const Tizen::Base::String& decryptedPath);
 
        static Tizen::Base::String GetCategory(int categoryType);
        static int GetCategoryType(char* pCategory);
index b29d588..7272388 100755 (executable)
@@ -1325,11 +1325,6 @@ ManifestHandler::OnCategoryValue(const char* pCharacters)
        {
                __pAppData->__feature = CATEGORY_TYPE_IME;
        }
-       else if (strcasecmp(pCharacters, TIZEN_CATEGORY_ANTIVIRUS) == 0)
-       {
-               AppLog("ANTIVIRUS Package is detected.");
-               __pContext->__isAntiVirus = true;
-       }
 
        return true;
 }