Add path checking at multi pkg install APIs 41/234141/1
authorSangyoon Jang <jeremy.jang@samsung.com>
Fri, 22 May 2020 06:50:43 +0000 (15:50 +0900)
committerSangyoon Jang <jeremy.jang@samsung.com>
Fri, 22 May 2020 06:50:43 +0000 (15:50 +0900)
Change-Id: I3a07d3f9c1b52b8c4ee871d043a7c797abc52d7c
Signed-off-by: Sangyoon Jang <jeremy.jang@samsung.com>
client/src/pkgmgr.c

index e30b3f9..cfbeb09 100644 (file)
@@ -400,6 +400,13 @@ API int pkgmgr_client_usr_install_packages(pkgmgr_client *pc,
                return PKGMGR_R_EINVAL;
        }
 
+       for (i = 0; i < n_pkgs; i++) {
+               if (access(pkg_paths[i], F_OK) != 0) {
+                       ERR("failed to access: %s", pkg_paths[i]);
+                       return PKGMGR_R_EINVAL;
+               }
+       }
+
        pkgs_builder = g_variant_builder_new(G_VARIANT_TYPE("as"));
        for (i = 0; i < n_pkgs; i++)
                g_variant_builder_add(pkgs_builder, "s", pkg_paths[i]);
@@ -635,6 +642,13 @@ API int pkgmgr_client_usr_mount_install_packages(pkgmgr_client *pc,
                return PKGMGR_R_EINVAL;
        }
 
+       for (i = 0; i < n_pkgs; i++) {
+               if (access(pkg_paths[i], F_OK) != 0) {
+                       ERR("failed to access: %s", pkg_paths[i]);
+                       return PKGMGR_R_EINVAL;
+               }
+       }
+
        pkgs_builder = g_variant_builder_new(G_VARIANT_TYPE("as"));
        for (i = 0; i < n_pkgs; i++)
                g_variant_builder_add(pkgs_builder, "s", pkg_paths[i]);