Installer SignatureValidator implementation
[platform/framework/native/installer.git] / src / Manager / SmackManager.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 /**
18  * @file        SmackManager.cpp
19  * @brief       This is the implementation file for %SmackManager class.
20  */
21
22 #include <dlfcn.h>
23 #include <unique_ptr.h>
24
25 #include <FIoFile.h>
26 #include <FIoRegistry.h>
27 #include <FSecCryptoSha1Hash.h>
28 #include <FBase_StringConverter.h>
29
30 #include "SmackManager.h"
31 #include "InstallerDefs.h"
32 #include "InstallerUtil.h"
33
34 using namespace Tizen::App;
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Collection;
37 using namespace Tizen::Base::Utility;
38 using namespace Tizen::Security::Cert;
39 using namespace Tizen::Security::Crypto;
40 using namespace Tizen::Io;
41
42 SmackManager::SmackManager(void)
43 :__pContext(null)
44 ,__isSmackEnable(false)
45 {
46         if (IsSmackEnable() == true)
47         {
48                 __isSmackEnable = true;
49         }
50 }
51
52 SmackManager::~SmackManager(void)
53 {
54 }
55
56 bool
57 SmackManager::Construct(InstallationContext* pContext)
58 {
59         __pContext = pContext;
60
61         return true;
62 }
63
64 bool
65 SmackManager::Install(const PackageId& packageId)
66 {
67         if (__isSmackEnable == false)
68         {
69                 return true;
70         }
71
72         int res = 0;
73
74         std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(packageId));
75         TryReturn(pPackageId, false, "pPackageId is null.");
76
77         res = Install(pPackageId.get());
78
79         return true;
80 }
81
82 bool
83 SmackManager::Uninstall(const PackageId& packageId)
84 {
85         if (__isSmackEnable == false)
86         {
87                 return true;
88         }
89
90         int res = 0;
91
92         std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(packageId));
93         TryReturn(pPackageId, false, "pPackageId is null.");
94
95         res = Uninstall(pPackageId.get());
96
97         return true;
98 }
99
100 bool
101 SmackManager::AddLabelDir(const String& label, const String& dirPath, bool rootDirectory)
102 {
103         if (__isSmackEnable == false)
104         {
105                 return true;
106         }
107
108         int res = 0;
109         String realPath;
110
111         std::unique_ptr<char[]> pPath(_StringConverter::CopyToCharArrayN(dirPath));
112         TryReturn(pPath, false, "pPath is null.");
113
114         if (InstallerUtil::IsSymlink(dirPath) == true)
115         {
116                 res = AddLabelDir("_", pPath.get());
117                 InstallerUtil::GetRealPath(dirPath, realPath);
118         }
119         else
120         {
121                 realPath = dirPath;
122         }
123
124         std::unique_ptr<char[]> pRealPath(_StringConverter::CopyToCharArrayN(realPath));
125         TryReturn(pRealPath, false, "pRealPath is null");
126
127         if (rootDirectory == true)
128         {
129                 res = AddLabelDir("_", pRealPath.get());
130         }
131         else if (dirPath.Contains(L"shared") == true)
132         {
133                 res = AddLabelDir("*", pRealPath.get());
134         }
135         else
136         {
137                 std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(label));
138                 TryReturn(pPackageId, false, "pPackageId is null");
139
140                 res = AddLabelDir(pPackageId.get(), pRealPath.get());
141         }
142
143         return true;
144 }
145
146 bool
147 SmackManager::AddLabelSharedDir(const PackageId& packageId, const String& dirPath)
148 {
149         if (__isSmackEnable == false)
150         {
151                 return true;
152         }
153
154         TryReturn(__pContext, false, "__pContext is null");
155
156         if (__pContext->__isVerificationMode == false)
157         {
158                 AppLog("VerificationMode is off.");
159                 return true;
160         }
161
162         int res = 0;
163         String label = packageId;
164
165         std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(packageId));
166         TryReturn(pPackageId, false, "pPackageId is null.");
167
168         std::unique_ptr<char[]> pPath(_StringConverter::CopyToCharArrayN(dirPath));
169         TryReturn(pPath, false, "pPath is null.");
170
171         if (dirPath.Contains(L"shared/data") == true)
172         {
173                 label = L"*";
174                 //label.Append("_shareddata");
175         }
176         else if (dirPath.Contains(L"shared/res") == true)
177         {
178                 label = L"*";
179                 //label.Append("_sharedres");
180         }
181         else if (dirPath.Contains(L"shared/trusted") == true)
182         {
183                 Sha1Hash hash;
184                 String base64Value;
185                 result r = E_SUCCESS;
186
187                 IListT<String *>* pAuthorCertList = __pContext->__pAuthorCertList;
188                 TryReturn(pAuthorCertList, false, "pAuthorCertList is null.");
189
190                 String *pEntity = null;
191                 r = pAuthorCertList->GetAt(0, pEntity);
192                 TryReturn(!IsFailed(r), false, "pAuthorCertList->GetAt() is failed.");
193                 TryReturn(pEntity, false, "pEntity is null.");
194
195                 std::unique_ptr<ByteBuffer> pEncodedData(StringUtil::DecodeBase64StringN(*pEntity));
196                 TryReturn(pEncodedData, false, "pEncodedData is null.");
197
198                 std::unique_ptr<ByteBuffer> pHashValue(hash.GetHashN(*pEncodedData.get()));
199                 TryReturn(pHashValue, false, "pHashValue is null.");
200
201                 r = StringUtil::EncodeToBase64String(*pHashValue, base64Value);
202                 TryReturn(!IsFailed(r), false, "EncodeToBase64String() is failed.");
203
204                 // in smack, '/' is not allowed for label.
205                 r = base64Value.Replace(L"/", L"#");
206                 TryReturn(!IsFailed(r), false, "base64Value.Replace() is failed.");
207
208                 std::unique_ptr<char[]> pHashEncodedValue(_StringConverter::CopyToCharArrayN(base64Value));
209                 TryReturn(!IsFailed(r), false, "pHashEncodedValue is null.");
210
211                 label = pHashEncodedValue.get();
212                 AppLog("pHashEncodedValue = [%s]", pHashEncodedValue.get());
213         }
214         else
215         {
216                 AppLog("Invalid Directory = [%ls]", dirPath.GetPointer());
217                 return false;
218         }
219
220         std::unique_ptr<char[]> pLabel(_StringConverter::CopyToCharArrayN(label));
221         TryReturn(pLabel, false, "pLabel is null.");
222
223         res = AddLabelSharedDir(pPackageId.get(), pLabel.get(), pPath.get());
224
225         return true;
226 }
227
228 bool
229 SmackManager::AddSharedDirReaders(const Tizen::Base::String& label)
230 {
231         if (__isSmackEnable == false)
232         {
233                 return true;
234         }
235
236         //int AddSharedDirReaders(const char* pSharedLabel, const char** ppAppList);
237
238         return true;
239 }
240
241 bool
242 SmackManager::AddFriend(const Tizen::App::PackageId& packageId1, const Tizen::App::PackageId& packageId2)
243 {
244         if (__isSmackEnable == false)
245         {
246                 return true;
247         }
248
249         //int AddFriend(const char* pPackageId1, const char* pPackageId2);
250
251         return true;
252 }
253
254 bool
255 SmackManager::EnablePermissions(const PackageId& packageId)
256 {
257         if (__isSmackEnable == false)
258         {
259                 return true;
260         }
261
262         TryReturn(__pContext, false, "__pContext is null");
263
264         int res = 0;
265
266         std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(packageId));
267         TryReturn(pPackageId, false, "pPackageId is null.");
268
269         int count = __pContext->__pPrivilegeList->GetCount();
270
271         const char** pList = new (std::nothrow) const char*[count+1];
272         TryReturn(pList, false, "pList is null.");
273
274         for (int i = 0; i < count; i++)
275         {
276                 String* pPrivilege = dynamic_cast < String* >(__pContext->__pPrivilegeList->GetAt(i));
277                 if (pPrivilege)
278                 {
279                         char* pPrivilegeString = _StringConverter::CopyToCharArrayN(*pPrivilege);
280                         TryReturn(pPrivilegeString, false, "pPrivilegeString is null.");
281
282                         pList[i] = pPrivilegeString;
283                 }
284          }
285
286         pList[count] = null;
287
288         res = EnablePermissions(pPackageId.get(), 1, pList, true);
289
290         if ((__pContext->__isPreloaded == true) && (__pContext->__isUpdated == false))
291         {
292                 String smackFile(L"/etc/smack/accesses2.d/");
293                 smackFile.Append(packageId);
294                 smackFile.Append(L"-temp.rule");
295
296                 String smackContext(packageId);
297                 smackContext.Append(L" all.rule include");
298
299                 InstallerUtil::CreateInfoFile(smackFile, &smackContext);
300         }
301         else
302         {
303                 String script("/usr/bin/smackload-app.sh");
304                 bool exist = File::IsFileExist(script);
305                 script.Append(L" ");
306                 script.Append(packageId);
307
308                 std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(script));
309                 TryReturn(pScript, false, "pScript is null.");
310
311                 if (exist == true)
312                 {
313                         res = system(pScript.get());
314                         AppLog("[smack] system(%s), result = [%d]", pScript.get(), res);
315                 }
316                 else
317                 {
318                         AppLog("[%ls] not found", script.GetPointer());
319                 }
320         }
321
322         for (int i = 0; pList[i] != null; i++)
323         {
324                 AppLog("delete Privilege - [%s]", pList[i]);
325                 delete[] pList[i];
326          }
327         delete[] pList;
328
329         return true;
330 }
331
332 #if 0
333 bool
334 SmackManager::AddPermissions(const PackageId& packageId)
335 {
336         if (__isSmackEnable == false)
337         {
338                 return true;
339         }
340
341         TryReturn(__pContext, false, "__pContext is null");
342
343         int res = 0;
344
345         std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(packageId));
346         TryReturn(pPackageId, false, "pPackageId is null.");
347
348         int count = __pContext->__pPrivilegeList->GetCount();
349
350         const char** pList = new (std::nothrow) const char*[count+1];
351         TryReturn(pList, false, "pList is null.");
352
353         for (int i = 0; i < count; i++)
354         {
355                 String* pPrivilege = dynamic_cast < String* >(__pContext->__pPrivilegeList->GetAt(i));
356                 if (pPrivilege)
357                 {
358                         char* pPrivilegeString = _StringConverter::CopyToCharArrayN(*pPrivilege);
359                         TryReturn(pPrivilegeString, false, "pPrivilegeString is null.");
360
361                         pList[i] = pPrivilegeString;
362                 }
363          }
364
365         pList[count] = null;
366
367         res = AddPermissions(pPackageId.get(), pList);
368
369         if (__pContext->__isPreloaded == true)
370         {
371                 String smackFile(L"/etc/smack/accesses2.d/");
372                 smackFile.Append(packageId);
373                 smackFile.Append(L"-temp.rule");
374
375                 String smackContext(packageId);
376                 smackContext.Append(L" all.rule include");
377
378                 InstallerUtil::CreateInfoFile(smackFile, &smackContext);
379         }
380         else
381         {
382                 String script("/usr/bin/smackload-app.sh");
383                 bool exist = File::IsFileExist(script);
384                 script.Append(L" ");
385                 script.Append(packageId);
386
387                 std::unique_ptr<char[]> pScript(_StringConverter::CopyToCharArrayN(script));
388                 TryReturn(pScript, false, "pScript is null.");
389
390                 if (exist == true)
391                 {
392                         res = system(pScript.get());
393                         AppLog("[smack] system(%s), result = [%d]", pScript.get(), res);
394                 }
395                 else
396                 {
397                         AppLog("[%ls] not found", script.GetPointer());
398                 }
399         }
400
401         for (int i = 0; pList[i] != null; i++)
402         {
403                 AppLog("delete Privilege - [%s]", pList[i]);
404                 delete[] pList[i];
405          }
406         delete[] pList;
407
408         return true;
409 }
410 #endif
411
412 bool
413 SmackManager::RevokePermissions(const PackageId& packageId)
414 {
415         if (__isSmackEnable == false)
416         {
417                 return true;
418         }
419
420         int res = 0;
421
422         std::unique_ptr<char[]> pPackageId(_StringConverter::CopyToCharArrayN(packageId));
423         TryReturn(pPackageId, false, "pPackageId is null.");
424
425         res = RevokePermissions(pPackageId.get());
426
427         return true;
428 }
429
430 bool
431 SmackManager::IsSmackEnable()
432 {
433         result r;
434         Registry reg;
435         String section(L"feature");
436         String entry(L"smack");
437         String value;
438
439         r = reg.Construct(CONFIG_PATH, "r");
440         TryReturn(!IsFailed(r), false, "CONFIG file is not found.");
441
442         r = reg.GetValue(section, entry, value);
443         TryReturn(!IsFailed(r), false, "GetValue is failed. entry = [%ls]", entry.GetPointer());
444
445         AppLog("[%ls is %ls.]", entry.GetPointer(), value.GetPointer());
446
447         if (value == L"on")
448         {
449                 return true;
450         }
451
452         return false;
453 }
454
455 int
456 SmackManager::Install(const char* pPackageId)
457 {
458         int ret = 0;
459         void* pHandle = null;
460         char* pErrorMsg = null;
461         int (*app_install)(const char*) = null;
462
463         pHandle = dlopen("libprivilege-control.so.0", RTLD_LAZY | RTLD_GLOBAL);
464         if (!pHandle)
465         {
466                 AppLog("Install(): dlopen() failed. [%s]", dlerror());
467                 return -1;
468         }
469
470         app_install = reinterpret_cast <int (*)(const char*)>(dlsym(pHandle, "app_install"));
471         pErrorMsg = dlerror();
472         if ((pErrorMsg != null) || (app_install == null))
473         {
474                 AppLog("Install(): dlsym() failed. [%s]", pErrorMsg);
475                 dlclose(pHandle);
476                 return -1;
477         }
478
479         ret = app_install(pPackageId);
480         AppLog("[smack] app_install(%s), result = [%d]", pPackageId, ret);
481
482         dlclose(pHandle);
483
484         return ret;
485 }
486
487 int
488 SmackManager::Uninstall(const char* pPackageId)
489 {
490         int ret = 0;
491         void* pHandle = null;
492         char* pErrorMsg = null;
493         int (*app_uninstall)(const char*) = null;
494
495         pHandle = dlopen("libprivilege-control.so.0", RTLD_LAZY | RTLD_GLOBAL);
496         if (!pHandle)
497         {
498                 AppLog("Uninstall(): dlopen() failed. [%s]", dlerror());
499                 return -1;
500         }
501
502         app_uninstall = reinterpret_cast <int (*)(const char*)>(dlsym(pHandle, "app_uninstall"));
503         pErrorMsg = dlerror();
504         if ((pErrorMsg != null) || (app_uninstall == null))
505         {
506                 AppLog("Uninstall(): dlsym() failed. [%s]", pErrorMsg);
507                 dlclose(pHandle);
508                 return -1;
509         }
510
511         ret = app_uninstall(pPackageId);
512         AppLog("[smack] app_uninstall(%s), result = [%d]", pPackageId, ret);
513
514         dlclose(pHandle);
515
516         return ret;
517 }
518
519 int
520 SmackManager::AddLabelDir(const char* pLabel, const char* pDirPath)
521 {
522         int ret = 0;
523         void* pHandle = null;
524         char* pErrorMsg = null;
525         int (*app_label_dir)(const char*, const char*) = null;
526
527         pHandle = dlopen("libprivilege-control.so.0", RTLD_LAZY | RTLD_GLOBAL);
528         if (!pHandle)
529         {
530                 AppLog("AddLabelDir(): dlopen() failed. [%s]", dlerror());
531                 return -1;
532         }
533
534         app_label_dir = reinterpret_cast <int (*)(const char*, const char*)>(dlsym(pHandle, "app_label_dir"));
535         pErrorMsg = dlerror();
536         if ((pErrorMsg != null) || (app_label_dir == null))
537         {
538                 AppLog("AddLabelDir(): dlsym() failed. [%s]", pErrorMsg);
539                 dlclose(pHandle);
540                 return -1;
541         }
542
543         ret = app_label_dir(pLabel, pDirPath);
544         AppLog("[smack] app_label_dir(%s, %s), result = [%d]", pLabel, pDirPath, ret);
545
546         dlclose(pHandle);
547
548         return 0;
549 }
550
551 int
552 SmackManager::AddLabelSharedDir(const char* pLabel, const char* pSharedLabel, const char* pDirPath)
553 {
554         int ret = 0;
555         void* pHandle = null;
556         char* pErrorMsg = null;
557         int (*app_label_shared_dir)(const char*, const char*, const char*) = null;
558
559         pHandle = dlopen("libprivilege-control.so.0", RTLD_LAZY | RTLD_GLOBAL);
560         if (!pHandle)
561         {
562                 AppLog("AddLabelSharedDir(): dlopen() failed. [%s]", dlerror());
563                 return -1;
564         }
565
566         app_label_shared_dir = reinterpret_cast <int (*)(const char*, const char*, const char*)>(dlsym(pHandle, "app_label_shared_dir"));
567         pErrorMsg = dlerror();
568         if ((pErrorMsg != null) || (app_label_shared_dir == null))
569         {
570                 AppLog("AddLabelSharedDir(): dlsym() failed. [%s]", pErrorMsg);
571                 dlclose(pHandle);
572                 return -1;
573         }
574
575         ret = app_label_shared_dir(pLabel, pSharedLabel, pDirPath);
576         AppLog("[smack] app_label_shared_dir(%s, %s, %s), result = [%d]", pLabel, pSharedLabel, pDirPath, ret);
577
578         dlclose(pHandle);
579
580         return 0;
581 }
582
583 int
584 SmackManager::AddSharedDirReaders(const char* pSharedLabel, const char** ppAppList)
585 {
586         int ret = 0;
587         void* pHandle = null;
588         char* pErrorMsg = null;
589         int (*add_shared_dir_readers)(const char*, const char**) = null;
590
591         pHandle = dlopen("libprivilege-control.so.0", RTLD_LAZY | RTLD_GLOBAL);
592         if (!pHandle)
593         {
594                 AppLog("AddSharedDirReaders(): dlopen() failed. [%s]", dlerror());
595                 return -1;
596         }
597
598         add_shared_dir_readers = reinterpret_cast <int (*)(const char*, const char**)>(dlsym(pHandle, "add_shared_dir_readers"));
599         pErrorMsg = dlerror();
600         if ((pErrorMsg != null) || (add_shared_dir_readers == null))
601         {
602                 AppLog("AddSharedDirReaders(): dlsym() failed. [%s]", pErrorMsg);
603                 dlclose(pHandle);
604                 return -1;
605         }
606
607         ret = add_shared_dir_readers(pSharedLabel, ppAppList);
608         AppLog("[smack] add_shared_dir_readers(%s), result = [%d]", pSharedLabel, ret);
609
610         dlclose(pHandle);
611
612         return 0;
613 }
614
615 int
616 SmackManager::AddFriend(const char* pPackageId1, const char* pPackageId2)
617 {
618         int ret = 0;
619         void* pHandle = null;
620         char* pErrorMsg = null;
621         int (*app_add_friend)(const char*, const char*) = null;
622
623         pHandle = dlopen("libprivilege-control.so.0", RTLD_LAZY | RTLD_GLOBAL);
624         if (!pHandle)
625         {
626                 AppLog("AddFriend(): dlopen() failed. [%s]", dlerror());
627                 return -1;
628         }
629
630         app_add_friend = reinterpret_cast <int (*)(const char*, const char*)>(dlsym(pHandle, "app_add_friend"));
631         pErrorMsg = dlerror();
632         if ((pErrorMsg != null) || (app_add_friend == null))
633         {
634                 AppLog("AddFriend(): dlsym() failed. [%s]", pErrorMsg);
635                 dlclose(pHandle);
636                 return -1;
637         }
638
639         ret = app_add_friend(pPackageId1, pPackageId2);
640         AppLog("[smack] app_add_friend(%s, %s), result = [%d]", pPackageId1, pPackageId2, ret);
641
642         dlclose(pHandle);
643
644         return 0;
645 }
646
647 int
648 SmackManager::EnablePermissions(const char* pPackageId, int appType, const char** ppPermissions, bool persistent)
649 {
650         int ret = 0;
651         void* pHandle = null;
652         char* pErrorMsg = null;
653         int (*app_enable_permissions)(const char*, int, const char**, bool) = null;
654
655         pHandle = dlopen("libprivilege-control.so.0", RTLD_LAZY | RTLD_GLOBAL);
656         if (!pHandle)
657         {
658                 AppLog("EnablePermissions(): dlopen() failed. [%s]", dlerror());
659                 return -1;
660         }
661
662         app_enable_permissions = reinterpret_cast <int (*)(const char*, int, const char**, bool)>(dlsym(pHandle, "app_enable_permissions"));
663         pErrorMsg = dlerror();
664         if ((pErrorMsg != null) || (app_enable_permissions == null))
665         {
666                 AppLog("EnablePermissions(): dlsym() failed. [%s]", pErrorMsg);
667                 dlclose(pHandle);
668                 return -1;
669         }
670
671         ret = app_enable_permissions(pPackageId, appType, ppPermissions, persistent);
672         AppLog("[smack] app_enable_permissions(%s, %d), result = [%d]", pPackageId, appType, ret);
673
674         dlclose(pHandle);
675
676         return 0;
677 }
678
679 int
680 SmackManager::RevokePermissions(const char* pPackageId)
681 {
682         int ret = 0;
683         void* pHandle = null;
684         char* pErrorMsg = null;
685         int (*app_revoke_permissions)(const char*) = null;
686
687         pHandle = dlopen("libprivilege-control.so.0", RTLD_LAZY | RTLD_GLOBAL);
688         if (!pHandle)
689         {
690                 AppLog("RevokePermissions(): dlopen() failed. [%s][%s]", pPackageId, dlerror());
691                 return -1;
692         }
693
694         app_revoke_permissions = reinterpret_cast <int (*)(const char*)>(dlsym(pHandle, "app_revoke_permissions"));
695         pErrorMsg = dlerror();
696         if ((pErrorMsg != null) || (app_revoke_permissions == null))
697         {
698                 AppLog("RevokePermissions(): dlsym() failed. [%s][%s]", pPackageId, pErrorMsg);
699                 dlclose(pHandle);
700                 return -1;
701         }
702
703         ret = app_revoke_permissions(pPackageId);
704         AppLog("[smack] app_revoke_permissions(%s), result = [%d]", pPackageId, ret);
705
706         dlclose(pHandle);
707
708         return 0;
709 }
710
711 #if 0
712 int
713 SmackManager::AddPermissions(const char* pPackageId, const char** ppPermissions)
714 {
715         int ret = 0;
716         void* pHandle = null;
717         char* pErrorMsg = null;
718         int (*app_add_permissions)(const char*, const char**) = null;
719
720         pHandle = dlopen("libprivilege-control.so.0", RTLD_LAZY | RTLD_GLOBAL);
721         if (!pHandle)
722         {
723                 AppLog("AddPermissions(): dlopen() failed. [%s][%s]", pPackageId, dlerror());
724                 return -1;
725         }
726
727         app_add_permissions = reinterpret_cast <int (*)(const char*, const char**)>(dlsym(pHandle, "app_add_permissions"));
728         pErrorMsg = dlerror();
729         if ((pErrorMsg != null) || (app_add_permissions == null))
730         {
731                 AppLog("AddPermissions(): dlsym() failed. [%s][%s]", pPackageId, pErrorMsg);
732                 dlclose(pHandle);
733                 return -1;
734         }
735
736         for (int i = 0; ppPermissions[i] != null; i++)
737         {
738                 AppLog("Privilege - [%s]", ppPermissions[i]);
739          }
740
741         ret = app_add_permissions(pPackageId, ppPermissions);
742         AppLog("[smack] app_add_permissions(%s), result = [%d]", pPackageId, ret);
743
744         dlclose(pHandle);
745
746         return 0;
747 }
748 #endif