* @param[in] pkgid package ID
* @return 0 if success, error code(<0) if fail\n
*/
-int pkgmgr_pkginfo_load_certinfo(const char *pkgid, pkgmgr_certinfo_h handle);
+int pkgmgr_pkginfo_load_certinfo(const char *pkgid, pkgmgr_certinfo_h handle, uid_t uid);
/**
* @brief This API gets cert value for corresponding cert type.
return ret;
}
-API int pkgmgr_pkginfo_load_certinfo(const char *pkgid, pkgmgr_certinfo_h handle)
+API int pkgmgr_pkginfo_load_certinfo(const char *pkgid, pkgmgr_certinfo_h handle, uid_t uid)
{
int ret = 0;
- ret = pkgmgrinfo_pkginfo_load_certinfo(pkgid, handle);
+ ret = pkgmgrinfo_pkginfo_load_certinfo(pkgid, handle, uid);
return ret;
}
#include <string.h>
#include <getopt.h>
-
#include "pkgmgr_installer.h"
#include "pkgmgr_installer_config.h"
return ret;
}
-API int pkgmgr_installer_save_certinfo(const char *pkgid, pkgmgr_instcertinfo_h handle)
+API int pkgmgr_installer_save_certinfo(const char *pkgid, pkgmgr_instcertinfo_h handle, uid_t uid)
{
int ret = 0;
- ret = pkgmgrinfo_save_certinfo(pkgid, handle);
+ ret = pkgmgrinfo_save_certinfo(pkgid, handle, uid);
return ret;
}
*/
-
-
+#include <sys/types.h>
#ifndef __PKGMGR_INSTALLER_H__
#define __PKGMGR_INSTALLER_H__
* @param[in] handle pointer to cert info handle
* @return 0 if success, error code(<0) if fail\n
*/
-int pkgmgr_installer_save_certinfo(const char *pkgid, pkgmgr_instcertinfo_h handle);
+int pkgmgr_installer_save_certinfo(const char *pkgid, pkgmgr_instcertinfo_h handle, uid_t uid);
/**
* @brief This API destroys cert info handle freeing all resources.
#include <sys/inotify.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
+#include <dirent.h>
+#include <sys/types.h>
#include <fcntl.h>
#include <glib.h>
#include <signal.h>
"REFERENCES package_app_info(app_id) " \
"ON DELETE CASCADE)"
+#define QUERY_CREATE_TABLE_CERT "create table if not exists package_cert_index_info " \
+ "(cert_info text not null, " \
+ "cert_id integer, " \
+ "cert_ref_count integer, " \
+ "PRIMARY KEY(cert_id)); " \
+ "create table if not exists package_cert_info " \
+ "(package text not null, " \
+ "author_root_cert integer, " \
+ "author_im_cert integer, " \
+ "author_signer_cert integer, " \
+ "dist_root_cert integer, " \
+ "dist_im_cert integer, " \
+ "dist_signer_cert integer, " \
+ "dist2_root_cert integer, " \
+ "dist2_im_cert integer, " \
+ "dist2_signer_cert integer, " \
+ "PRIMARY KEY(package)) "
+
#ifdef _E
#undef _E
#endif
_E(" %s is not removed",PACKAGE_INFO_DB_FILE);
if(remove(PACKAGE_INFO_DB_FILE_JOURNAL))
_E(" %s is not removed",PACKAGE_INFO_DB_FILE_JOURNAL);
+ if(remove(PKG_CERT_DB_FILE))
+ _E(" %s is not removed",PKG_CERT_DB_FILE);
+ if(remove(PKG_CERT_DB_FILE_JOURNAL))
+ _E(" %s is not removed",PKG_CERT_DB_FILE_JOURNAL);
}
setresuid(GLOBAL_USER, GLOBAL_USER, OWNER_ROOT);
_D("INITDB : %d", ret);
ret = __createdb_tables(&parser_db, PACKAGE_INFO_DB_FILE, QUERY_CREATE_TABLE_PARSER);
- _D("create DB %s", getUserPkgParserDBPathUID(GLOBAL_USER));
+ _D("create DB %s", PACKAGE_INFO_DB_FILE);
+ if (ret) {
+ _D("Parser DB creation Failed\n");
+ return -1;
+ }
+ ret = __createdb_tables(&cert_db, PKG_CERT_DB_FILE, QUERY_CREATE_TABLE_CERT);
+ _D("create DB %s", PKG_CERT_DB_FILE);
if (ret) {
_D("Parser DB creation Failed\n");
return -1;
"REFERENCES package_app_info(app_id) " \
"ON DELETE CASCADE)"
+#define QUERY_CREATE_TABLE_CERT "create table if not exists package_cert_index_info " \
+ "(cert_info text not null, " \
+ "cert_id integer, " \
+ "cert_ref_count integer, " \
+ "PRIMARY KEY(cert_id)); " \
+ "create table if not exists package_cert_info " \
+ "(package text not null, " \
+ "author_root_cert integer, " \
+ "author_im_cert integer, " \
+ "author_signer_cert integer, " \
+ "dist_root_cert integer, " \
+ "dist_im_cert integer, " \
+ "dist_signer_cert integer, " \
+ "dist2_root_cert integer, " \
+ "dist2_im_cert integer, " \
+ "dist2_signer_cert integer, " \
+ "PRIMARY KEY(package)) "
+
#ifdef _E
#undef _E
#endif
int ret;
char *journal = NULL;
uid_t uid = getuid();
- sqlite3 *parser_db;
- sqlite3 *cert_db;
-
if (!__is_authorized()) {
_E("You are not an authorized user!\n");
return -1;
asprintf(&journal, "%s-journal", getUserPkgParserDBPathUID(uid));
if(remove(journal))
_E(" %s is not removed", journal);
+ if(remove(getUserPkgCertDBPathUID(uid)))
+ _E(" %s is not removed", getUserPkgCertDBPathUID(uid));
+ asprintf(&journal, "%s-journal", getUserPkgCertDBPathUID(uid));
+ if(remove(journal))
+ _E(" %s is not removed", journal);
}
/* This is for AIL initializing */
ret = setenv("INITDB", "1", 1);
_D("Parser DB creation Failed\n");
return -1;
}
+ ret = __createdb_user_tables(&cert_db, getUserPkgCertDBPathUID(uid), QUERY_CREATE_TABLE_CERT);
+ _D("create DB %s", getUserPkgCertDBPathUID(uid));
+ if (ret) {
+ _D("Cert DB creation Failed\n");
+ return -1;
+ }
return 0;
}
static int __insert_manifest_in_db(char *manifest, uid_t uid);
static int __remove_manifest_from_db(char *manifest, uid_t uid);
static int __set_pkginfo_in_db(char *pkgid, uid_t uid);
-static int __set_certinfo_in_db(char *pkgid);
-static int __get_certinfo_from_db(char *pkgid);
+static int __set_certinfo_in_db(char *pkgid, uid_t uid);
+static int __get_certinfo_from_db(char *pkgid, uid_t uid);
static int __del_certinfo_from_db(char *pkgid);
static int __get_integer_input_data(void);
char *__get_string_input_data(void);
return 0;
}
-static int __get_certinfo_from_db(char *pkgid)
+static int __get_certinfo_from_db(char *pkgid, uid_t uid)
{
if (pkgid == NULL) {
printf("pkgid is NULL\n");
printf("pkgmgr_pkginfo_create_certinfo failed\n");
return -1;
}
- ret = pkgmgr_pkginfo_load_certinfo(pkgid, handle);
+ ret = pkgmgr_pkginfo_load_certinfo(pkgid, handle, uid);
if (ret < 0) {
printf("pkgmgr_pkginfo_load_certinfo failed\n");
return -1;
return 0;
}
-static int __set_certinfo_in_db(char *pkgid)
+static int __set_certinfo_in_db(char *pkgid, uid_t uid)
{
if (pkgid == NULL) {
printf("pkgid is NULL\n");
choice = __get_integer_input_data();
switch (choice) {
case 0:
- ret = pkgmgr_installer_save_certinfo(pkgid, handle);
+ ret = pkgmgr_installer_save_certinfo(pkgid, handle, uid);
if (ret < 0) {
printf("pkgmgr_installer_save_certinfo failed\n");
pkgmgr_installer_destroy_certinfo_set_handle(handle);
goto end;
}
} else if (strcmp(argv[1], "--setcert") == 0) {
- ret = __set_certinfo_in_db(argv[2]);
+ ret = __set_certinfo_in_db(argv[2], getuid());
if (ret == -1) {
printf("set certinfo in db failed\n");
goto end;
}
} else if (strcmp(argv[1], "--getcert") == 0) {
- ret = __get_certinfo_from_db(argv[2]);
+ ret = __get_certinfo_from_db(argv[2], getuid());
if (ret == -1) {
printf("get certinfo from db failed\n");
goto end;