Add privilege level check for plugin parser 01/241401/1
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 20 Aug 2020 00:53:06 +0000 (09:53 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Thu, 20 Aug 2020 00:53:06 +0000 (09:53 +0900)
App-defined loader feature is only for platform developers.

Change-Id: Icbb87b3835bf3e4b866aeb9f8e66896256bc9e71
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
packaging/launchpad.spec
src/parser/CMakeLists.txt
src/parser/launchpad_parser_plugin.cc

index 2994a022904a7368085467cbf282cf18cb0b3712..83a9da1086317d968c3606254e439450eb80f9e4 100644 (file)
@@ -31,6 +31,7 @@ BuildRequires:  pkgconfig(dbus-1)
 BuildRequires:  pkgconfig(iniparser)
 BuildRequires:  pkgconfig(libxml-2.0)
 BuildRequires:  pkgconfig(libsmack)
+BuildRequires:  pkgconfig(pkgmgr-installer)
 
 Requires(post): /sbin/ldconfig
 Requires(post): /usr/bin/systemctl
index f98579f4561ffcecc38bf11eee8908239fc9dbb6..29374bde81a6bd22b1f8b3993ae5faf4307d0693 100644 (file)
@@ -5,6 +5,7 @@ INCLUDE(FindPkgConfig)
 pkg_check_modules(PKGS REQUIRED
        dlog
        libxml-2.0
+       pkgmgr-installer
 )
 
 FOREACH(FLAGS ${PKGS_CFLAGS})
index 9abaeb2e339523e5a360bc3bd9f2245dfcb8febd..b7734c0f77373588a2a3c69020dfa94e40cdf44c 100644 (file)
  * limitations under the License.
  */
 
-#include <fstream>
-#include <string>
-
+#include <sys/types.h>
+#include <pkgmgr_installer_info.h>
 #include <sys/stat.h>
 #include <unistd.h>
 
+#include <fstream>
+#include <string>
+
 #include "launchpad_parser_plugin.hh"
 #include "log_private.hh"
 
@@ -85,6 +87,13 @@ bool LaunchpadParser::IsValidId(string loader_id, string pkgid) {
 }
 
 int LaunchpadParser::Install(xmlDocPtr doc, string pkgid) {
+  pkgmgr_privilege_level level;
+  pkgmgr_installer_info_get_privilege_level(&level);
+  if (level != PM_PRIVILEGE_PLATFORM) {
+    LOGE("Privilege level(%d) is not platform", static_cast<int>(level));
+    return -1;
+  }
+
   xmlNode* root = xmlDocGetRootElement(doc);
   for (xmlNode* node = root->children; node; node = node->next) {
     if (!node->name)