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 "pkgmgr-info-internal.h"
28 #include "pkgmgr-info-debug.h"
29 #include "pkgmgr-info.h"
34 #define LOG_TAG "PKGMGR_CERT"
37 typedef struct _pkgmgr_instcertinfo_x {
39 char *cert_info[MAX_CERT_TYPE]; /*certificate data*/
40 int is_new[MAX_CERT_TYPE]; /*whether already exist in table or not*/
41 int ref_count[MAX_CERT_TYPE]; /*reference count of certificate data*/
42 int cert_id[MAX_CERT_TYPE]; /*certificate ID in index table*/
43 } pkgmgr_instcertinfo_x;
45 typedef struct _pkgmgr_certindexinfo_x {
48 } pkgmgr_certindexinfo_x;
50 typedef struct _pkgmgr_certinfo_x {
53 char *cert_info[MAX_CERT_TYPE]; /*certificate info*/
54 int cert_id[MAX_CERT_TYPE]; /*certificate ID in index table*/
57 __thread sqlite3 *cert_db = NULL;
59 static int __maxid_cb(void *data, int ncols, char **coltxt, char **colname)
67 static int __certinfo_cb(void *data, int ncols, char **coltxt, char **colname)
69 pkgmgr_certinfo_x *info = (pkgmgr_certinfo_x *)data;
71 for(i = 0; i < ncols; i++)
73 if (strcmp(colname[i], "package") == 0) {
75 info->pkgid = strdup(coltxt[i]);
78 } else if (strcmp(colname[i], "author_signer_cert") == 0) {
80 (info->cert_id)[PMINFO_AUTHOR_SIGNER_CERT] = atoi(coltxt[i]);
82 (info->cert_id)[PMINFO_AUTHOR_SIGNER_CERT] = 0;
83 } else if (strcmp(colname[i], "author_im_cert") == 0) {
85 (info->cert_id)[PMINFO_AUTHOR_INTERMEDIATE_CERT] = atoi(coltxt[i]);
87 (info->cert_id)[PMINFO_AUTHOR_INTERMEDIATE_CERT] = 0;
88 } else if (strcmp(colname[i], "author_root_cert") == 0) {
90 (info->cert_id)[PMINFO_AUTHOR_ROOT_CERT] = atoi(coltxt[i]);
92 (info->cert_id)[PMINFO_AUTHOR_ROOT_CERT] = 0;
93 } else if (strcmp(colname[i], "dist_signer_cert") == 0 ){
95 (info->cert_id)[PMINFO_DISTRIBUTOR_SIGNER_CERT] = atoi(coltxt[i]);
97 (info->cert_id)[PMINFO_DISTRIBUTOR_SIGNER_CERT] = 0;
98 } else if (strcmp(colname[i], "dist_im_cert") == 0 ){
100 (info->cert_id)[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT] = atoi(coltxt[i]);
102 (info->cert_id)[PMINFO_DISTRIBUTOR_INTERMEDIATE_CERT] = 0;
103 } else if (strcmp(colname[i], "dist_root_cert") == 0 ){
105 (info->cert_id)[PMINFO_DISTRIBUTOR_ROOT_CERT] = atoi(coltxt[i]);
107 (info->cert_id)[PMINFO_DISTRIBUTOR_ROOT_CERT] = 0;
108 } else if (strcmp(colname[i], "dist2_signer_cert") == 0 ){
110 (info->cert_id)[PMINFO_DISTRIBUTOR2_SIGNER_CERT] = atoi(coltxt[i]);
112 (info->cert_id)[PMINFO_DISTRIBUTOR2_SIGNER_CERT] = 0;
113 } else if (strcmp(colname[i], "dist2_im_cert") == 0 ){
115 (info->cert_id)[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT] = atoi(coltxt[i]);
117 (info->cert_id)[PMINFO_DISTRIBUTOR2_INTERMEDIATE_CERT] = 0;
118 } else if (strcmp(colname[i], "dist2_root_cert") == 0 ){
120 (info->cert_id)[PMINFO_DISTRIBUTOR2_ROOT_CERT] = atoi(coltxt[i]);
122 (info->cert_id)[PMINFO_DISTRIBUTOR2_ROOT_CERT] = 0;
123 } else if (strcmp(colname[i], "cert_info") == 0 ){
125 info->cert_value = strdup(coltxt[i]);
127 info->cert_value = NULL;
134 static int __certindexinfo_cb(void *data, int ncols, char **coltxt, char **colname)
136 pkgmgr_certindexinfo_x *info = (pkgmgr_certindexinfo_x *)data;
138 for(i = 0; i < ncols; i++) {
139 if (strcmp(colname[i], "cert_id") == 0) {
141 info->cert_id = atoi(coltxt[i]);
144 } else if (strcmp(colname[i], "cert_ref_count") == 0) {
146 info->cert_ref_count = atoi(coltxt[i]);
148 info->cert_ref_count = 0;
155 static int __exec_certinfo_query(char *query, void *data)
157 char *error_message = NULL;
159 sqlite3_exec(cert_db, query, __certinfo_cb, data, &error_message)) {
160 _LOGE("Don't execute query = %s error message = %s\n", query,
162 sqlite3_free(error_message);
165 sqlite3_free(error_message);
169 static int __exec_certindexinfo_query(char *query, void *data)
171 char *error_message = NULL;
173 sqlite3_exec(cert_db, query, __certindexinfo_cb, data, &error_message)) {
174 _LOGE("Don't execute query = %s error message = %s\n", query,
176 sqlite3_free(error_message);
179 sqlite3_free(error_message);
183 static int __delete_certinfo(const char *pkgid)
189 int unique_id[MAX_CERT_TYPE] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
190 char *error_message = NULL;
191 char query[MAX_QUERY_LEN] = {'\0'};
192 pkgmgr_certinfo_x *certinfo = NULL;
193 pkgmgr_certindexinfo_x *indexinfo = NULL;
194 certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
195 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
196 indexinfo = calloc(1, sizeof(pkgmgr_certindexinfo_x));
197 if (indexinfo == NULL) {
198 _LOGE("Out of Memory!!!");
199 ret = PMINFO_R_ERROR;
202 /*populate certinfo from DB*/
203 char *sel_query = sqlite3_mprintf("select * from package_cert_info where package=%Q ", pkgid);
204 ret = __exec_certinfo_query(sel_query, (void *)certinfo);
205 sqlite3_free(sel_query);
207 _LOGE("Package Cert Info DB Information retrieval failed\n");
208 ret = PMINFO_R_ERROR;
211 /*Update cert index table*/
212 for (i = 0; i < MAX_CERT_TYPE; i++) {
213 if ((certinfo->cert_id)[i]) {
214 for (j = 0; j < MAX_CERT_TYPE; j++) {
215 if ((certinfo->cert_id)[i] == unique_id[j]) {
216 /*Ref count has already been updated. Just continue*/
220 if (j == MAX_CERT_TYPE)
221 unique_id[c++] = (certinfo->cert_id)[i];
224 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
225 ret = __exec_certindexinfo_query(query, (void *)indexinfo);
227 _LOGE("Cert Info DB Information retrieval failed\n");
228 ret = PMINFO_R_ERROR;
231 memset(query, '\0', MAX_QUERY_LEN);
232 if (indexinfo->cert_ref_count > 1) {
233 /*decrease ref count*/
234 snprintf(query, MAX_QUERY_LEN, "update package_cert_index_info set cert_ref_count=%d where cert_id=%d ",
235 indexinfo->cert_ref_count - 1, (certinfo->cert_id)[i]);
237 /*delete this certificate as ref count is 1 and it will become 0*/
238 snprintf(query, MAX_QUERY_LEN, "delete from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
241 sqlite3_exec(cert_db, query, NULL, NULL, &error_message)) {
242 _LOGE("Don't execute query = %s error message = %s\n", query,
244 sqlite3_free(error_message);
245 ret = PMINFO_R_ERROR;
250 /*Now delete the entry from db*/
251 char *del_query = sqlite3_mprintf("delete from package_cert_info where package=%Q", pkgid);
253 sqlite3_exec(cert_db, del_query, NULL, NULL, &error_message)) {
254 _LOGE("Don't execute query = %s error message = %s\n", del_query,
256 sqlite3_free(error_message);
257 sqlite3_free(del_query);
258 ret = PMINFO_R_ERROR;
261 sqlite3_free(del_query);
268 if (certinfo->pkgid) {
269 free(certinfo->pkgid);
270 certinfo->pkgid = NULL;
272 for (i = 0; i < MAX_CERT_TYPE; i++) {
273 if ((certinfo->cert_info)[i]) {
274 free((certinfo->cert_info)[i]);
275 (certinfo->cert_info)[i] = NULL;
283 API int pkgmgrinfo_pkginfo_create_certinfo(pkgmgrinfo_certinfo_h *handle)
285 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
286 pkgmgr_certinfo_x *certinfo = NULL;
287 certinfo = calloc(1, sizeof(pkgmgr_certinfo_x));
288 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
289 *handle = (void *)certinfo;
293 API int pkgmgrinfo_pkginfo_load_certinfo(const char *pkgid, pkgmgrinfo_certinfo_h handle)
295 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
296 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
297 pkgmgr_certinfo_x *certinfo = NULL;
298 int ret = PMINFO_R_OK;
299 char query[MAX_QUERY_LEN] = {'\0'};
303 ret = db_util_open_with_options(CERT_DB, &cert_db, SQLITE_OPEN_READONLY, NULL);
304 if (ret != SQLITE_OK) {
305 _LOGE("connect db [%s] failed!\n", CERT_DB);
306 return PMINFO_R_ERROR;
309 certinfo = (pkgmgr_certinfo_x *)handle;
310 /*populate certinfo from DB*/
311 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_info where package='%s' ", pkgid);
312 ret = __exec_certinfo_query(query, (void *)certinfo);
314 _LOGE("Package Cert Info DB Information retrieval failed\n");
315 ret = PMINFO_R_ERROR;
319 if (certinfo->pkgid == NULL) {
320 _LOGE("Package not found in DB\n");
321 ret = PMINFO_R_ERROR;
325 for (i = 0; i < MAX_CERT_TYPE; i++) {
326 memset(query, '\0', MAX_QUERY_LEN);
327 snprintf(query, MAX_QUERY_LEN, "select cert_info from package_cert_index_info where cert_id=%d ", (certinfo->cert_id)[i]);
328 ret = __exec_certinfo_query(query, (void *)certinfo);
330 _LOGE("Cert Info DB Information retrieval failed\n");
331 ret = PMINFO_R_ERROR;
334 if (certinfo->cert_value) {
335 (certinfo->cert_info)[i] = strdup(certinfo->cert_value);
336 free(certinfo->cert_value);
337 certinfo->cert_value = NULL;
341 sqlite3_close(cert_db);
345 API int pkgmgrinfo_pkginfo_get_cert_value(pkgmgrinfo_certinfo_h handle, pkgmgrinfo_cert_type cert_type, const char **cert_value)
347 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
348 retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
349 retvm_if(cert_type < PMINFO_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
350 retvm_if(cert_type > PMINFO_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
351 pkgmgr_certinfo_x *certinfo = NULL;
352 certinfo = (pkgmgr_certinfo_x *)handle;
353 if ((certinfo->cert_info)[cert_type])
354 *cert_value = (certinfo->cert_info)[cert_type];
360 API int pkgmgrinfo_pkginfo_destroy_certinfo(pkgmgrinfo_certinfo_h handle)
362 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
364 pkgmgr_certinfo_x *certinfo = NULL;
365 certinfo = (pkgmgr_certinfo_x *)handle;
366 if (certinfo->pkgid) {
367 free(certinfo->pkgid);
368 certinfo->pkgid = NULL;
370 for (i = 0; i < MAX_CERT_TYPE; i++) {
371 if ((certinfo->cert_info)[i]) {
372 free((certinfo->cert_info)[i]);
373 (certinfo->cert_info)[i] = NULL;
381 API int pkgmgrinfo_create_certinfo_set_handle(pkgmgrinfo_instcertinfo_h *handle)
383 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied to hold return value is NULL\n");
384 pkgmgr_instcertinfo_x *certinfo = NULL;
385 certinfo = calloc(1, sizeof(pkgmgr_instcertinfo_x));
386 retvm_if(certinfo == NULL, PMINFO_R_ERROR, "Malloc Failed\n");
387 *handle = (void *)certinfo;
391 API int pkgmgrinfo_set_cert_value(pkgmgrinfo_instcertinfo_h handle, pkgmgrinfo_instcert_type cert_type, char *cert_value)
393 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
394 retvm_if(cert_value == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
395 retvm_if(cert_type < PMINFO_SET_AUTHOR_ROOT_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
396 retvm_if(cert_type > PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT, PMINFO_R_EINVAL, "Invalid certificate type\n");
397 pkgmgr_instcertinfo_x *certinfo = NULL;
398 certinfo = (pkgmgr_instcertinfo_x *)handle;
399 (certinfo->cert_info)[cert_type] = strdup(cert_value);
403 API int pkgmgrinfo_save_certinfo(const char *pkgid, pkgmgrinfo_instcertinfo_h handle)
405 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "package ID is NULL\n");
406 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Certinfo handle is NULL\n");
407 char *error_message = NULL;
408 char query[MAX_QUERY_LEN] = {'\0'};
414 int unique_id[MAX_CERT_TYPE] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
421 pkgmgr_instcertinfo_x *info = (pkgmgr_instcertinfo_x *)handle;
422 pkgmgr_certindexinfo_x *indexinfo = NULL;
423 indexinfo = calloc(1, sizeof(pkgmgr_certindexinfo_x));
424 if (indexinfo == NULL) {
425 _LOGE("Out of Memory!!!");
426 return PMINFO_R_ERROR;
428 info->pkgid = strdup(pkgid);
431 ret = db_util_open_with_options(CERT_DB, &cert_db, SQLITE_OPEN_READWRITE, NULL);
432 if (ret != SQLITE_OK) {
433 _LOGE("connect db [%s] failed!\n", CERT_DB);
434 ret = PMINFO_R_ERROR;
437 /*Begin Transaction*/
438 ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
439 if (ret != SQLITE_OK) {
440 _LOGE("Failed to begin transaction\n");
441 ret = PMINFO_R_ERROR;
444 _LOGE("Transaction Begin\n");
445 /*Check if request is to insert/update*/
446 char *cert_query = sqlite3_mprintf("select exists(select * from package_cert_info where package=%Q)", pkgid);
448 sqlite3_exec(cert_db, cert_query, _pkgmgrinfo_validate_cb, (void *)&exist, &error_message)) {
449 _LOGE("Don't execute query = %s error message = %s\n", cert_query,
451 sqlite3_free(cert_query);
452 sqlite3_free(error_message);
453 ret = PMINFO_R_ERROR;
456 sqlite3_free(cert_query);
460 We cant just issue update query directly. We need to manage index table also.
461 Hence it is better to delete and insert again in case of update*/
462 ret = __delete_certinfo(pkgid);
464 _LOGE("Certificate Deletion Failed\n");
466 for (i = 0; i < MAX_CERT_TYPE; i++) {
467 if ((info->cert_info)[i]) {
468 for (j = 0; j < i; j++) {
469 if ( (info->cert_info)[j]) {
470 if (strcmp((info->cert_info)[i], (info->cert_info)[j]) == 0) {
471 (info->cert_id)[i] = (info->cert_id)[j];
472 (info->is_new)[i] = 0;
473 (info->ref_count)[i] = (info->ref_count)[j];
480 snprintf(query, MAX_QUERY_LEN, "select * from package_cert_index_info " \
481 "where cert_info='%s'",(info->cert_info)[i]);
482 ret = __exec_certindexinfo_query(query, (void *)indexinfo);
484 _LOGE("Cert Info DB Information retrieval failed\n");
485 ret = PMINFO_R_ERROR;
488 if (indexinfo->cert_id == 0) {
489 /*New certificate. Get newid*/
490 memset(query, '\0', MAX_QUERY_LEN);
491 snprintf(query, MAX_QUERY_LEN, "select MAX(cert_id) from package_cert_index_info ");
493 sqlite3_exec(cert_db, query, __maxid_cb, (void *)&newid, &error_message)) {
494 _LOGE("Don't execute query = %s error message = %s\n", query,
496 sqlite3_free(error_message);
497 ret = PMINFO_R_ERROR;
505 indexinfo->cert_id = maxid;
506 indexinfo->cert_ref_count = 1;
510 (info->cert_id)[i] = indexinfo->cert_id;
511 (info->is_new)[i] = is_new;
512 (info->ref_count)[i] = indexinfo->cert_ref_count;
513 _LOGE("Id:Count = %d %d\n", indexinfo->cert_id, indexinfo->cert_ref_count);
514 indexinfo->cert_id = 0;
515 indexinfo->cert_ref_count = 0;
520 for (i = 0; i < MAX_CERT_TYPE; i++) {
521 if ((info->cert_info)[i])
522 len+= strlen((info->cert_info)[i]);
524 vquery = (char *)calloc(1, len);
526 snprintf(vquery, len,
527 "insert into package_cert_info(package, author_root_cert, author_im_cert, author_signer_cert, dist_root_cert, " \
528 "dist_im_cert, dist_signer_cert, dist2_root_cert, dist2_im_cert, dist2_signer_cert) " \
529 "values('%s', %d, %d, %d, %d, %d, %d, %d, %d, %d)",\
530 info->pkgid,(info->cert_id)[PMINFO_SET_AUTHOR_ROOT_CERT],(info->cert_id)[PMINFO_SET_AUTHOR_INTERMEDIATE_CERT],
531 (info->cert_id)[PMINFO_SET_AUTHOR_SIGNER_CERT], (info->cert_id)[PMINFO_SET_DISTRIBUTOR_ROOT_CERT],
532 (info->cert_id)[PMINFO_SET_DISTRIBUTOR_INTERMEDIATE_CERT], (info->cert_id)[PMINFO_SET_DISTRIBUTOR_SIGNER_CERT],
533 (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_ROOT_CERT],(info->cert_id)[PMINFO_SET_DISTRIBUTOR2_INTERMEDIATE_CERT],
534 (info->cert_id)[PMINFO_SET_DISTRIBUTOR2_SIGNER_CERT]);
536 sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
537 _LOGE("Don't execute query = %s error message = %s\n", vquery,
539 sqlite3_free(error_message);
540 ret = PMINFO_R_ERROR;
543 /*Update index table info*/
544 /*If cert_id exists and is repeated for current package, ref count should only be increased once*/
545 for (i = 0; i < MAX_CERT_TYPE; i++) {
546 if ((info->cert_info)[i]) {
547 memset(vquery, '\0', len);
548 if ((info->is_new)[i]) {
549 snprintf(vquery, len, "insert into package_cert_index_info(cert_info, cert_id, cert_ref_count) " \
550 "values('%s', '%d', '%d') ", (info->cert_info)[i], (info->cert_id)[i], 1);
551 unique_id[c++] = (info->cert_id)[i];
554 for (j = 0; j < MAX_CERT_TYPE; j++) {
555 if ((info->cert_id)[i] == unique_id[j]) {
556 /*Ref count has already been increased. Just continue*/
560 if (j == MAX_CERT_TYPE)
561 unique_id[c++] = (info->cert_id)[i];
564 snprintf(vquery, len, "update package_cert_index_info set cert_ref_count=%d " \
565 "where cert_id=%d", (info->ref_count)[i] + 1, (info->cert_id)[i]);
568 sqlite3_exec(cert_db, vquery, NULL, NULL, &error_message)) {
569 _LOGE("Don't execute query = %s error message = %s\n", vquery,
571 sqlite3_free(error_message);
572 ret = PMINFO_R_ERROR;
577 /*Commit transaction*/
578 ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
579 if (ret != SQLITE_OK) {
580 _LOGE("Failed to commit transaction, Rollback now\n");
581 ret = sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
582 if (ret != SQLITE_OK)
583 _LOGE("Failed to commit transaction, Rollback now\n");
585 ret = PMINFO_R_ERROR;
588 _LOGE("Transaction Commit and End\n");
591 sqlite3_close(cert_db);
603 API int pkgmgrinfo_destroy_certinfo_set_handle(pkgmgrinfo_instcertinfo_h handle)
605 retvm_if(handle == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
607 pkgmgr_instcertinfo_x *certinfo = NULL;
608 certinfo = (pkgmgr_instcertinfo_x *)handle;
609 if (certinfo->pkgid) {
610 free(certinfo->pkgid);
611 certinfo->pkgid = NULL;
613 for (i = 0; i < MAX_CERT_TYPE; i++) {
614 if ((certinfo->cert_info)[i]) {
615 free((certinfo->cert_info)[i]);
616 (certinfo->cert_info)[i] = NULL;
624 API int pkgmgrinfo_delete_certinfo(const char *pkgid)
626 retvm_if(pkgid == NULL, PMINFO_R_EINVAL, "Argument supplied is NULL\n");
629 ret = db_util_open_with_options(CERT_DB, &cert_db, SQLITE_OPEN_READWRITE, NULL);
630 if (ret != SQLITE_OK) {
631 _LOGE("connect db [%s] failed!\n", CERT_DB);
632 ret = PMINFO_R_ERROR;
635 /*Begin Transaction*/
636 ret = sqlite3_exec(cert_db, "BEGIN EXCLUSIVE", NULL, NULL, NULL);
637 if (ret != SQLITE_OK) {
638 _LOGE("Failed to begin transaction\n");
639 ret = PMINFO_R_ERROR;
642 _LOGE("Transaction Begin\n");
643 ret = __delete_certinfo(pkgid);
645 _LOGE("Certificate Deletion Failed\n");
647 _LOGE("Certificate Deletion Success\n");
649 /*Commit transaction*/
650 ret = sqlite3_exec(cert_db, "COMMIT", NULL, NULL, NULL);
651 if (ret != SQLITE_OK) {
652 _LOGE("Failed to commit transaction, Rollback now\n");
653 ret = sqlite3_exec(cert_db, "ROLLBACK", NULL, NULL, NULL);
654 if (ret != SQLITE_OK)
655 _LOGE("Failed to commit transaction, Rollback now\n");
657 ret = PMINFO_R_ERROR;
660 _LOGE("Transaction Commit and End\n");
663 sqlite3_close(cert_db);