4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Jayoun Lee <airjany@samsung.com>, Junsuk Oh <junsuk77.oh@samsung.com>,
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
27 #include "pkgmgrinfo_private.h"
28 #include "pkgmgrinfo_debug.h"
29 #include "pkgmgr-info.h"
30 #include "pkgmgrinfo_basic.h"
35 #define LOG_TAG "PKGMGR_CERT"
38 typedef struct _pkgmgr_instcertinfo_x {
40 char *cert_info[MAX_CERT_TYPE]; /*certificate data*/
41 int is_new[MAX_CERT_TYPE]; /*whether already exist in table or not*/
42 int ref_count[MAX_CERT_TYPE]; /*reference count of certificate data*/
43 int cert_id[MAX_CERT_TYPE]; /*certificate ID in index table*/
44 } pkgmgr_instcertinfo_x;
46 typedef struct _pkgmgr_certindexinfo_x {
49 } pkgmgr_certindexinfo_x;
51 typedef struct _pkgmgr_certinfo_x {
54 char *cert_info[MAX_CERT_TYPE]; /*certificate info*/
55 int cert_id[MAX_CERT_TYPE]; /*certificate ID in index table*/
58 __thread sqlite3 *cert_db = NULL;
60 static int __maxid_cb(void *data, int ncols, char **coltxt, char **colname)
68 static int __certinfo_cb(void *data, int ncols, char **coltxt, char **colname)
70 pkgmgr_certinfo_x *info = (pkgmgr_certinfo_x *)data;
72 for(i = 0; i < ncols; i++)
74 if (colname[i] == NULL)
77 if (strcmp(colname[i], "package") == 0) {
78 if (coltxt[i] && info->pkgid == NULL) {
79 info->pkgid = strdup(coltxt[i]);
86 } else if (strcmp(colname[i], "author_signer_cert") == 0) {
88 (info->cert_id)[PMINFO_AUTHOR_SIGNER_CERT] = atoi(coltxt[i]);
90 (info->cert_id)[PMINFO_AUTHOR_SIGNER_CERT] = 0;
91 } else if (strcmp(colname[i], "author_im_cert") == 0) {
93 (info->cert_id)[PMINFO_AUTHOR_INTERMEDIATE_CERT] = atoi(coltxt[i]);
95 (info->cert_id)[PMINFO_AUTHOR_INTERMEDIATE_CERT] = 0;
96 } else if (strcmp(colname[i], "author_root_cert") == 0) {
98 (info->cert_id)[PMINFO_AUTHOR_ROOT_CERT] = atoi(coltxt[i]);
100 (info->cert_id)[PMINFO_AUTHOR_ROOT_CERT] = 0;
101 } else if (strcmp(colname[i], "dist_signer_cert") == 0 ){
103 (info->cert_id)[PMINFO_DISTRIBUTOR_SIGNER_CERT] = atoi(coltxt[i]);
105 (info->cert_id)[PMINFO_DISTRIBUTOR_SIGNER_CERT] = 0;
106 } else if (strcmp(colname[i], "dist_im_cert") == 0 ){
108 (info->cert_id)[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT] = atoi(coltxt[i]);
110 (info->cert_id)[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT] = 0;
111 } else if (strcmp(colname[i], "dist_root_cert") == 0 ){
113 (info->cert_id)[PMINFO_DISTRIBUTOR_ROOT_CERT] = atoi(coltxt[i]);
115 (info->cert_id)[PMINFO_DISTRIBUTOR_ROOT_CERT] = 0;
116 } else if (strcmp(colname[i], "dist2_signer_cert") == 0 ){
118 (info->cert_id)[PMINFO_DISTRIBUTOR2_SIGNER_CERT] = atoi(coltxt[i]);
120 (info->cert_id)[PMINFO_DISTRIBUTOR2_SIGNER_CERT] = 0;
121 } else if (strcmp(colname[i], "dist2_im_cert") == 0 ){
123 (info->cert_id)[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT] = atoi(coltxt[i]);
125 (info->cert_id)[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT] = 0;
126 } else if (strcmp(colname[i], "dist2_root_cert") == 0 ){
128 (info->cert_id)[PMINFO_DISTRIBUTOR2_ROOT_CERT] = atoi(coltxt[i]);
130 (info->cert_id)[PMINFO_DISTRIBUTOR2_ROOT_CERT] = 0;
131 } else if (strcmp(colname[i], "cert_info") == 0 ){
132 if (coltxt[i] && info->cert_value == NULL) {
133 info->cert_value = strdup(coltxt[i]);
135 if (info->cert_value)
136 free(info->cert_value);
138 info->cert_value = NULL;
146 static int __certindexinfo_cb(void *data, int ncols, char **coltxt, char **colname)
148 pkgmgr_certindexinfo_x *info = (pkgmgr_certindexinfo_x *)data;
150 for(i = 0; i < ncols; i++) {
151 if (strcmp(colname[i], "cert_id") == 0) {
153 info->cert_id = atoi(coltxt[i]);
156 } else if (strcmp(colname[i], "cert_ref_count") == 0) {
158 info->cert_ref_count = atoi(coltxt[i]);
160 info->cert_ref_count = 0;
167 static int __exec_certinfo_query(char *query, void *data)
169 char *error_message = NULL;
171 sqlite3_exec(cert_db, query, __certinfo_cb, data, &error_message)) {
172 _LOGE("Don't execute query = %s error message = %s\n", query,
174 sqlite3_free(error_message);
177 sqlite3_free(error_message);
181 static int __exec_certindexinfo_query(char *query, void *data)
183 char *error_message = NULL;
185 sqlite3_exec(cert_db, query, __certindexinfo_cb, data, &error_message)) {
186 _LOGE("Don't execute query = %s error message = %s\n", query,
188 sqlite3_free(error_message);
191 sqlite3_free(error_message);
195 static int __delete_certinfo(const char *pkgid)
201 int unique_id[MAX_CERT_TYPE] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
202 char *error_message = NULL;
203 char query[MAX_QUERY_LEN] = {'\0'};
204 pkgmgr_certinfo_x *certinfo = NULL;
205 pkgmgr_certindexinfo_x *indexinfo = NULL;
206 certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
207 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
208 indexinfo = calloc(1, sizeof(pkgmgr_certindexinfo_x));
209 if (indexinfo == NULL) {
210 _LOGE("Out of Memory!!!");
211 ret = PMINFO_R_ERROR;
214 /*populate certinfo from DB*/
215 char *sel_query = sqlite3_mprintf("select * from package_cert_info where package=%Q ", pkgid);
216 ret = __exec_certinfo_query(sel_query, (void *)certinfo);
217 sqlite3_free(sel_query);
219 _LOGE("Package Cert Info DB Information retrieval failed\n");
220 ret = PMINFO_R_ERROR;
223 /*Update cert index table*/
224 for (i = 0; i < MAX_CERT_TYPE; i++) {
225 if ((certinfo->cert_id)[i]) {
226 for (j = 0; j < MAX_CERT_TYPE; j++) {
227 if ((certinfo->cert_id)[i] == unique_id[j]) {
228 /*Ref count has already been updated. Just continue*/
232 if (j == MAX_CERT_TYPE)
233 unique_id[c++] = (certinfo->cert_id)[i];
236 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
237 ret = __exec_certindexinfo_query(query, (void *)indexinfo);
239 _LOGE("Cert Info DB Information retrieval failed\n");
240 ret = PMINFO_R_ERROR;
243 memset(query, '\0', MAX_QUERY_LEN);
244 if (indexinfo->cert_ref_count > 1) {
245 /*decrease ref count*/
246 snprintf(query, MAX_QUERY_LEN, "update package_cert_index_info set cert_ref_count=%d where cert_id=%d ",
247 indexinfo->cert_ref_count - 1, (certinfo->cert_id)[i]);
249 /*delete this certificate as ref count is 1 and it will become 0*/
250 snprintf(query, MAX_QUERY_LEN, "delete from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
253 sqlite3_exec(cert_db, query, NULL, NULL, &error_message)) {
254 _LOGE("Don't execute query = %s error message = %s\n", query,
256 sqlite3_free(error_message);
257 ret = PMINFO_R_ERROR;
262 /*Now delete the entry from db*/
263 char *del_query = sqlite3_mprintf("delete from package_cert_info where package=%Q", pkgid);
265 sqlite3_exec(cert_db, del_query, NULL, NULL, &error_message)) {
266 _LOGE("Don't execute query = %s error message = %s\n", del_query,
268 sqlite3_free(error_message);
269 sqlite3_free(del_query);
270 ret = PMINFO_R_ERROR;
273 sqlite3_free(del_query);
276 FREE_AND_NULL(indexinfo);
277 FREE_AND_NULL(certinfo->pkgid);
278 for (i = 0; i < MAX_CERT_TYPE; i++) {
279 FREE_AND_NULL((certinfo->cert_info)[i]);
281 FREE_AND_NULL(certinfo);
285 API int pkgmgrinfo_pkginfo_create_certinfo(pkgmgrinfo_certinfo_h *handle)
287 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
288 pkgmgr_certinfo_x *certinfo = NULL;
289 certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
290 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
291 *handle = (void *)certinfo;
295 API int pkgmgrinfo_pkginfo_load_certinfo(const char *pkgid, pkgmgrinfo_certinfo_h handle)
297 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
298 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
299 pkgmgr_certinfo_x *certinfo = NULL;
300 int ret = PMINFO_R_OK;
301 char query[MAX_QUERY_LEN] = {'\0'};
305 ret = db_util_open_with_options(CERT_DB, &cert_db, SQLITE_OPEN_READONLY, NULL);
306 if (ret != SQLITE_OK) {
307 _LOGE("connect db [%s] failed!\n", CERT_DB);
308 return PMINFO_R_ERROR;
311 certinfo = (pkgmgr_certinfo_x *)handle;
312 /*populate certinfo from DB*/
313 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_info where package='%s' ", pkgid);
314 ret = __exec_certinfo_query(query, (void *)certinfo);
316 _LOGE("Package Cert Info DB Information retrieval failed\n");
317 ret = PMINFO_R_ERROR;
321 if (certinfo->pkgid == NULL) {
322 _LOGE("Package not found in DB\n");
323 ret = PMINFO_R_ERROR;
327 for (i = 0; i < MAX_CERT_TYPE; i++) {
328 memset(query, '\0', MAX_QUERY_LEN);
329 snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
330 ret = __exec_certinfo_query(query, (void *)certinfo);
332 _LOGE("Cert Info DB Information retrieval failed\n");
333 ret = PMINFO_R_ERROR;
336 if (certinfo->cert_value) {
337 (certinfo->cert_info)[i] = strdup(certinfo->cert_value);
338 FREE_AND_NULL(certinfo->cert_value);
342 sqlite3_close(cert_db);
346 API int pkgmgrinfo_pkginfo_get_cert_value(pkgmgrinfo_certinfo_h handle, pkgmgrinfo_cert_type cert_type, const char **cert_value)
348 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
349 retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
350 retvm_if(cert_type < PMINFO_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
351 retvm_if(cert_type > PMINFO_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
352 pkgmgr_certinfo_x *certinfo = NULL;
353 certinfo = (pkgmgr_certinfo_x *)handle;
354 if ((certinfo->cert_info)[cert_type])
355 *cert_value = (certinfo->cert_info)[cert_type];
361 API int pkgmgrinfo_pkginfo_destroy_certinfo(pkgmgrinfo_certinfo_h handle)
363 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
365 pkgmgr_certinfo_x *certinfo = NULL;
366 certinfo = (pkgmgr_certinfo_x *)handle;
367 FREE_AND_NULL(certinfo->pkgid);
368 for (i = 0; i < MAX_CERT_TYPE; i++) {
369 FREE_AND_NULL((certinfo->cert_info)[i]);
371 FREE_AND_NULL(certinfo);
375 API int pkgmgrinfo_create_certinfo_set_handle(pkgmgrinfo_instcertinfo_h *handle)
377 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
378 pkgmgr_instcertinfo_x *certinfo = NULL;
379 certinfo = calloc(1, sizeof(pkgmgr_instcertinfo_x));
380 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
381 *handle = (void *)certinfo;
385 API int pkgmgrinfo_set_cert_value(pkgmgrinfo_instcertinfo_h handle, pkgmgrinfo_instcert_type cert_type, char *cert_value)
387 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
388 retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
389 retvm_if(cert_type < PMINFO_SET_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
390 retvm_if(cert_type > PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
391 pkgmgr_instcertinfo_x *certinfo = NULL;
392 certinfo = (pkgmgr_instcertinfo_x *)handle;
393 (certinfo->cert_info)[cert_type] = strdup(cert_value);
397 API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h handle)
399 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
400 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
401 char *error_message = NULL;
402 char query[MAX_QUERY_LEN] = {'\0'};
408 int unique_id[MAX_CERT_TYPE] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
415 pkgmgr_instcertinfo_x *info = (pkgmgr_instcertinfo_x *)handle;
416 pkgmgr_certindexinfo_x *indexinfo = NULL;
417 indexinfo = calloc(1, sizeof(pkgmgr_certindexinfo_x));
418 if (indexinfo == NULL) {
419 _LOGE("Out of Memory!!!");
420 return PMINFO_R_ERROR;
422 info->pkgid = strdup(pkgid);
425 ret = db_util_open_with_options(CERT_DB, &cert_db, SQLITE_OPEN_READWRITE, NULL);
426 if (ret != SQLITE_OK) {
427 _LOGE("connect db [%s] failed!\n", CERT_DB);
428 ret = PMINFO_R_ERROR;
431 /*Begin Transaction*/
432 ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
433 if (ret != SQLITE_OK) {
434 _LOGE("Failed to begin transaction\n");
435 ret = PMINFO_R_ERROR;
438 _LOGE("Transaction Begin\n");
439 /*Check if request is to insert/update*/
440 char *cert_query = sqlite3_mprintf("select exists(select * from package_cert_info where package=%Q)", pkgid);
442 sqlite3_exec(cert_db, cert_query, _pkgmgrinfo_validate_cb, (void *)&exist, &error_message)) {
443 _LOGE("Don't execute query = %s error message = %s\n", cert_query,
445 sqlite3_free(cert_query);
446 sqlite3_free(error_message);
447 ret = PMINFO_R_ERROR;
450 sqlite3_free(cert_query);
454 We cant just issue update query directly. We need to manage index table also.
455 Hence it is better to delete and insert again in case of update*/
456 ret = __delete_certinfo(pkgid);
458 _LOGE("Certificate Deletion Failed\n");
460 for (i = 0; i < MAX_CERT_TYPE; i++) {
461 if ((info->cert_info)[i]) {
462 for (j = 0; j < i; j++) {
463 if ( (info->cert_info)[j]) {
464 if (strcmp((info->cert_info)[i], (info->cert_info)[j]) == 0) {
465 (info->cert_id)[i] = (info->cert_id)[j];
466 (info->is_new)[i] = 0;
467 (info->ref_count)[i] = (info->ref_count)[j];
474 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_index_info " \
475 "where cert_info='%s'",(info->cert_info)[i]);
476 ret = __exec_certindexinfo_query(query, (void *)indexinfo);
478 _LOGE("Cert Info DB Information retrieval failed\n");
479 ret = PMINFO_R_ERROR;
482 if (indexinfo->cert_id == 0) {
483 /*New certificate. Get newid*/
484 memset(query, '\0', MAX_QUERY_LEN);
485 snprintf(query, MAX_QUERY_LEN, "select MAX(cert_id) from package_cert_index_info ");
487 sqlite3_exec(cert_db, query, __maxid_cb, (void *)&newid, &error_message)) {
488 _LOGE("Don't execute query = %s error message = %s\n", query,
490 sqlite3_free(error_message);
491 ret = PMINFO_R_ERROR;
499 indexinfo->cert_id = maxid;
500 indexinfo->cert_ref_count = 1;
504 (info->cert_id)[i] = indexinfo->cert_id;
505 (info->is_new)[i] = is_new;
506 (info->ref_count)[i] = indexinfo->cert_ref_count;
507 _LOGE("Id:Count = %d %d\n", indexinfo->cert_id, indexinfo->cert_ref_count);
508 indexinfo->cert_id = 0;
509 indexinfo->cert_ref_count = 0;
514 for (i = 0; i < MAX_CERT_TYPE; i++) {
515 if ((info->cert_info)[i])
516 len+= strlen((info->cert_info)[i]);
518 vquery = (char *)calloc(1, len);
519 if (vquery == NULL) {
520 _LOGE("out of memory");
521 ret = PMINFO_R_ERROR;
525 snprintf(vquery, len,
526 "insert into package_cert_info(package, author_root_cert, author_im_cert, author_signer_cert, dist_root_cert, " \
527 "dist_im_cert, dist_signer_cert, dist2_root_cert, dist2_im_cert, dist2_signer_cert) " \
528 "values('%s', %d, %d, %d, %d, %d, %d, %d, %d, %d)",\
529 info->pkgid,(info->cert_id)[PMINFO_SET_AUTHOR_ROOT_CERT],(info->cert_id)[PMINFO_SET_AUTHOR_INTERMEDIATE_CERT],
530 (info->cert_id)[PMINFO_SET_AUTHOR_SIGNER_CERT], (info->cert_id)[PMINFO_SET_DISTRIBUTOR_ROOT_CERT],
531 (info->cert_id)[PMINFO_SET_DISTRIBUTOR_INTERMEDIATE_CERT], (info->cert_id)[PMINFO_SET_DISTRIBUTOR_SIGNER_CERT],
532 (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_ROOT_CERT],(info->cert_id)[PMINFO_SET_DISTRIBUTOR2_INTERMEDIATE_CERT],
533 (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT]);
535 sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
536 _LOGE("Don't execute query = %s error message = %s\n", vquery,
538 sqlite3_free(error_message);
539 ret = PMINFO_R_ERROR;
542 /*Update index table info*/
543 /*If cert_id exists and is repeated for current package, ref count should only be increased once*/
544 for (i = 0; i < MAX_CERT_TYPE; i++) {
545 if ((info->cert_info)[i]) {
546 memset(vquery, '\0', len);
547 if ((info->is_new)[i]) {
548 snprintf(vquery, len, "insert into package_cert_index_info(cert_info, cert_id, cert_ref_count) " \
549 "values('%s', '%d', '%d') ", (info->cert_info)[i], (info->cert_id)[i], 1);
550 unique_id[c++] = (info->cert_id)[i];
553 for (j = 0; j < MAX_CERT_TYPE; j++) {
554 if ((info->cert_id)[i] == unique_id[j]) {
555 /*Ref count has already been increased. Just continue*/
559 if (j == MAX_CERT_TYPE)
560 unique_id[c++] = (info->cert_id)[i];
563 snprintf(vquery, len, "update package_cert_index_info set cert_ref_count=%d " \
564 "where cert_id=%d", (info->ref_count)[i] + 1, (info->cert_id)[i]);
567 sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
568 _LOGE("Don't execute query = %s error message = %s\n", vquery,
570 sqlite3_free(error_message);
571 ret = PMINFO_R_ERROR;
576 /*Commit transaction*/
577 ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
578 if (ret != SQLITE_OK) {
579 _LOGE("Failed to commit transaction, Rollback now\n");
580 ret = sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
581 if (ret != SQLITE_OK)
582 _LOGE("Failed to commit transaction, Rollback now\n");
584 ret = PMINFO_R_ERROR;
587 _LOGE("Transaction Commit and End\n");
590 sqlite3_close(cert_db);
591 FREE_AND_NULL(vquery);
592 FREE_AND_NULL(indexinfo);
596 API int pkgmgrinfo_destroy_certinfo_set_handle(pkgmgrinfo_instcertinfo_h handle)
598 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
600 pkgmgr_instcertinfo_x *certinfo = NULL;
601 certinfo = (pkgmgr_instcertinfo_x *)handle;
602 FREE_AND_NULL(certinfo->pkgid);
603 for (i = 0; i < MAX_CERT_TYPE; i++) {
604 FREE_AND_NULL((certinfo->cert_info)[i]);
606 FREE_AND_NULL(certinfo);
610 API int pkgmgrinfo_delete_certinfo(const char *pkgid)
612 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
615 ret = db_util_open_with_options(CERT_DB, &cert_db, SQLITE_OPEN_READWRITE, NULL);
616 if (ret != SQLITE_OK) {
617 _LOGE("connect db [%s] failed!\n", CERT_DB);
618 ret = PMINFO_R_ERROR;
621 /*Begin Transaction*/
622 ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
623 if (ret != SQLITE_OK) {
624 _LOGE("Failed to begin transaction\n");
625 ret = PMINFO_R_ERROR;
628 _LOGE("Transaction Begin\n");
629 ret = __delete_certinfo(pkgid);
631 _LOGE("Certificate Deletion Failed\n");
633 _LOGE("Certificate Deletion Success\n");
635 /*Commit transaction*/
636 ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
637 if (ret != SQLITE_OK) {
638 _LOGE("Failed to commit transaction, Rollback now\n");
639 ret = sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
640 if (ret != SQLITE_OK)
641 _LOGE("Failed to commit transaction, Rollback now\n");
643 ret = PMINFO_R_ERROR;
646 _LOGE("Transaction Commit and End\n");
649 sqlite3_close(cert_db);