adjust global DB path for owner user 11/101211/1 accepted/tizen/common/20161130.134238 accepted/tizen/ivi/20161130.233505 accepted/tizen/mobile/20161130.233426 accepted/tizen/wearable/20161130.233448 submit/tizen/20161130.115058
authorIckhee Woo <ickhee.woo@samsung.com>
Wed, 30 Nov 2016 11:46:52 +0000 (20:46 +0900)
committerIckhee Woo <ickhee.woo@samsung.com>
Wed, 30 Nov 2016 11:46:52 +0000 (20:46 +0900)
Change-Id: Ifd095c5dbf7faa791e6f71480a9676d3c8a5ba81
Signed-off-by: Ickhee Woo <ickhee.woo@samsung.com>
packaging/account-manager.spec
server/src/account-server-db.c

index 8648a58..ac8634c 100644 (file)
@@ -1,6 +1,6 @@
 Name:       account-manager
 Summary:    Account Manager
-Version:    0.1.9
+Version:    0.1.10
 Release:    1
 Group:      Social & Content/Other
 License:    Apache-2.0
@@ -24,7 +24,6 @@ BuildRequires:  pkgconfig(account-common)
 BuildRequires:  pkgconfig(libtzplatform-config)
 
 %define upgrade_script_path /usr/share/upgrade/scripts
-%define TZ_OWNER_DB %{TZ_SYS_DB}/5001
 
 Requires(post): /sbin/ldconfig
 Requires(post): /usr/bin/sqlite3
@@ -78,10 +77,10 @@ cp -f scripts/%{name}-upgrade.sh %{buildroot}%{upgrade_script_path}
 #then
 #        mkdir -p /opt/usr/dbspace
 #fi
-mkdir -p %{TZ_OWNER_DB}
-if [ ! -f %{TZ_OWNER_DB}/.account.db ]
+mkdir -p %{TZ_SYS_DB}
+if [ ! -f %{TZ_SYS_DB}/.account.db ]
 then
-        sqlite3 %{TZ_OWNER_DB}/.account.db 'PRAGMA journal_mode = PERSIST;
+        sqlite3 %{TZ_SYS_DB}/.account.db 'PRAGMA journal_mode = PERSIST;
         CREATE TABLE if not exists label (AppId TEXT, Label TEXT, Locale TEXT);
         CREATE TABLE if not exists account_type (_id INTEGER PRIMARY KEY AUTOINCREMENT, AppId TEXT,
         ServiceProviderId TEXT, IconPath TEXT, SmallIconPath TEXT, MultipleAccountSupport INT);
@@ -96,12 +95,11 @@ then
 '
 fi
 
-chown service_fw:service_fw %{TZ_OWNER_DB}
-chown service_fw:service_fw %{TZ_OWNER_DB}/.account.db
-chown service_fw:service_fw %{TZ_OWNER_DB}/.account.db-journal
+chown service_fw:service_fw %{TZ_SYS_DB}/.account.db
+chown service_fw:service_fw %{TZ_SYS_DB}/.account.db-journal
 
-chmod 644 %{TZ_OWNER_DB}/.account.db
-chmod 644 %{TZ_OWNER_DB}/.account.db-journal
+chmod 644 %{TZ_SYS_DB}/.account.db
+chmod 644 %{TZ_SYS_DB}/.account.db-journal
 
 #smack labeling
 #chsmack -a 'System::Shared' %{TZ_SYS_DB}/.account.db-journal
index a29cd5e..27161da 100644 (file)
@@ -227,55 +227,55 @@ static int _account_end_transaction_from_global_db(bool is_success)
 
 int _account_global_db_open(void)
 {
-       int  rc = 0;
+       int rc = 0;
        int ret = -1;
        char account_db_path[256] = {0, };
 
-       _INFO( "start _account_global_db_open()");
+       _INFO("start _account_global_db_open()");
 
        ACCOUNT_MEMSET(account_db_path, 0x00, sizeof(account_db_path));
-       ACCOUNT_GET_OWNER_DB_PATH(account_db_path, sizeof(account_db_path), 5001);
+       ACCOUNT_GET_GLOBAL_DB_PATH(account_db_path, sizeof(account_db_path));
 
-       if( g_hAccountGlobalDB ) {
-               _ERR( "Account database is using in another app. %x", g_hAccountDB );
+       if (g_hAccountGlobalDB) {
+               _ERR("Account database is using in another app. %x", g_hAccountDB);
                return _ACCOUNT_ERROR_DATABASE_BUSY;
        }
 
        ret = _account_db_handle_close(g_hAccountGlobalDB2);
-       if( ret != _ACCOUNT_ERROR_NONE )
-               ACCOUNT_DEBUG( "db_util_close(g_hAccountGlobalDB2) fail ret = %d", ret);
+       if (ret != _ACCOUNT_ERROR_NONE)
+               ACCOUNT_DEBUG("db_util_close(g_hAccountGlobalDB2) fail ret = %d", ret);
 
-       ACCOUNT_DEBUG( "before _account_global_db_open()");
+       ACCOUNT_DEBUG("before _account_global_db_open()");
 //     if(mode == ACCOUNT_DB_OPEN_READWRITE)
 //             rc = db_util_open(account_db_path, &g_hAccountDB, DB_UTIL_REGISTER_HOOK_METHOD);
 //     else if(mode == ACCOUNT_DB_OPEN_READONLY)
        rc = db_util_open_with_options(account_db_path, &g_hAccountGlobalDB, SQLITE_OPEN_READONLY, NULL);
 //     else
 //             return _ACCOUNT_ERROR_DB_NOT_OPENED;
-       ACCOUNT_DEBUG( "after _account_global_db_open() sqlite_rc = %d", rc);
+       ACCOUNT_DEBUG("after _account_global_db_open() sqlite_rc = %d", rc);
 
-       if( rc == SQLITE_PERM || _account_db_err_code(g_hAccountGlobalDB) == SQLITE_PERM ) {
-               ACCOUNT_ERROR( "Account permission denied");
+       if (rc == SQLITE_PERM || _account_db_err_code(g_hAccountGlobalDB) == SQLITE_PERM) {
+               ACCOUNT_ERROR("Account permission denied");
                return _ACCOUNT_ERROR_PERMISSION_DENIED;
        }
 
-       if( rc == SQLITE_BUSY ) {
-               ACCOUNT_ERROR( "busy handler fail.");
+       if (rc == SQLITE_BUSY) {
+               ACCOUNT_ERROR("busy handler fail.");
                return _ACCOUNT_ERROR_DATABASE_BUSY;
        }
 
-       if( rc != SQLITE_OK ) {
-               ACCOUNT_ERROR( "The database isn't connected." );
+       if (rc != SQLITE_OK) {
+               ACCOUNT_ERROR("The database isn't connected.");
                return _ACCOUNT_ERROR_DB_NOT_OPENED;
        }
 
-       _INFO( "end _account_global_db_open()");
+       _INFO("end _account_global_db_open()");
        return _ACCOUNT_ERROR_NONE;
 }
 
 int _account_global_db_close(void)
 {
-       ACCOUNT_DEBUG( "start account_global_db_close()");
+       ACCOUNT_DEBUG("start account_global_db_close()");
        int ret = -1;
 /*
        ret = _account_db_handle_close(g_hAccountGlobalDB2);
@@ -283,9 +283,8 @@ int _account_global_db_close(void)
                ACCOUNT_DEBUG( "db_util_close(g_hAccountGlobalDB2) fail ret = %d", ret);
 */
        ret = _account_db_handle_close(g_hAccountGlobalDB);
-       if( ret != _ACCOUNT_ERROR_NONE )
-       {
-               ACCOUNT_ERROR( "db_util_close(g_hAccountGlobalDB) fail ret = %d", ret);
+       if (ret != _ACCOUNT_ERROR_NONE) {
+               ACCOUNT_ERROR("db_util_close(g_hAccountGlobalDB) fail ret = %d", ret);
                g_hAccountGlobalDB2 = g_hAccountGlobalDB;
        }
        g_hAccountGlobalDB = NULL;
@@ -328,54 +327,53 @@ static bool _account_check_add_more_account(const char* app_id)
 
 int _account_db_open(int mode, int pid, uid_t uid)
 {
-       int  rc = 0;
+       int rc = 0;
        int ret = -1;
        char account_db_dir[256] = {0, };
        char account_db_path[256] = {0, };
 
-       _INFO( "start _account_db_open() pid [%d]. uid [%d]", pid, uid);
+       _INFO("start _account_db_open() pid [%d]. uid [%d]", pid, uid);
 
        ACCOUNT_MEMSET(account_db_dir, 0x00, sizeof(account_db_dir));
        ACCOUNT_MEMSET(account_db_path, 0x00, sizeof(account_db_path));
 
        ACCOUNT_GET_USER_DB_PATH(account_db_path, sizeof(account_db_path), uid);
 
-       if( g_hAccountDB ) {
-               _ERR( "Account database is using in another app. %x", g_hAccountDB );
+       if (g_hAccountDB) {
+               _ERR("Account database is using in another app. %x", g_hAccountDB);
                return _ACCOUNT_ERROR_DATABASE_BUSY;
        }
 
        ret = _account_db_handle_close(g_hAccountDB2);
-       if( ret != _ACCOUNT_ERROR_NONE )
-               ACCOUNT_DEBUG( "db_util_close(g_hAccountDB2) fail ret = %d", ret);
+       if (ret != _ACCOUNT_ERROR_NONE)
+               ACCOUNT_DEBUG("db_util_close(g_hAccountDB2) fail ret = %d", ret);
 
        ACCOUNT_GET_USER_DB_DIR(account_db_dir, sizeof(account_db_dir), uid);
 
        if (mkdir(account_db_dir, 0777) != 0)
-               ACCOUNT_DEBUG("mkdir \"%s\" fail", account_db_dir);
+               ACCOUNT_DEBUG("\"%s\" is already exist directory", account_db_dir);
 
-
-       ACCOUNT_DEBUG( "before db_util_open()");
+       ACCOUNT_DEBUG("before db_util_open()");
 //     if(mode == ACCOUNT_DB_OPEN_READWRITE)
                rc = db_util_open(account_db_path, &g_hAccountDB, DB_UTIL_REGISTER_HOOK_METHOD);
 //     else if(mode == ACCOUNT_DB_OPEN_READONLY)
 //             rc = db_util_open_with_options(account_db_path, &g_hAccountDB, SQLITE_OPEN_READONLY, NULL);
 //     else
 //             return _ACCOUNT_ERROR_DB_NOT_OPENED;
-       ACCOUNT_DEBUG( "after db_util_open() sqlite_rc = %d", rc);
+       ACCOUNT_DEBUG("after db_util_open() sqlite_rc = %d", rc);
 
-       if( rc == SQLITE_PERM || _account_db_err_code(g_hAccountDB) == SQLITE_PERM ) {
-               ACCOUNT_ERROR( "Account permission denied");
+       if (rc == SQLITE_PERM || _account_db_err_code(g_hAccountDB) == SQLITE_PERM) {
+               ACCOUNT_ERROR("Account permission denied");
                return _ACCOUNT_ERROR_PERMISSION_DENIED;
        }
 
-       if( rc == SQLITE_BUSY ) {
-               ACCOUNT_ERROR( "busy handler fail.");
+       if (rc == SQLITE_BUSY) {
+               ACCOUNT_ERROR("busy handler fail.");
                return _ACCOUNT_ERROR_DATABASE_BUSY;
        }
 
-       if( rc != SQLITE_OK ) {
-               ACCOUNT_ERROR( "The database isn't connected." );
+       if (rc != SQLITE_OK) {
+               ACCOUNT_ERROR("The database isn't connected.");
                return _ACCOUNT_ERROR_DB_NOT_OPENED;
        }
 
@@ -394,13 +392,13 @@ int _account_db_open(int mode, int pid, uid_t uid)
                }
        }
 
-       _INFO( "end _account_db_open()");
+       _INFO("end _account_db_open()");
        return _ACCOUNT_ERROR_NONE;
 }
 
 int _account_db_close(void)
 {
-       ACCOUNT_DEBUG( "start db_util_close()");
+       ACCOUNT_DEBUG("start db_util_close()");
        int ret = -1;
 /*
        ret = _account_db_handle_close(g_hAccountDB2);
@@ -410,7 +408,7 @@ int _account_db_close(void)
        ret = _account_db_handle_close(g_hAccountDB);
        if( ret != _ACCOUNT_ERROR_NONE )
        {
-               ACCOUNT_ERROR( "db_util_close(g_hAccountDB) fail ret = %d", ret);
+               ACCOUNT_ERROR("db_util_close(g_hAccountDB) fail ret = %d", ret);
                g_hAccountDB2 = g_hAccountDB;
        }
        g_hAccountDB = NULL;