Sort privilege list before call security-manager function. 60/48060/1 tizen_3.0.m1_mobile tizen_3.0.m1_tv accepted/tizen/mobile/20150911.150711 accepted/tizen/tv/20150911.150722 accepted/tizen/wearable/20150911.150727 submit/tizen/20150911.145534 submit/tizen_common/20151023.083358 submit/tizen_common/20151026.085049 tizen_3.0.m1_mobile_release tizen_3.0.m1_tv_release
authorWonYoung Choi <wy80.choi@samsung.com>
Fri, 11 Sep 2015 14:38:11 +0000 (23:38 +0900)
committerWonYoung Choi <wy80.choi@samsung.com>
Fri, 11 Sep 2015 14:38:11 +0000 (23:38 +0900)
SecurityManager considers the privilege list is always sorted.

Change-Id: Ib5a9632e3d1d310d49aa55d29acca16ea4e3d670

src/common/security_registration.cc

index aab8a67..fe0a1b1 100644 (file)
@@ -9,6 +9,7 @@
 
 #include <utility>
 #include <vector>
+#include <algorithm>
 
 #include "common/utils/clist_helpers.h"
 #include "common/utils/logging.h"
@@ -63,16 +64,25 @@ bool PrepareRequest(const std::string& app_id, const std::string& pkg_id,
   }
 
   if (manifest) {
+    std::vector<std::string> priv_vec;
+
     privileges_x *privileges = nullptr;
     PKGMGR_LIST_MOVE_NODE_TO_HEAD(manifest->privileges, privileges);
     for (; privileges != nullptr; privileges = privileges->next) {
       privilege_x* priv = nullptr;
       PKGMGR_LIST_MOVE_NODE_TO_HEAD(privileges->privilege, priv);
       for (; priv != nullptr; priv = priv->next) {
-        security_manager_app_inst_req_add_privilege(req, priv->text);
+        priv_vec.push_back(priv->text);
       }
     }
+
+    // privileges should be sorted.
+    std::sort(priv_vec.begin(), priv_vec.end());
+    for (auto& priv : priv_vec) {
+      security_manager_app_inst_req_add_privilege(req, priv.c_str());
+    }
   }
+
   return true;
 }