BEGIN TRANSACTION;
+CREATE TABLE schema_info (
+ version INT PRIMARY KEY not null,
+ description TEXT);
+
CREATE TABLE ssl (
gname TEXT PRIMARY KEY not null,
certificate TEXT not null,
echo "${common_name:1}" # cut first whitespace
}
-function initialize_store()
+function initialize_store_version()
+{
+ sqlite3 $DB_PATH "INSERT INTO schema_info (version, description) \
+ VALUES (2, 'Tizen 3.0');"
+}
+
+function initialize_store_data()
{
echo "BEGIN TRANSACTION;" >> $ROOT_CERT_SQL
for fname in `find $SYSTEM_SSL_DIR/* | sort`
echo "INSERT INTO ssl \
(gname, certificate, file_hash, subject_hash, \
- common_name, enabled, is_root_app_enabled) values \
+ common_name, enabled, is_root_app_enabled) VALUES \
(\"$gname\", \"$cert\", \"$subject_hash\", \"$subject_hash_old\", \
\"$common_name\", 1, 1);" >> $ROOT_CERT_SQL
done
touch $ROOT_CERT_SQL
-initialize_store
+initialize_store_version
+initialize_store_data
cat $ROOT_CERT_SQL | sqlite3 $DB_PATH
extern sqlite3 *cert_store_db;
+typedef enum schema_version_t {
+ TIZEN_2_4 = 1,
+ TIZEN_3_0 = 2
+} schema_version;
+
int initialize_db(void);
void deinitialize_db(void);
int execute_insert_update_query(const char *query);
sqlite3 *cert_store_db = NULL;
+
+void check_schema_version(void)
+{
+ sqlite3_stmt *stmt = NULL;
+ char *query = NULL;
+
+ query = sqlite3_mprintf("SELECT version FROM schema_info WHERE version=%d",
+ TIZEN_3_0);
+
+ int result = execute_select_query(query, &stmt);
+
+ if (result != CERTSVC_SUCCESS) {
+ SLOGE("Failed to get schema version.");
+ return;
+ }
+
+ if (sqlite3_step(stmt) == SQLITE_ROW)
+ SLOGI("Database version is 2(Tizen 3.0)");
+ else
+ SLOGW("Database should be upgrade.");
+
+ if (query)
+ sqlite3_free(query);
+ if (stmt)
+ sqlite3_finalize(stmt);
+}
+
int initialize_db(void)
{
int result = CERTSVC_SUCCESS;
return CERTSVC_FAIL;
}
+ /* Check schema version for consistent on platform upgrade */
+ check_schema_version();
+
return CERTSVC_SUCCESS;
}