int _coretpk_installer_get_group_id(char *pkgid, char **result);
void _coretpk_installer_set_privilege_setup_path(char *pkgid, char *dirpath, app_path_type_t type, char *label);
+int __coretpk_patch_padded_api_version(const char *api_version, char **pad_api_version)
+{
+ char *pad_version = NULL;
+ char *ptr_fw = NULL;
+ char *ptr_bw = NULL;
+
+ pad_version = strdup(api_version);
+ if (pad_version == NULL) {
+ _LOGE("out of memory");
+ return RPM_INSTALLER_ERR_NOT_ENOUGH_MEMORY;
+ }
+
+ ptr_fw = strchr(pad_version, '.');
+ ptr_bw = strrchr(pad_version, '.');
+
+ if (ptr_fw && ptr_bw) {
+ if (ptr_fw == ptr_bw) {
+ pad_version = strncat(pad_version, ".0", BUF_SIZE - strlen(pad_version) - 1);
+ }
+ }
+
+ *pad_api_version = pad_version;
+
+ return RPM_INSTALLER_SUCCESS;
+}
+
+static int __coretpk_compare_with_platform_version(const char *api_version)
+{
+ char *current_version = NULL;
+ char *platform_version = NULL;
+ int ret = 0;
+ int result = 0;
+
+ if (!api_version) {
+ _LOGE("Invalid parameter");
+ return RPM_INSTALLER_ERR_WRONG_PARAM;
+ }
+
+ if (strlen(api_version) == 0) {
+ _LOGD("No api-version, assume same with platform api-version");
+ return RPM_INSTALLER_SUCCESS;
+ }
+
+ ret = __coretpk_patch_padded_api_version(api_version, ¤t_version);
+ if (ret != RPM_INSTALLER_SUCCESS) {
+ return RPM_INSTALLER_ERR_WRONG_PARAM;
+ }
+
+ ret = __coretpk_patch_padded_api_version(TIZEN_VERSION, &platform_version);
+ if (ret != RPM_INSTALLER_SUCCESS) {
+ return RPM_INSTALLER_ERR_WRONG_PARAM;
+ }
+
+ _LOGD("platform_version(%s) vs. current_version(%s)", platform_version, current_version);
+
+ result = strverscmp(platform_version, current_version);
+ if (result < 0) {
+ ret = RPM_INSTALLER_ERR_NOT_SUPPORTED_API_VERSION;
+ } else {
+ ret = RPM_INSTALLER_SUCCESS;
+ }
+
+ FREE_AND_NULL(current_version);
+ FREE_AND_NULL(platform_version);
+
+ return ret;
+}
+
static int __get_unzip_size(const char *item, unsigned long long *size)
{
if (!item || !size) {
return 0;
}
-int _coretpk_installer_verify_privilege_list(GList *privilege_list, int visibility, const char *api_version)
+int _coretpk_installer_verify_privilege_list(const char *pkg_id, GList *privilege_list, int visibility, const char *api_version)
{
char *error_privilege_name = NULL;
GList *list = NULL;
int ret = 0;
+ char buf[BUF_SIZE] = { '\0' };
ret = privilege_manager_verify_privilege(api_version, PRVMGR_PACKAGE_TYPE_CORE, privilege_list, visibility, &error_privilege_name);
if (ret != PRVMGR_ERR_NONE) {
_LOGE("privilege_manager_verify_privilege_list(PRVMGR_PACKAGE_TYPE_CORE) failed. ret = [%d][%s]", ret, error_privilege_name);
fprintf(stdout, "\n verify_privilege_list(PRVMGR_PACKAGE_TYPE_CORE) failed. [%d][%s]\n", ret, error_privilege_name);
- if (!error_privilege_name) {
- ret = RPM_INSTALLER_ERR_SIG_VERIFICATION_FAILED;
- goto err;
- }
+ if (!error_privilege_name)
+ error_privilege_name = strdup("Unidentified privilege error");
if (strstr(error_privilege_name, "[DEPRECATED_PRIVILEGE]") != NULL)
ret = RPM_INSTALLER_ERR_PRIVILEGE_USING_LEGACY_FAILED;
_LOGE("Unidentified privilege error : [%s]", error_privilege_name);
ret = RPM_INSTALLER_ERR_SIG_VERIFICATION_FAILED;
}
- } else {
+
+ snprintf(buf, BUF_SIZE - 1, "%d:%s", ret, error_privilege_name);
+ _ri_broadcast_privilege_notification(pkg_id, "coretpk", "error", buf);
+ } else
_LOGD("privilege_manager_verify_privilege_list(PRVMGR_PACKAGE_TYPE_CORE) is ok.");
- }
err:
_ri_broadcast_status_notification(pkgid, "coretpk", "start", "install");
_LOGD("[#]start : _coretpk_installer_package_install[%s]", pkgid);
+ /*get pkginfo*/
+ info = _coretpk_installer_get_pkgfile_info(pkgfile);
+ if (info == NULL || (strlen(info->package_name) == 0)) {
+ _LOGE("failed to get pkg info");
+ ret = RPM_INSTALLER_ERR_INTERNAL;
+ goto err;
+ }
+
+ /*compare package's api version with platform version*/
+ ret = __coretpk_compare_with_platform_version(info->api_version);
+ if (ret != RPM_INSTALLER_SUCCESS) {
+ if (ret == RPM_INSTALLER_ERR_NOT_SUPPORTED_API_VERSION) {
+ _LOGE("Unable to install. Platform version[%s] < Package version[%s]",
+ TIZEN_VERSION, info->api_version);
+ }
+ ret = RPM_INSTALLER_ERR_INTERNAL;
+ goto err;
+ }
+
/*send event for install_percent*/
_ri_broadcast_status_notification(pkgid, "coretpk", "install_percent", "30");
_LOGD("signature and certificate are verified successfully.");
}
- /*chdir*/
+ /*chdir*/
ret = chdir(cwd);
if (ret != 0) {
_LOGL("chdir()", errno);
goto err;
}
- info = _coretpk_installer_get_pkgfile_info(pkgfile);
- if (info == NULL || (strlen(info->package_name) == 0)) {
- _LOGE("failed to get pkg info");
- ret = RPM_INSTALLER_ERR_INTERNAL;
- goto err;
- }
-
if (strlen(info->api_version) != 0) {
ret = _ri_privilege_set_package_version(pkgid, info->api_version);
if (ret != 0)
// Check privilege and visibility
if (privilege_list) {
- ret = _coretpk_installer_verify_privilege_list(privilege_list, visibility, info->api_version);
+ ret = _coretpk_installer_verify_privilege_list(pkgid, privilege_list, visibility, info->api_version);
if (ret != 0) {
goto err;
} else {
}
char *errorstr = NULL;
- _ri_error_no_to_string(ret, &errorstr);
- _ri_broadcast_status_notification(pkgid, "coretpk", "error", errorstr);
+ if (ret < RPM_INSTALLER_ERR_PRIVILEGE_UNAUTHORIZED || ret > RPM_INSTALLER_ERR_PRIVILEGE_USING_LEGACY_FAILED) {
+ _ri_error_no_to_string(ret, &errorstr);
+ _ri_broadcast_status_notification(pkgid, "coretpk", "error", errorstr);
+ }
sleep(2);
_LOGE("_coretpk_installer_package_install is failed.");
/*send event for start*/
_ri_broadcast_status_notification(pkgid, "coretpk", "start", "update");
+ /*get pkginfo*/
+ info = _coretpk_installer_get_pkgfile_info(pkgfile);
+ if (info == NULL || strlen(info->package_name) == 0) {
+ _LOGE("failed to get pkg info");
+ ret = RPM_INSTALLER_ERR_INTERNAL;
+ goto err;
+ }
+
+ /*compare package's api version with platform version*/
+ ret = __coretpk_compare_with_platform_version(info->api_version);
+ if (ret != RPM_INSTALLER_SUCCESS) {
+ if (ret == RPM_INSTALLER_ERR_NOT_SUPPORTED_API_VERSION) {
+ _LOGE("Unable to install. Platform version[%s] < Package version[%s]",
+ TIZEN_VERSION, info->api_version);
+ }
+ ret = RPM_INSTALLER_ERR_INTERNAL;
+ goto err;
+ }
+
/*terminate running app*/
ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &pkghandle);
if (ret < 0) {
pkgmgrinfo_appinfo_get_list(pkghandle, PMINFO_UI_APP, __ri_check_running_app, NULL);
pkgmgrinfo_pkginfo_destroy_pkginfo(pkghandle);
- /*remove dir for clean*/
+ /*remove dir for clean*/
__ri_remove_updated_dir(pkgid);
/* pre_upgrade */
_LOGD("#signature and certificate verifying success");
}
- /*chdir*/
+ /*chdir*/
ret = chdir(cwd);
if (ret != 0) {
_LOGL("chdir()", errno);
}
_LOGD("#permission applying success.");
- info = _coretpk_installer_get_pkgfile_info(pkgfile);
- if (info == NULL || strlen(info->package_name) == 0) {
- _LOGE("failed to get pkg info");
- ret = RPM_INSTALLER_ERR_INTERNAL;
- goto err;
- }
-
// Check privilege and visibility
if (privilege_list) {
- ret = _coretpk_installer_verify_privilege_list(privilege_list, visibility, info->api_version);
+ ret = _coretpk_installer_verify_privilege_list(pkgid, privilege_list, visibility, info->api_version);
if (ret != 0) {
goto err;
} else {
_LOGD("signature and certificate verifying success");
}
- /*chdir*/
+ /*chdir*/
ret = chdir(cwd);
if (ret != 0) {
_LOGL("chdir()", errno);
goto err;
}
+ /*get pkginfo*/
+ info = _coretpk_installer_get_pkg_info(manifest);
+ if (info == NULL || strlen(info->package_name) == 0) {
+ _LOGE("failed to get pkg info");
+ ret = RPM_INSTALLER_ERR_INTERNAL;
+ goto err;
+ }
+
+ /*compare package's api version with platform version*/
+ ret = __coretpk_compare_with_platform_version(info->api_version);
+ if (ret != RPM_INSTALLER_SUCCESS) {
+ if (ret == RPM_INSTALLER_ERR_NOT_SUPPORTED_API_VERSION) {
+ _LOGE("Unable to install. Platform version[%s] < Package version[%s]",
+ TIZEN_VERSION, info->api_version);
+ }
+ ret = RPM_INSTALLER_ERR_INTERNAL;
+ goto err;
+ }
+
/*Parse the manifest to get install location and size. If failed, remove manifest info from DB.*/
ret = pkgmgr_parser_parse_manifest_for_upgrade(manifest, NULL);
if (ret < 0) {
}
_LOGD("#permission applying success.");
- info = _coretpk_installer_get_pkg_info(manifest);
- if (info == NULL || strlen(info->package_name) == 0) {
- _LOGE("failed to get pkg info");
- ret = RPM_INSTALLER_ERR_INTERNAL;
- goto err;
- }
-
// Check privilege and visibility
if (privilege_list) {
- ret = _coretpk_installer_verify_privilege_list(privilege_list, visibility, info->api_version);
+ ret = _coretpk_installer_verify_privilege_list(pkgid, privilege_list, visibility, info->api_version);
if (ret != 0) {
goto err;
} else {