+SmackManager::EnablePermissions(const PackageId& packageId)
+{
+ if (__isSmackEnable == false)
+ {
+ return true;
+ }
+
+ TryReturn(__pContext, false, "__pContext is null");
+
+ int res = 0;
+
+ std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(packageId));
+ TryReturn(pPackageId, false, "pPackageId is null.");
+
+ int count = __pContext->__pPrivilegeList->GetCount();
+
+ const char** pList = new (std::nothrow) const char*[count+1];
+ TryReturn(pList, false, "pList is null.");
+
+ for (int i = 0; i < count; i++)
+ {
+ String* pPrivilege = dynamic_cast < String* >(__pContext->__pPrivilegeList->GetAt(i));
+ if (pPrivilege)
+ {
+ char* pPrivilegeString = _StringConverter::CopyToCharArrayN(*pPrivilege);
+ TryReturn(pPrivilegeString, false, "pPrivilegeString is null.");
+
+ pList[i] = pPrivilegeString;
+ }
+ }
+
+ pList[count] = null;
+
+ res = EnablePermissions(pPackageId.get(), 1, pList, true);
+
+ if (__pContext->__isPreloaded == true)
+ {
+ String smackFile(L"/etc/smack/accesses2.d/");
+ smackFile.Append(packageId);
+ smackFile.Append(L"-temp.rule");
+
+ String smackContext(packageId);
+ smackContext.Append(L" all.rule include");
+
+ InstallerUtil::CreateInfoFile(smackFile, &smackContext);
+ }
+ else
+ {
+ String script("/usr/bin/smackload-app.sh");
+ bool exist = File::IsFileExist(script);
+ script.Append(L" ");
+ script.Append(packageId);
+
+ std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(script));
+ TryReturn(pScript, false, "pScript is null.");
+
+ if (exist == true)
+ {
+ res = system(pScript.get());
+ AppLog("[smack] system(%s), result = [%d]", pScript.get(), res);
+ }
+ else
+ {
+ AppLog("[%ls] not found", script.GetPointer());
+ }
+ }
+
+ for (int i = 0; pList[i] != null; i++)
+ {
+ AppLog("delete Privilege - [%s]", pList[i]);
+ delete[] pList[i];
+ }
+ delete[] pList;
+
+ return true;
+}
+
+#if 0
+bool