int rcert = 0;
int exist = -1;
int i;
+ int is_global = 0;
*compare_result = PMINFO_CERT_COMPARE_ERROR;
ret = __open_cert_db(uid, "r");
}
rcert = exist;
- snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=(select author_signer_cert from package_cert_info where package=?) and for_all_users=(select for_all_users from package_cert_info where package=?)");
+ if (uid == GLOBAL_USER || uid == ROOT_UID) {
+ snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=(select author_signer_cert from package_cert_info where package=?)");
+ is_global = 1;
+ } else
+ snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=(select author_signer_cert from package_cert_info where package=?) and for_all_users=(select for_all_users from package_cert_info where package=?)");
if (SQLITE_OK != sqlite3_prepare_v2(GET_DB(cert_db), query, strlen(query), &stmt, NULL)) {
_LOGE("sqlite3_prepare_v2 error: %s", sqlite3_errmsg(GET_DB(cert_db)));
ret = PMINFO_R_ERROR;
goto err;
}
- for (i = 1; i <= 2; i++) {
+ for (i = 1; i <= 2 - is_global; i++) {
if (SQLITE_OK != sqlite3_bind_text(stmt, i, lhs_package_id, -1, SQLITE_STATIC)) {
_LOGE("sqlite3_bind_text error: %s", sqlite3_errmsg(GET_DB(cert_db)));
ret = PMINFO_R_ERROR;
sqlite3_reset(stmt);
sqlite3_clear_bindings(stmt);
- for (i = 1; i <= 2; i++) {
+ for (i = 1; i <= 2 - is_global; i++) {
if (SQLITE_OK != sqlite3_bind_text(stmt, i, rhs_package_id, -1, SQLITE_STATIC)) {
_LOGE("sqlite3_bind_text error: %s", sqlite3_errmsg(GET_DB(cert_db)));
ret = PMINFO_R_ERROR;
}
for (i = 0; i < MAX_CERT_TYPE; i++) {
memset(query, '\0', MAX_QUERY_LEN);
- snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=%d and for_all_users=%d", (certinfo->cert_id)[i], certinfo->for_all_users);
+ if (uid == GLOBAL_USER || uid == ROOT_UID)
+ snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=%d", (certinfo->cert_id)[i]);
+ else
+ snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=%d and for_all_users=%d", (certinfo->cert_id)[i], certinfo->for_all_users);
ret = __exec_certinfo_query(query, (void *)certinfo);
if (ret == -1) {
_LOGE("Cert Info DB Information retrieval failed\n");