#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"
};
+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_
,__isVerificationMode(false)
,__isUpdated(false)
,__isAppSetting(false)
-,__isAntiVirus(false)
,__isCsc(false)
,__isUninstallable(false)
,__isVirtualRoot(false)
bool __isVerificationMode;
bool __isUpdated;
bool __isAppSetting;
- bool __isAntiVirus;
bool __isCsc;
bool __isUninstallable;
bool __isVirtualRoot;
{
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.");
InstallerUtil::Remove(DIR_OSP_APPLICATIONS_TEMP);
}
+ if (File::IsFileExist(DIR_MEMORYCARD_OSP_APPLICATIONS) == true)
+ {
+ InstallerUtil::Remove(DIR_MEMORYCARD_OSP_APPLICATIONS);
+ }
+
return errorType;
}
continue;
}
+ if (entry.IsDirectory() == false)
+ {
+ continue;
+ }
+
+ if (entryName.StartsWith(L".", 0) == true)
+ {
+ continue;
+ }
+
int length = 0;
app2ext_dir_details* pDirDetails = null;
// 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;
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;
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;
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";
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
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;
// 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;
}
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 {
}
else if (sigFileNumber == SIGNATURE_FILE_NUMBER_DISTRIBUTOR2)
{
- __pContext->__pDistributorCertList2->Add(new String(value.c_str()));
AppLog("Default distributor2 cert value=[%s]", value.c_str());
}
}
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.");
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());
}
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.");
}
}
}
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;
+ }
}
}
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;
}
return true;
}
+#if 0
bool
SmackManager::AddLabelSharedDir(const PackageId& packageId, const String& dirPath)
{
return true;
}
+#endif
+#if 0
bool
SmackManager::AddSharedDirReaders(const String& label)
{
return res;
}
+#endif
bool
SmackManager::AddFriend(const Tizen::App::PackageId& packageId1, const Tizen::App::PackageId& packageId2)
}
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;
return 0;
}
+#if 0
int
SmackManager::AddLabelSharedDir(const char* pLabel, const char* pSharedLabel, const char* pDirPath)
{
return 0;
}
+#endif
+#if 0
int
SmackManager::AddSharedDirReaders(const char* pSharedLabel, const char** ppAppList)
{
return 0;
}
+#endif
int
SmackManager::AddFriend(const char* pPackageId1, const char* pPackageId2)
}
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*
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();
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;
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;
#include <sys/stat.h>
#include <dirent.h>
+#include <dlfcn.h>
#include <errno.h>
#include <unistd.h>
#include <unique_ptr.h>
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
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);
{
__pAppData->__feature = CATEGORY_TYPE_IME;
}
- else if (strcasecmp(pCharacters, TIZEN_CATEGORY_ANTIVIRUS) == 0)
- {
- AppLog("ANTIVIRUS Package is detected.");
- __pContext->__isAntiVirus = true;
- }
return true;
}