[Non-ACR] improve SAM score 67/243167/3
authorAbhishek Vijay <abhishek.v@samsung.com>
Thu, 3 Sep 2020 12:53:19 +0000 (18:23 +0530)
committerAbhishek Vijay <abhishek.v@samsung.com>
Fri, 4 Sep 2020 09:42:49 +0000 (15:12 +0530)
Change-Id: I9e941fcaaade46e176df95e7b9f16aac8f00c870
Signed-off-by: Abhishek Vijay <abhishek.v@samsung.com>
packaging/account-manager.spec
server/src/account-server.c

index 0cb57a9..da56c0e 100644 (file)
@@ -1,6 +1,6 @@
 Name:       account-manager
 Summary:    Account Manager
-Version:    0.1.19
+Version:    0.1.20
 Release:    1
 Group:      Social & Content/Other
 License:    Apache-2.0
index eb39c05..e05893b 100644 (file)
@@ -125,9 +125,9 @@ __ACCOUNT_ERROR_quark(void)
        static volatile gsize quark_volatile = 0;
 
        g_dbus_error_register_error_domain(_ACCOUNT_SVC_ERROR_DOMAIN,
-                                                                               &quark_volatile,
-                                                                               _account_svc_errors,
-                                                                               G_N_ELEMENTS(_account_svc_errors));
+                                       &quark_volatile,
+                                       _account_svc_errors,
+                                       G_N_ELEMENTS(_account_svc_errors));
 
        return (GQuark) quark_volatile;
 }
@@ -240,38 +240,86 @@ int _check_priviliege_account_write(GDBusMethodInvocation *invocation)
        return _check_privilege(invocation, _PRIVILEGE_ACCOUNT_WRITE);
 }
 
-gboolean account_manager_account_add(AccountManager *obj, GDBusMethodInvocation *invocation, GVariant* account_data, gint uid, gpointer user_data)
+void _account_set_db_close(gboolean flag)
 {
-       _INFO("account_manager_account_add start");
-       lifecycle_method_call_active();
+       if (!flag) {
+               _ERR("invalid flag");
+               return;
+       }
 
-       int db_id = -1;
-       account_s* account = NULL;
+       int rc = _ACCOUNT_ERROR_NONE;
 
-       guint pid = _get_client_pid(invocation);
-       _INFO("client Id = [%u]", pid);
+       rc = _account_db_close();
+       if (rc != _ACCOUNT_ERROR_NONE)
+               ACCOUNT_DEBUG("_account_db_close() fail[%d]", rc);
 
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
+
+       rc = _account_global_db_close();
+       if (rc != _ACCOUNT_ERROR_NONE)
+               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", rc);
+
+       return;
+}
+
+int _account_check_privilege_and_set_db_open(GDBusMethodInvocation *invocation, gint uid,
+                                               guint *pid, gboolean read_priv, gboolean write_priv)
+{
+       if (invocation == NULL) {
+               _ERR("invalid invocation");
+               return _ACCOUNT_ERROR_INVALID_PARAMETER;
        }
 
-       return_code = _check_priviliege_account_write(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_write failed, ret = %d", return_code);
+       _INFO("uid - [%d], read_priv - [%d], write_priv - [%d]", uid, read_priv, write_priv);
+
+       *pid = _get_client_pid(invocation);
+       _INFO("client Id = [%u]", *pid);
+
+       int rc = _ACCOUNT_ERROR_NONE;
+
+       if (read_priv) {
+               rc = _check_priviliege_account_read(invocation);
+               if (rc != _ACCOUNT_ERROR_NONE) {
+                       _ERR("_check_priviliege_account_read failed, ret = %d", rc);
+                       goto RETURN;
+               }
+       }
+
+       if (write_priv) {
+               rc = _check_priviliege_account_write(invocation);
+               if (rc != _ACCOUNT_ERROR_NONE) {
+                       _ERR("_check_priviliege_account_write failed, ret = %d", rc);
+                       goto RETURN;
+               }
+       }
+
+       rc = _account_db_open(1, *pid, uid);
+       if (rc != _ACCOUNT_ERROR_NONE) {
+               _ERR("_account_db_open() error, ret = %d", rc);
                goto RETURN;
        }
 
-       return_code = _account_db_open(1, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
+       rc = _account_global_db_open();
+       if (rc != _ACCOUNT_ERROR_NONE) {
+               _ERR("_account_global_db_open() error, ret = %d", rc);
                goto RETURN;
        }
 
-       return_code = _account_global_db_open();
+RETURN:
+       return rc;
+}
+
+gboolean account_manager_account_add(AccountManager *obj, GDBusMethodInvocation *invocation, GVariant* account_data, gint uid, gpointer user_data)
+{
+       _INFO("account_manager_account_add start");
+       lifecycle_method_call_active();
+
+       int db_id = -1;
+       account_s* account = NULL;
+       guint pid = -1;
+
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, true);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -300,17 +348,7 @@ RETURN:
                account_manager_complete_account_add(obj, invocation, db_id);
        }
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        _account_free_account_with_items(account);
 
@@ -327,25 +365,11 @@ account_manager_account_query_all(AccountManager *obj, GDBusMethodInvocation *in
        lifecycle_method_call_active();
 
        GVariant* account_list_variant = NULL;
+       guint pid = -1;
 
-       guint pid = _get_client_pid(invocation);
-       _INFO("client Id = [%u]", pid);
-
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_db_open(0, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_global_db_open();
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -378,17 +402,7 @@ RETURN:
                account_manager_complete_account_query_all(obj, invocation, account_list_variant);
        }
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        lifecycle_method_call_inactive();
        _INFO("account_manager_account_query_all end");
@@ -403,24 +417,11 @@ account_manager_account_type_query_all(AccountManager *obj, GDBusMethodInvocatio
        lifecycle_method_call_active();
 
        GVariant* account_type_list_variant = NULL;
-       guint pid = _get_client_pid(invocation);
-       _INFO("client Id = [%u]", pid);
-
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_db_open(0, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
+       guint pid = -1;
 
-       return_code = _account_global_db_open();
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -453,17 +454,7 @@ RETURN:
                account_manager_complete_account_type_query_all(obj, invocation, account_type_list_variant);
        }
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        lifecycle_method_call_inactive();
        _INFO("account_manager_account_query_all end");
@@ -479,31 +470,11 @@ account_manager_account_type_add(AccountManager *obj, GDBusMethodInvocation *inv
 
        int db_id = -1;
        account_type_s *account_type = NULL;
+       guint pid = -1;
 
-       guint pid = _get_client_pid(invocation);
-       _INFO("client pid = [%u], uid = [%d]", pid, uid);
-
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _check_priviliege_account_write(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_write failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_db_open(1, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_global_db_open();
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, true);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -534,17 +505,7 @@ RETURN:
                account_manager_complete_account_type_add(obj, invocation, db_id);
        }
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        _account_type_free_account_type_with_items(account_type);
 
@@ -556,37 +517,18 @@ RETURN:
 
 gboolean
 account_manager_account_delete_from_db_by_id(AccountManager *object,
-                                                                                        GDBusMethodInvocation *invocation,
-                                                                                        gint account_db_id,
-                                                                                        gint uid)
+                                        GDBusMethodInvocation *invocation,
+                                        gint account_db_id,
+                                        gint uid)
 {
        _INFO("account_manager_account_delete_from_db_by_id start");
        lifecycle_method_call_active();
 
-       guint pid = _get_client_pid(invocation);
-       _INFO("client Id = [%u]", pid);
-
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _check_priviliege_account_write(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_write failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_db_open(1, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
+       guint pid = -1;
 
-       return_code = _account_global_db_open();
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, true);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -610,17 +552,7 @@ RETURN:
                account_manager_complete_account_delete_from_db_by_id(object, invocation);
        }
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        lifecycle_method_call_inactive();
        _INFO("account_manager_account_delete_from_db_by_id end");
@@ -630,38 +562,19 @@ RETURN:
 
 gboolean
 account_manager_account_delete_from_db_by_user_name(AccountManager *object,
-                                                                                                                        GDBusMethodInvocation *invocation,
-                                                                                                                        const gchar *user_name,
-                                                                                                                        const gchar *package_name,
-                                                                                                                        gint uid)
+                                                GDBusMethodInvocation *invocation,
+                                                const gchar *user_name,
+                                                const gchar *package_name,
+                                                gint uid)
 {
        _INFO("account_manager_account_delete_from_db_by_user_name start");
        lifecycle_method_call_active();
 
-       guint pid = _get_client_pid(invocation);
-       _INFO("client Id = [%u]", pid);
-
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _check_priviliege_account_write(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_write failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_db_open(1, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
+       guint pid = -1;
 
-       return_code = _account_global_db_open();
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, true);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -685,17 +598,7 @@ RETURN:
                account_manager_complete_account_delete_from_db_by_id(object, invocation);
        }
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        lifecycle_method_call_inactive();
        _INFO("account_manager_account_delete_from_db_by_user_name end");
@@ -705,42 +608,24 @@ RETURN:
 
 gboolean
 account_manager_account_delete_from_db_by_package_name(AccountManager *object,
-                                                                GDBusMethodInvocation *invocation,
-                                                                const gchar *package_name,
-                                                                gboolean permission,
-                                                                gint uid)
+                                                GDBusMethodInvocation *invocation,
+                                                const gchar *package_name,
+                                                gboolean permission,
+                                                gint uid)
 {
        _INFO("account_manager_account_delete_from_db_by_package_name start");
        lifecycle_method_call_active();
 
        int return_code = _ACCOUNT_ERROR_NONE;
+       guint pid = -1;
 
-       guint pid = _get_client_pid(invocation);
-       _INFO("client Id = [%u]", pid);
-
-       if (permission) {
-               return_code = _check_priviliege_account_read(invocation);
-               if (return_code != _ACCOUNT_ERROR_NONE) {
-                       _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-                       goto RETURN;
-               }
-
-               return_code = _check_priviliege_account_write(invocation);
-               if (return_code != _ACCOUNT_ERROR_NONE) {
-                       _ERR("_check_priviliege_account_write failed, ret = %d", return_code);
-                       goto RETURN;
-               }
-       }
-
-       return_code = _account_db_open(1, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
+       if (permission)
+               return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, true);
+       else
+               return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, false, false);
 
-       return_code = _account_global_db_open();
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -764,17 +649,7 @@ RETURN:
                account_manager_complete_account_delete_from_db_by_package_name(object, invocation);
        }
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        lifecycle_method_call_inactive();
        _INFO("account_manager_account_delete_from_db_by_package_name end");
@@ -784,40 +659,20 @@ RETURN:
 
 gboolean
 account_manager_account_update_to_db_by_id(AccountManager *object,
-                                                                                                                       GDBusMethodInvocation *invocation,
-                                                                                                                       GVariant *account_data,
-                                                                                                                       gint account_id,
-                                                                                                                       gint uid)
+                                       GDBusMethodInvocation *invocation,
+                                       GVariant *account_data,
+                                       gint account_id,
+                                       gint uid)
 {
        _INFO("account_manager_account_update_to_db_by_id start");
        lifecycle_method_call_active();
 
        account_s *account = NULL;
+       guint pid = -1;
 
-       guint pid = _get_client_pid(invocation);
-       _INFO("client Id = [%u]", pid);
-
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _check_priviliege_account_write(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_write failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_db_open(1, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_global_db_open();
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, true);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -848,17 +703,7 @@ RETURN:
                account_manager_complete_account_update_to_db_by_id(object, invocation);
        }
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        _account_free_account_with_items(account);
 
@@ -870,41 +715,21 @@ RETURN:
 
 gboolean
 account_manager_handle_account_update_to_db_by_user_name(AccountManager *object,
-                                                                                                                       GDBusMethodInvocation *invocation,
-                                                                                                                       GVariant *account_data,
-                                                                                                                       const gchar *user_name,
-                                                                                                                       const gchar *package_name,
-                                                                                                                       gint uid)
+                                                       GDBusMethodInvocation *invocation,
+                                                       GVariant *account_data,
+                                                       const gchar *user_name,
+                                                       const gchar *package_name,
+                                                       gint uid)
 {
        _INFO("account_manager_handle_account_update_to_db_by_user_name start");
        lifecycle_method_call_active();
 
        account_s* account = NULL;
+       guint pid = -1;
 
-       guint pid = _get_client_pid(invocation);
-       _INFO("client Id = [%u]", pid);
-
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _check_priviliege_account_write(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_write failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_db_open(1, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_global_db_open();
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, true);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -925,7 +750,6 @@ account_manager_handle_account_update_to_db_by_user_name(AccountManager *object,
        }
 
 RETURN:
-
        if (return_code != _ACCOUNT_ERROR_NONE) {
                _ERR("Account SVC is returning error [%d]", return_code);
                GError* error = g_error_new(__ACCOUNT_ERROR_quark(), return_code, "RecordNotFound");
@@ -935,17 +759,7 @@ RETURN:
                account_manager_complete_account_update_to_db_by_id(object, invocation);
        }
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        _account_free_account_with_items(account);
 
@@ -957,34 +771,20 @@ RETURN:
 
 gboolean
 account_manager_handle_account_type_query_label_by_locale(AccountManager *object,
-                                                                                                                       GDBusMethodInvocation *invocation,
-                                                                                                                       const gchar *app_id,
-                                                                                                                       const gchar *locale,
-                                                                                                                       gint uid)
+                                               GDBusMethodInvocation *invocation,
+                                               const gchar *app_id,
+                                               const gchar *locale,
+                                               gint uid)
 {
        _INFO("account_manager_handle_account_type_query_label_by_locale start");
        lifecycle_method_call_active();
 
        char *label_name = NULL;
-       guint pid = _get_client_pid(invocation);
-
-       _INFO("client Id = [%u]", pid);
-
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_db_open(0, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
+       guint pid = -1;
 
-       return_code = _account_global_db_open();
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -1009,17 +809,7 @@ RETURN:
        }
        _ACCOUNT_FREE(label_name);
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        lifecycle_method_call_inactive();
        _INFO("account_manager_handle_account_type_query_label_by_locale end");
@@ -1029,34 +819,19 @@ RETURN:
 
 gboolean
 account_manager_handle_account_type_query_by_provider_feature(AccountManager *obj,
-                                                                                                                       GDBusMethodInvocation *invocation,
-                                                                                                                       const gchar *key,
-                                                                                                                       gint uid)
+                                                       GDBusMethodInvocation *invocation,
+                                                       const gchar *key,
+                                                       gint uid)
 {
        _INFO("account_manager_handle_account_type_query_by_provider_feature start");
        lifecycle_method_call_active();
 
        GVariant* account_type_list_variant = NULL;
+       guint pid = -1;
 
-       guint pid = _get_client_pid(invocation);
-
-       _INFO("client Id = [%u]", pid);
-
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_db_open(0, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_global_db_open();
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -1098,17 +873,7 @@ RETURN:
                account_manager_complete_account_type_query_by_provider_feature(obj, invocation, account_type_list_variant);
        }
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        lifecycle_method_call_inactive();
        _INFO("account_manager_handle_account_type_query_by_provider_feature end");
@@ -1123,25 +888,11 @@ account_manager_account_get_total_count_from_db(AccountManager *object, GDBusMet
        lifecycle_method_call_active();
 
        int count = -1;
-       guint pid = _get_client_pid(invocation);
-
-       _INFO("client Id = [%u]", pid);
-
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_db_open(0, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
+       guint pid = -1;
 
-       return_code = _account_global_db_open();
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -1165,17 +916,7 @@ RETURN:
                account_manager_complete_account_get_total_count_from_db(object, invocation, count);
        }
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        lifecycle_method_call_inactive();
        _INFO("account_manager_account_get_total_count_from_db end");
@@ -1193,26 +934,11 @@ account_manager_handle_account_query_account_by_account_id(AccountManager *objec
 
        GVariant* account_variant = NULL;
        account_s* account_data = NULL;
+       guint pid = -1;
 
-       guint pid = _get_client_pid(invocation);
-
-       _INFO("client Id = [%u]", pid);
-
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_db_open(0, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_global_db_open();
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -1248,17 +974,7 @@ RETURN:
                account_manager_complete_account_query_account_by_account_id(object, invocation, account_variant);
        }
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        _account_free_account_with_items(account_data);
 
@@ -1278,25 +994,11 @@ account_manager_handle_account_query_account_by_user_name(AccountManager *obj,
        lifecycle_method_call_active();
 
        GVariant* account_list_variant = NULL;
-       guint pid = _get_client_pid(invocation);
-
-       _INFO("client Id = [%u]", pid);
-
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_db_open(0, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
+       guint pid = -1;
 
-       return_code = _account_global_db_open();
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -1334,17 +1036,7 @@ RETURN:
                account_manager_complete_account_query_account_by_user_name(obj, invocation, account_list_variant);
        }
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        lifecycle_method_call_inactive();
        _INFO("account_manager_handle_account_query_account_by_user_name end");
@@ -1354,33 +1046,19 @@ RETURN:
 
 gboolean
 account_manager_handle_account_query_account_by_package_name(AccountManager *obj,
-                                                                                                                 GDBusMethodInvocation *invocation,
-                                                                                                                 const gchar *package_name,
-                                                                                                                 gint uid)
+                                                         GDBusMethodInvocation *invocation,
+                                                         const gchar *package_name,
+                                                         gint uid)
 {
        _INFO("account_manager_handle_account_query_account_by_package_name start");
        lifecycle_method_call_active();
 
        GVariant* account_list_variant = NULL;
-       guint pid = _get_client_pid(invocation);
-
-       _INFO("client Id = [%u]", pid);
-
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_db_open(0, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
+       guint pid = -1;
 
-       return_code = _account_global_db_open();
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -1417,17 +1095,7 @@ RETURN:
        }
        _INFO("account_manager_handle_account_query_account_by_package_name start");
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        lifecycle_method_call_inactive();
        _INFO("account_manager_handle_account_query_account_by_package_name start");
@@ -1437,35 +1105,20 @@ RETURN:
 
 gboolean
 account_manager_handle_account_query_account_by_capability(AccountManager *obj,
-                                                                                                                 GDBusMethodInvocation *invocation,
-                                                                                                                 const gchar *capability_type,
-                                                                                                                 gint capability_value,
-                                                                                                                 gint uid)
+                                                         GDBusMethodInvocation *invocation,
+                                                         const gchar *capability_type,
+                                                         gint capability_value,
+                                                         gint uid)
 {
        _INFO("account_manager_handle_account_query_account_by_capability start");
        lifecycle_method_call_active();
 
        GVariant* account_list_variant = NULL;
+       guint pid = -1;
 
-       guint pid = _get_client_pid(invocation);
-
-       _INFO("client Id = [%u]", pid);
-
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_db_open(0, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_global_db_open();
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -1503,17 +1156,7 @@ RETURN:
                account_manager_complete_account_query_account_by_capability(obj, invocation, account_list_variant);
        }
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        lifecycle_method_call_inactive();
        _INFO("account_manager_handle_account_query_account_by_capability end");
@@ -1523,35 +1166,19 @@ RETURN:
 
 gboolean
 account_manager_handle_account_query_account_by_capability_type(AccountManager *obj,
-                                                                                                                 GDBusMethodInvocation *invocation,
-                                                                                                                 const gchar *capability_type,
-                                                                                                                 gint uid)
+                                                         GDBusMethodInvocation *invocation,
+                                                         const gchar *capability_type,
+                                                         gint uid)
 {
        _INFO("account_manager_handle_account_query_account_by_capability_type start");
        lifecycle_method_call_active();
 
        GVariant* account_list_variant = NULL;
+       guint pid = -1;
 
-       guint pid = _get_client_pid(invocation);
-
-       _INFO("client Id = [%u]", pid);
-
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_db_open(0, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_global_db_open();
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
-
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -1589,17 +1216,7 @@ RETURN:
                account_manager_complete_account_query_account_by_capability(obj, invocation, account_list_variant);
        }
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        lifecycle_method_call_inactive();
        _INFO("account_manager_handle_account_query_account_by_capability_type end");
@@ -1609,34 +1226,19 @@ RETURN:
 
 gboolean
 account_manager_handle_account_query_capability_by_account_id(AccountManager *obj,
-                                                                                                                 GDBusMethodInvocation *invocation,
-                                                                                                                 const int account_id,
-                                                                                                                 gint uid)
+                                                         GDBusMethodInvocation *invocation,
+                                                         const int account_id,
+                                                         gint uid)
 {
        _INFO("account_manager_handle_account_query_capability_by_account_id start");
        lifecycle_method_call_active();
 
        GVariant* capability_list_variant = NULL;
+       guint pid = -1;
 
-       guint pid = _get_client_pid(invocation);
-
-       _INFO("client Id = [%u]", pid);
-
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_db_open(0, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_global_db_open();
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -1674,17 +1276,7 @@ RETURN:
                account_manager_complete_account_query_capability_by_account_id(obj, invocation, capability_list_variant);
        }
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        lifecycle_method_call_inactive();
        _INFO("account_manager_handle_account_query_capability_by_account_id end");
@@ -1694,39 +1286,18 @@ RETURN:
 
 gboolean
 account_manager_handle_account_update_sync_status_by_id(AccountManager *object,
-                                                                                                                       GDBusMethodInvocation *invocation,
-                                                                                                                       const int account_db_id,
-                                                                                                                       const int sync_status,
-                                                                                                                       gint uid)
+                                                       GDBusMethodInvocation *invocation,
+                                                       const int account_db_id,
+                                                       const int sync_status,
+                                                       gint uid)
 {
        _INFO("account_manager_handle_account_update_sync_status_by_id start");
        lifecycle_method_call_active();
+       guint pid = -1;
 
-       guint pid = _get_client_pid(invocation);
-
-       _INFO("client Id = [%u]", pid);
-
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _check_priviliege_account_write(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_write failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_db_open(1, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_global_db_open();
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, true);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -1750,17 +1321,7 @@ RETURN:
                account_manager_complete_account_update_sync_status_by_id(object, invocation);
        }
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        lifecycle_method_call_inactive();
        _INFO("account_manager_handle_account_update_sync_status_by_id end");
@@ -1770,35 +1331,20 @@ RETURN:
 
 gboolean
 account_manager_handle_account_type_query_provider_feature_by_app_id(AccountManager *obj,
-                                                                                                                       GDBusMethodInvocation *invocation,
-                                                                                                                       const gchar* app_id,
-                                                                                                                       gint uid)
+                                                               GDBusMethodInvocation *invocation,
+                                                               const gchar* app_id,
+                                                               gint uid)
 {
        _INFO("account_manager_handle_account_type_query_provider_feature_by_app_id start");
        lifecycle_method_call_active();
 
        GSList* feature_record_list = NULL;
        GVariant* feature_record_list_variant = NULL;
+       guint pid = -1;
 
-       guint pid = _get_client_pid(invocation);
-
-       _INFO("client Id = [%u]", pid);
-
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_db_open(0, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_global_db_open();
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -1831,17 +1377,7 @@ RETURN:
                account_manager_complete_account_type_query_provider_feature_by_app_id(obj, invocation, feature_record_list_variant);
        }
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        lifecycle_method_call_inactive();
        _INFO("account_manager_handle_account_type_query_provider_feature_by_app_id end");
@@ -1851,34 +1387,20 @@ RETURN:
 
 gboolean
 account_manager_handle_account_type_query_supported_feature(AccountManager *obj,
-                                                                                                                       GDBusMethodInvocation *invocation,
-                                                                                                                       const gchar* app_id,
-                                                                                                                       const gchar* capability,
-                                                                                                                       gint uid)
+                                                       GDBusMethodInvocation *invocation,
+                                                       const gchar* app_id,
+                                                       const gchar* capability,
+                                                       gint uid)
 {
        _INFO("account_manager_handle_account_type_query_supported_feature start");
        lifecycle_method_call_active();
 
        int is_supported = 0;
-       guint pid = _get_client_pid(invocation);
-
-       _INFO("client Id = [%u]", pid);
-
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_db_open(0, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
+       guint pid = -1;
 
-       return_code = _account_global_db_open();
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -1902,17 +1424,7 @@ RETURN:
                account_manager_complete_account_type_query_supported_feature(obj, invocation, is_supported);
        }
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        lifecycle_method_call_inactive();
        _INFO("account_manager_handle_account_type_query_supported_feature end");
@@ -1922,41 +1434,20 @@ RETURN:
 
 gboolean
 account_manager_handle_account_type_update_to_db_by_app_id(AccountManager *obj,
-                                                                                                                       GDBusMethodInvocation *invocation,
-                                                                                                                       GVariant *account_type_variant,
-                                                                                                                       const gchar *app_id,
-                                                                                                                       gint uid)
+                                                       GDBusMethodInvocation *invocation,
+                                                       GVariant *account_type_variant,
+                                                       const gchar *app_id,
+                                                       gint uid)
 {
        _INFO("account_manager_handle_account_type_update_to_db_by_app_id start");
        lifecycle_method_call_active();
 
        account_type_s* account_type = NULL;
+       guint pid = -1;
 
-       guint pid = _get_client_pid(invocation);
-
-       _INFO("client Id = [%u]", pid);
-
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _check_priviliege_account_write(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_write failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_db_open(1, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_global_db_open();
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, true);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -1982,17 +1473,7 @@ RETURN:
                account_manager_complete_account_type_update_to_db_by_app_id(obj, invocation);
        }
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        _account_type_free_account_type_with_items(account_type);
 
@@ -2004,38 +1485,18 @@ RETURN:
 
 gboolean
 account_manager_handle_account_type_delete_by_app_id(AccountManager *obj,
-                                                                                                                       GDBusMethodInvocation *invocation,
-                                                                                                                       const gchar *app_id,
-                                                                                                                       gint uid)
+                                               GDBusMethodInvocation *invocation,
+                                               const gchar *app_id,
+                                               gint uid)
 {
        _INFO("account_manager_handle_account_type_delete_by_app_id start");
        lifecycle_method_call_active();
 
-       guint pid = _get_client_pid(invocation);
-
-       _INFO("client Id = [%u]", pid);
-
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _check_priviliege_account_write(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_write failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_db_open(1, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
+       guint pid = -1;
 
-       return_code = _account_global_db_open();
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, true);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -2059,17 +1520,7 @@ RETURN:
                account_manager_complete_account_type_delete_by_app_id(obj, invocation);
        }
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        lifecycle_method_call_inactive();
        _INFO("account_manager_handle_account_type_delete_by_app_id end");
@@ -2079,9 +1530,9 @@ RETURN:
 
 gboolean
 account_manager_handle_account_type_query_label_by_app_id(AccountManager *obj,
-                                                                                                                       GDBusMethodInvocation *invocation,
-                                                                                                                       const gchar *app_id,
-                                                                                                                       gint uid)
+                                                       GDBusMethodInvocation *invocation,
+                                                       const gchar *app_id,
+                                                       gint uid)
 {
        _INFO("account_manager_handle_account_type_query_label_by_app_id start");
        lifecycle_method_call_active();
@@ -2089,25 +1540,11 @@ account_manager_handle_account_type_query_label_by_app_id(AccountManager *obj,
        GSList* label_list = NULL;
        GVariant* label_list_variant = NULL;
 
-       guint pid = _get_client_pid(invocation);
-
-       _INFO("client Id = [%u]", pid);
-
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_db_open(0, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
+       guint pid = -1;
 
-       return_code = _account_global_db_open();
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -2134,17 +1571,7 @@ RETURN:
                account_manager_complete_account_type_query_label_by_app_id(obj, invocation, label_list_variant);
        }
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        lifecycle_method_call_inactive();
        _INFO("account_manager_handle_account_type_query_label_by_app_id end");
@@ -2154,35 +1581,20 @@ RETURN:
 
 gboolean
 account_manager_handle_account_type_query_by_app_id(AccountManager *obj,
-                                                                                                                       GDBusMethodInvocation *invocation,
-                                                                                                                       const gchar *app_id,
-                                                                                                                       gint uid)
+                                               GDBusMethodInvocation *invocation,
+                                               const gchar *app_id,
+                                               gint uid)
 {
        _INFO("account_manager_handle_account_type_query_by_app_id start");
        lifecycle_method_call_active();
 
        account_type_s* account_type = NULL;
        GVariant* account_type_variant = NULL;
+       guint pid = -1;
 
-       guint pid = _get_client_pid(invocation);
-
-       _INFO("client Id = [%u]", pid);
-
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_db_open(0, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_global_db_open();
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -2215,17 +1627,7 @@ RETURN:
                account_manager_complete_account_type_query_by_app_id(obj, invocation, account_type_variant);
        }
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        _account_type_free_account_type_with_items(account_type);
 
@@ -2236,32 +1638,18 @@ RETURN:
 
 gboolean
 account_manager_handle_account_type_query_app_id_exist(AccountManager *obj,
-                                                                                                                       GDBusMethodInvocation *invocation,
-                                                                                                                       const gchar *app_id,
-                                                                                                                       gint uid)
+                                               GDBusMethodInvocation *invocation,
+                                               const gchar *app_id,
+                                               gint uid)
 {
        _INFO("account_manager_handle_account_type_query_app_id_exist start");
        lifecycle_method_call_active();
 
-       guint pid = _get_client_pid(invocation);
-
-       _INFO("client Id = [%u]", pid);
-
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_db_open(0, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
+       guint pid = -1;
 
-       return_code = _account_global_db_open();
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, false);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -2286,17 +1674,7 @@ RETURN:
                account_manager_complete_account_type_query_app_id_exist(obj, invocation);
        }
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        lifecycle_method_call_inactive();
        _INFO("account_manager_handle_account_type_query_app_id_exist end");
@@ -2306,40 +1684,20 @@ RETURN:
 
 gboolean
 account_manager_handle_account_update_to_db_by_id_ex(AccountManager *obj,
-                                                                                                                       GDBusMethodInvocation *invocation,
-                                                                                                                       GVariant *account_data,
-                                                                                                                       gint account_id,
-                                                                                                                       gint uid)
+                                               GDBusMethodInvocation *invocation,
+                                               GVariant *account_data,
+                                               gint account_id,
+                                               gint uid)
 {
        _INFO("account_manager_handle_account_update_to_db_by_id_ex start");
        lifecycle_method_call_active();
 
        account_s* account = NULL;
-       guint pid = _get_client_pid(invocation);
-
-       _INFO("client Id = [%u]", pid);
-
-       int return_code = _check_priviliege_account_read(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_read failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _check_priviliege_account_write(invocation);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_check_priviliege_account_write failed, ret = %d", return_code);
-               goto RETURN;
-       }
-
-       return_code = _account_db_open(1, pid, uid);
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_db_open() error, ret = %d", return_code);
-               goto RETURN;
-       }
+       guint pid = -1;
 
-       return_code = _account_global_db_open();
+       int return_code = _account_check_privilege_and_set_db_open(invocation, uid, &pid, true, true);
        if (return_code != _ACCOUNT_ERROR_NONE) {
-               _ERR("_account_global_db_open() error, ret = %d", return_code);
+               _ERR("_account_check_privilege_and_set_db_open failed, ret = %d", return_code);
                goto RETURN;
        }
 
@@ -2371,17 +1729,7 @@ RETURN:
                account_manager_complete_account_update_to_db_by_id_ex(obj, invocation);
        }
 
-       return_code = _account_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
-
-       return_code = _account_global_db_close();
-       if (return_code != _ACCOUNT_ERROR_NONE) {
-               ACCOUNT_DEBUG("_account_global_db_close() fail[%d]", return_code);
-               return_code = _ACCOUNT_ERROR_NONE;
-       }
+       _account_set_db_close(true);
 
        _account_free_account_with_items(account);
 
@@ -2390,110 +1738,109 @@ RETURN:
        return true;
 }
 
-static void
-on_bus_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
+static void on_bus_acquired(GDBusConnection *connection, const gchar *name, gpointer user_data)
 {
-               _INFO("on_bus_acquired [%s]", name);
+       _INFO("on_bus_acquired [%s]", name);
 
-               GDBusInterfaceSkeleton* interface = NULL;
-               account_mgr_server_obj = account_manager_skeleton_new();
-               if (account_mgr_server_obj == NULL) {
-                       _ERR("account_mgr_server_obj NULL!!");
-                       return;
-               }
+       GDBusInterfaceSkeleton* interface = NULL;
+       account_mgr_server_obj = account_manager_skeleton_new();
+       if (account_mgr_server_obj == NULL) {
+               _ERR("account_mgr_server_obj NULL!!");
+               return;
+       }
 
-               interface = G_DBUS_INTERFACE_SKELETON(account_mgr_server_obj);
-               if (!g_dbus_interface_skeleton_export(interface, connection, ACCOUNT_MGR_DBUS_PATH, NULL)) {
-                       _ERR("export failed!!");
-                       return;
-               }
+       interface = G_DBUS_INTERFACE_SKELETON(account_mgr_server_obj);
+       if (!g_dbus_interface_skeleton_export(interface, connection, ACCOUNT_MGR_DBUS_PATH, NULL)) {
+               _ERR("export failed!!");
+               return;
+       }
 
-               _INFO("connecting account signals start");
+       _INFO("connecting account signals start");
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_add",
-                                               G_CALLBACK(account_manager_account_add), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_add",
+                                       G_CALLBACK(account_manager_account_add), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_query_all",
-                                               G_CALLBACK(account_manager_account_query_all), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_query_all",
+                                       G_CALLBACK(account_manager_account_query_all), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_type_add",
-                                               G_CALLBACK(account_manager_account_type_add), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_type_add",
+                                       G_CALLBACK(account_manager_account_type_add), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_type_query_all",
-                                               G_CALLBACK(account_manager_account_type_query_all), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_type_query_all",
+                                       G_CALLBACK(account_manager_account_type_query_all), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_delete_from_db_by_id",
-                                               G_CALLBACK(account_manager_account_delete_from_db_by_id), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_delete_from_db_by_id",
+                                       G_CALLBACK(account_manager_account_delete_from_db_by_id), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_delete_from_db_by_user_name",
-                                               G_CALLBACK(account_manager_account_delete_from_db_by_user_name), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_delete_from_db_by_user_name",
+                                       G_CALLBACK(account_manager_account_delete_from_db_by_user_name), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_delete_from_db_by_package_name",
-                                               G_CALLBACK(account_manager_account_delete_from_db_by_package_name), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_delete_from_db_by_package_name",
+                                       G_CALLBACK(account_manager_account_delete_from_db_by_package_name), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_update_to_db_by_id",
-                                               G_CALLBACK(account_manager_account_update_to_db_by_id), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_update_to_db_by_id",
+                                       G_CALLBACK(account_manager_account_update_to_db_by_id), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_get_total_count_from_db",
-                                               G_CALLBACK(account_manager_account_get_total_count_from_db), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_get_total_count_from_db",
+                                       G_CALLBACK(account_manager_account_get_total_count_from_db), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_query_account_by_account_id",
-                                               G_CALLBACK(account_manager_handle_account_query_account_by_account_id), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_query_account_by_account_id",
+                                       G_CALLBACK(account_manager_handle_account_query_account_by_account_id), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_update_to_db_by_user_name",
-                                               G_CALLBACK(account_manager_handle_account_update_to_db_by_user_name), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_update_to_db_by_user_name",
+                                       G_CALLBACK(account_manager_handle_account_update_to_db_by_user_name), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_type_query_label_by_locale",
-                                               G_CALLBACK(account_manager_handle_account_type_query_label_by_locale), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_type_query_label_by_locale",
+                                       G_CALLBACK(account_manager_handle_account_type_query_label_by_locale), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_type_query_by_provider_feature",
-                                               G_CALLBACK(account_manager_handle_account_type_query_by_provider_feature), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_type_query_by_provider_feature",
+                                       G_CALLBACK(account_manager_handle_account_type_query_by_provider_feature), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_query_account_by_user_name",
-                                               G_CALLBACK(account_manager_handle_account_query_account_by_user_name), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_query_account_by_user_name",
+                                       G_CALLBACK(account_manager_handle_account_query_account_by_user_name), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_query_account_by_package_name",
-                                               G_CALLBACK(account_manager_handle_account_query_account_by_package_name), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_query_account_by_package_name",
+                                       G_CALLBACK(account_manager_handle_account_query_account_by_package_name), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_query_account_by_capability",
-                                               G_CALLBACK(account_manager_handle_account_query_account_by_capability), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_query_account_by_capability",
+                                       G_CALLBACK(account_manager_handle_account_query_account_by_capability), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_query_account_by_capability_type",
-                                               G_CALLBACK(account_manager_handle_account_query_account_by_capability_type), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_query_account_by_capability_type",
+                                       G_CALLBACK(account_manager_handle_account_query_account_by_capability_type), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_query_capability_by_account_id",
-                                               G_CALLBACK(account_manager_handle_account_query_capability_by_account_id), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_query_capability_by_account_id",
+                                       G_CALLBACK(account_manager_handle_account_query_capability_by_account_id), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_update_sync_status_by_id",
-                                               G_CALLBACK(account_manager_handle_account_update_sync_status_by_id), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_update_sync_status_by_id",
+                                       G_CALLBACK(account_manager_handle_account_update_sync_status_by_id), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_type_query_provider_feature_by_app_id",
-                                               G_CALLBACK(account_manager_handle_account_type_query_provider_feature_by_app_id), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_type_query_provider_feature_by_app_id",
+                                       G_CALLBACK(account_manager_handle_account_type_query_provider_feature_by_app_id), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_type_query_supported_feature",
-                                               G_CALLBACK(account_manager_handle_account_type_query_supported_feature), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_type_query_supported_feature",
+                                       G_CALLBACK(account_manager_handle_account_type_query_supported_feature), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_type_update_to_db_by_app_id",
-                                               G_CALLBACK(account_manager_handle_account_type_update_to_db_by_app_id), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_type_update_to_db_by_app_id",
+                                       G_CALLBACK(account_manager_handle_account_type_update_to_db_by_app_id), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_type_delete_by_app_id",
-                                               G_CALLBACK(account_manager_handle_account_type_delete_by_app_id), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_type_delete_by_app_id",
+                                       G_CALLBACK(account_manager_handle_account_type_delete_by_app_id), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_type_query_label_by_app_id",
-                                               G_CALLBACK(account_manager_handle_account_type_query_label_by_app_id), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_type_query_label_by_app_id",
+                                       G_CALLBACK(account_manager_handle_account_type_query_label_by_app_id), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_type_query_by_app_id",
-                                               G_CALLBACK(account_manager_handle_account_type_query_by_app_id), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_type_query_by_app_id",
+                                       G_CALLBACK(account_manager_handle_account_type_query_by_app_id), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_type_query_app_id_exist",
-                                               G_CALLBACK(account_manager_handle_account_type_query_app_id_exist), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_type_query_app_id_exist",
+                                       G_CALLBACK(account_manager_handle_account_type_query_app_id_exist), NULL);
 
-               g_signal_connect(account_mgr_server_obj, "handle_account_update_to_db_by_id_ex",
-                                               G_CALLBACK(account_manager_handle_account_update_to_db_by_id_ex), NULL);
+       g_signal_connect(account_mgr_server_obj, "handle_account_update_to_db_by_id_ex",
+                                       G_CALLBACK(account_manager_handle_account_update_to_db_by_id_ex), NULL);
 
-               _INFO("connecting account signals end");
+       _INFO("connecting account signals end");
 
-               _INFO("on_bus_acquired end [%s]", name);
+       _INFO("on_bus_acquired end [%s]", name);
 }
 
 void terminate_main_loop()
@@ -2522,13 +1869,13 @@ static bool _initialize_dbus()
        _INFO("__initialize_dbus Enter");
 
        owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
-                                                       "org.tizen.account.manager",
-                                                       G_BUS_NAME_OWNER_FLAGS_NONE,
-                                                       on_bus_acquired,
-                                                       on_name_acquired,
-                                                       on_name_lost,
-                                                       NULL,
-                                                       NULL);
+                               "org.tizen.account.manager",
+                               G_BUS_NAME_OWNER_FLAGS_NONE,
+                               on_bus_acquired,
+                               on_name_acquired,
+                               on_name_lost,
+                               NULL,
+                               NULL);
 
        _INFO("owner_id=[%d]", owner_id);