<method name="account_add">
<arg type="s" name="account_db_path" direction="in" />
<arg type="a{sv}" name="account_data" direction="in" />
- <arg type="s" name="cookie" direction="in" />
<arg type="i" name="account_db_id" direction="out" />
</method>
<method name="account_type_add">
<arg type="s" name="account_db_path" direction="in" />
<arg type="a{sv}" name="account_type_data" direction="in" />
- <arg type="s" name="cookie" direction="in" />
<arg type="i" name="account_type_db_id" direction="out" />
</method>
<method name="account_query_all">
<arg type="s" name="account_db_path" direction="in" />
- <arg type="s" name="cookie" direction="in" />
<arg type="aa{sv}" name="account_data" direction="out" />
</method>
<method name="account_type_query_all">
<arg type="s" name="account_db_path" direction="in" />
- <arg type="s" name="cookie" direction="in" />
<arg type="aa{sv}" name="account_type_data" direction="out" />
</method>
<method name="account_delete_from_db_by_id">
<arg type="s" name="account_db_path" direction="in" />
<arg type="i" name="account_db_id" direction="in" />
- <arg type="s" name="cookie" direction="in" />
</method>
<method name="account_delete_from_db_by_user_name">
<arg type="s" name="account_db_path" direction="in" />
<arg type="s" name="user_name" direction="in" />
<arg type="s" name="package_name" direction="in" />
- <arg type="s" name="cookie" direction="in" />
</method>
<method name="account_delete_from_db_by_package_name">
<arg type="s" name="account_db_path" direction="in" />
<arg type="s" name="package_name" direction="in" />
- <arg type="b" name="permission" direction="in" />
- <arg type="s" name="cookie" direction="in" />
+ <arg type="b" name="permission" direction="in" />
</method>
<method name="account_update_to_db_by_id">
<arg type="s" name="account_db_path" direction="in" />
<arg type="a{sv}" name="account_data" direction="in" />
<arg type="i" name="account_id" direction="in" />
- <arg type="s" name="cookie" direction="in" />
</method>
<method name="account_get_total_count_from_db">
<arg type="s" name="account_db_path" direction="in" />
<arg type="b" name="include_hidden" direction="in" />
- <arg type="s" name="cookie" direction="in" />
<arg type="i" name="count" direction="out" />
</method>
<method name="account_query_account_by_account_id">
<arg type="s" name="account_db_path" direction="in" />
<arg type="i" name="account_db_id" direction="in" />
- <arg type="s" name="cookie" direction="in" />
<arg type="a{sv}" name="account_data" direction="out" />
</method>
<method name="account_update_to_db_by_user_name">
<arg type="a{sv}" name="account_data" direction="in" />
<arg type="s" name="user_name" direction="in" />
<arg type="s" name="package_name" direction="in" />
- <arg type="s" name="cookie" direction="in" />
</method>
<method name="account_type_query_label_by_locale">
<arg type="s" name="account_db_path" direction="in" />
<arg type="s" name="app_id" direction="in" />
<arg type="s" name="locale" direction="in" />
- <arg type="s" name="cookie" direction="in" />
<arg type="s" name="label_name" direction="out" />
</method>
<method name="account_type_query_by_provider_feature">
<arg type="s" name="account_db_path" direction="in" />
<arg type="s" name="key" direction="in" />
- <arg type="s" name="cookie" direction="in" />
<arg type="aa{sv}" name="account_type_list_data" direction="out" />
</method>
<method name="account_query_account_by_user_name">
<arg type="s" name="account_db_path" direction="in" />
<arg type="s" name="user_name" direction="in" />
- <arg type="s" name="cookie" direction="in" />
<arg type="aa{sv}" name="account_list_data" direction="out" />
</method>
<method name="account_query_account_by_package_name">
<arg type="s" name="account_db_path" direction="in" />
<arg type="s" name="package_name" direction="in" />
- <arg type="s" name="cookie" direction="in" />
<arg type="aa{sv}" name="account_list_data" direction="out" />
</method>
<method name="account_query_account_by_capability">
<arg type="s" name="account_db_path" direction="in" />
<arg type="s" name="capability_type" direction="in" />
<arg type="i" name="capability_value" direction="in" />
- <arg type="s" name="cookie" direction="in" />
<arg type="aa{sv}" name="account_list_data" direction="out" />
</method>
<method name="account_query_account_by_capability_type">
<arg type="s" name="account_db_path" direction="in" />
<arg type="s" name="capability_type" direction="in" />
- <arg type="s" name="cookie" direction="in" />
<arg type="aa{sv}" name="account_list_data" direction="out" />
</method>
<method name="account_query_capability_by_account_id">
<arg type="s" name="account_db_path" direction="in" />
<arg type="i" name="account_id" direction="in" />
- <arg type="s" name="cookie" direction="in" />
<arg type="aa{sv}" name="account_list_data" direction="out" />
</method>
<method name="account_update_sync_status_by_id">
<arg type="s" name="account_db_path" direction="in" />
<arg type="i" name="account_db_id" direction="in" />
<arg type="i" name="sync_status" direction="in" />
- <arg type="s" name="cookie" direction="in" />
</method>
<method name="account_type_query_provider_feature_by_app_id">
<arg type="s" name="account_db_path" direction="in" />
<arg type="s" name="app_id" direction="in" />
- <arg type="s" name="cookie" direction="in" />
<arg type="a(ss)" name="feature_list_data" direction="out" />
</method>
<method name="account_type_query_supported_feature">
<arg type="s" name="account_db_path" direction="in" />
<arg type="s" name="app_id" direction="in" />
<arg type="s" name="capability" direction="in" />
- <arg type="s" name="cookie" direction="in" />
<arg type="i" name="is_supported" direction="out" />
</method>
<method name="account_type_update_to_db_by_app_id">
<arg type="s" name="account_db_path" direction="in" />
<arg type="a{sv}" name="account_type_variant" direction="in" />
<arg type="s" name="app_id" direction="in" />
- <arg type="s" name="cookie" direction="in" />
</method>
<method name="account_type_delete_by_app_id">
<arg type="s" name="account_db_path" direction="in" />
<arg type="s" name="app_id" direction="in" />
- <arg type="s" name="cookie" direction="in" />
</method>
<method name="account_type_query_label_by_app_id">
<arg type="s" name="account_db_path" direction="in" />
<arg type="s" name="app_id" direction="in" />
- <arg type="s" name="cookie" direction="in" />
<arg type="a(sss)" name="label_list_variant" direction="out" />
</method>
<method name="account_type_query_by_app_id">
<arg type="s" name="account_db_path" direction="in" />
<arg type="s" name="app_id" direction="in" />
- <arg type="s" name="cookie" direction="in" />
<arg type="a{sv}" name="account_type_variant" direction="out" />
</method>
<method name="account_type_query_app_id_exist">
<arg type="s" name="account_db_path" direction="in" />
<arg type="s" name="app_id" direction="in" />
- <arg type="s" name="cookie" direction="in" />
</method>
<method name="account_update_to_db_by_id_ex">
<arg type="s" name="account_db_path" direction="in" />
<arg type="a{sv}" name="account_variant" direction="in" />
<arg type="i" name="account_id" direction="in" />
- <arg type="s" name="cookie" direction="in" />
</method>
</interface>
</node>
#define _DEFAULT_SOURCE
#include <stdio.h>
#include <stdlib.h>
-#include <stdbool.h>
-#include <time.h>
#include <signal.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <unistd.h>
-#include <sys/timerfd.h>
-#include <poll.h>
-#include <stdint.h>
-#include <dbus/dbus.h>
#include <glib.h>
#if !GLIB_CHECK_VERSION (2, 31, 0)
#include <glib/gmacros.h>
#endif
-#include <security-server.h>
+#include <cynara-client.h>
+#include <cynara-session.h>
+#include <cynara-creds-gdbus.h>
#include <gio/gio.h>
+
#include "dbg.h"
#include "account-server-db.h"
#include "account_ipc_marshal.h"
#include "account-private.h"
#include "account-error.h"
-#define _CHECK_READ_LABEL "libaccounts-svc::check_read"
-#define _DB_LABEL "libaccounts-svc::db"
-#define _READ_LABEL "r"
-#define _WRITE_LABEL "w"
-#define _READ_WRITE_LABEL "rw"
+#define _PRIVILEGE_ACCOUNT_READ "http://tizen.org/privilege/account.read"
+#define _PRIVILEGE_ACCOUNT_WRITE "http://tizen.org/privilege/account.write"
#define ACCOUNT_MGR_DBUS_PATH "/org/tizen/account/manager"
static guint owner_id = 0;
GDBusObjectManagerServer *account_mgr_server_mgr = NULL;
static AccountManager* account_mgr_server_obj = NULL;
+
+static cynara *p_cynara;
+
//static gboolean has_owner = FALSE;
// pid-mode, TODO: make it sessionId-mode, were session id is mix of pid and some rand no, so that
return (GQuark) quark_volatile;
}
-static int _check_privilege_by_cookie(char *e_cookie, const char *label, const char *access_perm, bool check_root, int pid) {
- guchar *cookie = NULL;
- gsize size = 0;
- int retval = 0;
- char buf[128] = {0,};
- FILE *fp = NULL;
- char title[128] = {0,};
- int uid = -1;
-
- if (check_root) {
- // Gets the userID from /proc/pid/status to check if the process is the root or not.
- snprintf(buf, sizeof(buf), "/proc/%d/status", pid);
- fp = fopen(buf, "r");
- if(fp) {
- while (fgets(buf, sizeof(buf), fp) != NULL) {
- if(strncmp(buf, "Uid:", 4) == 0) {
- sscanf(buf, "%s %d", title, &uid);
- break;
- }
- }
- fclose(fp);
- }
+static int __check_privilege_by_cynara(const char *client, const char *session, const char *user, const char *privilege)
+{
+ int ret;
+ char err_buf[128] = {0,};
+
+ ret = cynara_check(p_cynara, client, session, user, privilege);
+ switch (ret) {
+ case CYNARA_API_ACCESS_ALLOWED:
+ _DBG("cynara_check success");
+ return ACCOUNT_ERROR_NONE;
+ case CYNARA_API_ACCESS_DENIED:
+ _ERR("cynara_check permission deined, privilege=%s, error = CYNARA_API_ACCESS_DENIED", privilege);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ default:
+ cynara_strerror(ret, err_buf, sizeof(err_buf));
+ _ERR("cynara_check error : %s, privilege=%s, ret = %d", err_buf, privilege, ret);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+}
+
+int __get_information_for_cynara_check(GDBusMethodInvocation *invocation, char **client, char **user, char **session)
+{
+ GDBusConnection *gdbus_conn = NULL;
+ char* sender = NULL;
+ int ret = -1;
- _INFO("uid : %d", uid);
+ //get GDBusConnection
+ gdbus_conn = g_dbus_method_invocation_get_connection(invocation);
+ if(gdbus_conn == NULL)
+ {
+ _ERR("g_dbus_method_invocation_get_connection failed");
+ return -1;
}
- if (uid != 0) { // Checks the cookie only when the process is not the root
- cookie = g_base64_decode(e_cookie, &size);
- if (cookie == NULL) {
- _ERR("Unable to decode cookie!!!");
- return ACCOUNT_ERROR_PERMISSION_DENIED;
- }
+ //get sender(unique_name)
+ sender = (char*) g_dbus_method_invocation_get_sender(invocation);
+ if (sender == NULL)
+ {
+ _ERR("g_dbus_method_invocation_get_sender failed");
+ return -1;
+ }
- retval = security_server_check_privilege_by_cookie((const char *)cookie, label, access_perm);
- g_free(cookie);
+ ret = cynara_creds_gdbus_get_user(gdbus_conn, sender, CLIENT_METHOD_SMACK, user);
+ if (ret != CYNARA_API_SUCCESS)
+ {
+ _ERR("cynara_creds_gdbus_get_user failed, ret = %d", ret);
+ return -1;
+ }
- if (retval < 0) {
- if (retval == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) {
- _ERR("Access to account-svcd has been denied by smack.");
- }
- _ERR("Error has occurred in security_server_check_privilege_by_cookie() : %d.", retval);
- return ACCOUNT_ERROR_PERMISSION_DENIED;
- }
+ ret = cynara_creds_gdbus_get_client(gdbus_conn, sender, CLIENT_METHOD_SMACK, client);
+ if (ret != CYNARA_API_SUCCESS)
+ {
+ _ERR("cynara_creds_gdbus_get_client failed, ret = %d", ret);
+ return -1;
}
- _INFO("The process(%d) was authenticated successfully.", pid);
+ guint pid = _get_client_pid(invocation);
+ _INFO("client Id = [%u]", pid);
+
+ *session = cynara_session_from_pid(pid);
+ if (*session == NULL)
+ {
+ _ERR("cynara_session_from_pid failed");
+ return -1;
+ }
return ACCOUNT_ERROR_NONE;
}
-gboolean account_manager_account_add(AccountManager *obj, GDBusMethodInvocation *invocation, gchar* account_db_path, GVariant* account_data, gchar *cookie, gpointer user_data)
+int _check_privilege(GDBusMethodInvocation *invocation, const char* privilege)
+{
+ int ret = -1;
+ char *client = NULL;
+ char *session = NULL;
+ char *user = NULL;
+
+ ret = __get_information_for_cynara_check(invocation, &client, &user, &session);
+ if ( ret != ACCOUNT_ERROR_NONE )
+ {
+ _ERR("__get_information_for_cynara_check failed");
+ g_free(client);
+ g_free(user);
+ _ACCOUNT_FREE(session);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+
+ ret = __check_privilege_by_cynara(client, session, user, privilege);
+ if ( ret != ACCOUNT_ERROR_NONE )
+ {
+ _ERR("__check_privilege_by_cynara failed, ret = %d", ret);
+ g_free(client);
+ g_free(user);
+ _ACCOUNT_FREE(session);
+ return ACCOUNT_ERROR_PERMISSION_DENIED;
+ }
+ g_free(client);
+ g_free(user);
+ _ACCOUNT_FREE(session);
+ return ACCOUNT_ERROR_NONE;
+}
+
+int _check_priviliege_account_read(GDBusMethodInvocation *invocation)
+{
+ return _check_privilege(invocation, _PRIVILEGE_ACCOUNT_READ);
+}
+
+int _check_priviliege_account_write(GDBusMethodInvocation *invocation)
+{
+ return _check_privilege(invocation, _PRIVILEGE_ACCOUNT_WRITE);
+}
+
+gboolean account_manager_account_add(AccountManager *obj, GDBusMethodInvocation *invocation, gchar* account_db_path, GVariant* account_data, gpointer user_data)
{
_INFO("account_manager_account_add start");
int db_id = -1;
guint pid = _get_client_pid(invocation);
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _DB_LABEL, _READ_WRITE_LABEL, true, 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 true;
}
-gboolean account_manager_account_query_all(AccountManager *obj, GDBusMethodInvocation *invocation, gchar *account_db_path, gchar *cookie)
+gboolean account_manager_account_query_all(AccountManager *obj, GDBusMethodInvocation *invocation, gchar *account_db_path)
{
_INFO("account_manager_account_query_all start");
guint pid = _get_client_pid(invocation);
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _CHECK_READ_LABEL, _READ_LABEL, true, 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 true;
}
-gboolean account_manager_account_type_query_all(AccountManager *obj, GDBusMethodInvocation *invocation, gchar *account_db_path, gchar *cookie)
+gboolean account_manager_account_type_query_all(AccountManager *obj, GDBusMethodInvocation *invocation, gchar *account_db_path)
{
_INFO("account_manager_account_query_all start");
guint pid = _get_client_pid(invocation);
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _CHECK_READ_LABEL, _READ_LABEL, true, 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 true;
}
-gboolean account_manager_account_type_add(AccountManager *obj, GDBusMethodInvocation *invocation, gchar *account_db_path, GVariant *account_type_data, gchar *cookie, gpointer user_data)
+gboolean account_manager_account_type_add(AccountManager *obj, GDBusMethodInvocation *invocation, gchar *account_db_path, GVariant *account_type_data, gpointer user_data)
{
int db_id = -1;
guint pid = _get_client_pid(invocation);
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _DB_LABEL, _READ_WRITE_LABEL, true, 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;
}
gboolean account_manager_account_delete_from_db_by_id(AccountManager *object,
GDBusMethodInvocation *invocation,
gchar *account_db_path,
- gint account_db_id, gchar *cookie)
+ gint account_db_id)
{
_INFO("account_manager_account_delete_from_db_by_id start");
guint pid = _get_client_pid(invocation);
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _DB_LABEL, _READ_WRITE_LABEL, true, 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;
}
GDBusMethodInvocation *invocation,
gchar *account_db_path,
const gchar *user_name,
- const gchar *package_name, gchar *cookie)
+ const gchar *package_name)
{
_INFO("account_manager_account_delete_from_db_by_user_name start");
guint pid = _get_client_pid(invocation);
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _DB_LABEL, _READ_WRITE_LABEL, true, 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;
}
gboolean account_manager_account_delete_from_db_by_package_name(AccountManager *object,
GDBusMethodInvocation *invocation,
gchar *account_db_path,
- const gchar *package_name, gboolean permission, gchar *cookie)
+ const gchar *package_name, gboolean permission)
{
_INFO("account_manager_account_delete_from_db_by_package_name start");
guint pid = _get_client_pid(invocation);
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _DB_LABEL, _READ_WRITE_LABEL, true, 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;
}
GDBusMethodInvocation *invocation,
gchar *account_db_path,
GVariant *account_data,
- gint account_id, gchar *cookie)
+ gint account_id)
{
_INFO("account_manager_account_update_to_db_by_id start");
guint pid = _get_client_pid(invocation);
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _DB_LABEL, _READ_WRITE_LABEL, true, 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;
}
gchar *account_db_path,
GVariant *account_data,
const gchar *user_name,
- const gchar *package_name, gchar *cookie)
+ const gchar *package_name)
{
_INFO("account_manager_handle_account_update_to_db_by_user_name start");
guint pid = _get_client_pid(invocation);
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _DB_LABEL, _READ_WRITE_LABEL, true, 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;
}
GDBusMethodInvocation *invocation,
gchar *account_db_path,
const gchar *app_id,
- const gchar *locale, gchar *cookie)
+ const gchar *locale)
{
_INFO("account_manager_handle_account_type_query_label_by_locale start");
guint pid = _get_client_pid(invocation);
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _CHECK_READ_LABEL, _READ_LABEL, true, 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;
}
gboolean
account_manager_handle_account_type_query_by_provider_feature(AccountManager *obj,
GDBusMethodInvocation *invocation,
- gchar *account_db_path, const gchar *key, gchar *cookie)
+ gchar *account_db_path, const gchar *key)
{
_INFO("account_manager_handle_account_type_query_by_provider_feature start");
GVariant* account_type_list_variant = NULL;
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _CHECK_READ_LABEL, _READ_LABEL, true, 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 true;
}
-gboolean account_manager_account_get_total_count_from_db(AccountManager *object, GDBusMethodInvocation *invocation, gchar *account_db_path, gboolean include_hidden, gchar *cookie)
+gboolean account_manager_account_get_total_count_from_db(AccountManager *object, GDBusMethodInvocation *invocation, gchar *account_db_path, gboolean include_hidden)
{
_INFO("account_manager_account_get_total_count_from_db start");
guint pid = _get_client_pid(invocation);
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _CHECK_READ_LABEL, _READ_LABEL, true, 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;
}
}
gboolean account_manager_handle_account_query_account_by_account_id(AccountManager *object, GDBusMethodInvocation *invocation,
- gchar *account_db_path, gint account_db_id, gchar *cookie)
+ gchar *account_db_path, gint account_db_id)
{
_INFO("account_manager_handle_account_query_account_by_account_id start");
GVariant* account_variant = NULL;
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _CHECK_READ_LABEL, _READ_LABEL, true, 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;
}
gboolean
account_manager_handle_account_query_account_by_user_name(AccountManager *obj,
GDBusMethodInvocation *invocation,
- gchar *account_db_path, const gchar *user_name, gchar *cookie)
+ gchar *account_db_path, const gchar *user_name)
{
_INFO("account_manager_handle_account_query_account_by_user_name start");
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _CHECK_READ_LABEL, _READ_LABEL, true, 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;
}
gboolean
account_manager_handle_account_query_account_by_package_name(AccountManager *obj,
GDBusMethodInvocation *invocation,
- gchar *account_db_path, const gchar *package_name, gchar *cookie)
+ gchar *account_db_path, const gchar *package_name)
{
_INFO("account_manager_handle_account_query_account_by_package_name start");
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _CHECK_READ_LABEL, _READ_LABEL, true, 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;
}
GDBusMethodInvocation *invocation,
gchar *account_db_path,
const gchar *capability_type,
- gint capability_value, gchar *cookie)
+ gint capability_value)
{
_INFO("account_manager_handle_account_query_account_by_capability start");
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _CHECK_READ_LABEL, _READ_LABEL, true, 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;
}
account_manager_handle_account_query_account_by_capability_type(AccountManager *obj,
GDBusMethodInvocation *invocation,
gchar *account_db_path,
- const gchar *capability_type, gchar *cookie)
+ const gchar *capability_type)
{
_INFO("account_manager_handle_account_query_account_by_capability_type start");
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _CHECK_READ_LABEL, _READ_LABEL, true, 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;
}
account_manager_handle_account_query_capability_by_account_id(AccountManager *obj,
GDBusMethodInvocation *invocation,
gchar *account_db_path,
- const int account_id, gchar *cookie)
+ const int account_id)
{
_INFO("account_manager_handle_account_query_capability_by_account_id start");
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _CHECK_READ_LABEL, _READ_LABEL, true, 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, (const char*)account_db_path);
if (return_code != ACCOUNT_ERROR_NONE)
{
GDBusMethodInvocation *invocation,
gchar *account_db_path,
const int account_db_id,
- const int sync_status, gchar *cookie)
+ const int sync_status)
{
_INFO("account_manager_handle_account_update_sync_status_by_id start");
guint pid = _get_client_pid(invocation);
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _DB_LABEL, _READ_WRITE_LABEL, true, 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;
}
gboolean account_manager_handle_account_type_query_provider_feature_by_app_id(AccountManager *obj,
GDBusMethodInvocation *invocation,
gchar *account_db_path,
- const gchar* app_id, gchar *cookie)
+ const gchar* app_id)
{
GSList* feature_record_list = NULL;
GVariant* feature_record_list_variant = NULL;
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _CHECK_READ_LABEL, _READ_LABEL, true, 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;
}
GDBusMethodInvocation *invocation,
gchar *account_db_path,
const gchar* app_id,
- const gchar* capability, gchar *cookie)
+ const gchar* capability)
{
int is_supported = 0;
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _CHECK_READ_LABEL, _READ_LABEL, true, 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;
}
GDBusMethodInvocation *invocation,
gchar *account_db_path,
GVariant *account_type_variant,
- const gchar *app_id, gchar *cookie)
+ const gchar *app_id)
{
_INFO("account_manager_handle_account_type_update_to_db_by_app_id start");
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _DB_LABEL, _READ_WRITE_LABEL, true, 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;
}
gboolean account_manager_handle_account_type_delete_by_app_id (AccountManager *obj,
GDBusMethodInvocation *invocation,
gchar *account_db_path,
- const gchar *app_id, gchar *cookie)
+ const gchar *app_id)
{
_INFO("account_manager_handle_account_type_delete_by_app_id start");
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _DB_LABEL, _READ_WRITE_LABEL, true, 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;
}
gboolean account_manager_handle_account_type_query_label_by_app_id (AccountManager *obj,
GDBusMethodInvocation *invocation,
gchar *account_db_path,
- const gchar *app_id, gchar *cookie)
+ const gchar *app_id)
{
_INFO("account_manager_handle_account_type_query_label_by_app_id start");
GSList* label_list = NULL;
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _CHECK_READ_LABEL, _READ_LABEL, true, 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;
}
gboolean account_manager_handle_account_type_query_by_app_id (AccountManager *obj,
GDBusMethodInvocation *invocation,
gchar *account_db_path,
- const gchar *app_id, gchar *cookie)
+ const gchar *app_id)
{
_INFO("account_manager_handle_account_type_query_by_app_id start");
GVariant* account_type_variant = NULL;
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _CHECK_READ_LABEL, _READ_LABEL, true, 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;
}
gboolean account_manager_handle_account_type_query_app_id_exist (AccountManager *obj,
GDBusMethodInvocation *invocation,
- gchar *account_db_path, const gchar *app_id, gchar *cookie)
+ gchar *account_db_path, const gchar *app_id)
{
_INFO("account_manager_handle_account_type_query_app_id_exist start");
guint pid = _get_client_pid(invocation);
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _CHECK_READ_LABEL, _READ_LABEL, true, 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;
}
GDBusMethodInvocation *invocation,
gchar *account_db_path,
GVariant *account_data,
- gint account_id, gchar *cookie)
+ gint account_id)
{
_INFO("account_manager_handle_account_update_to_db_by_id_ex start");
guint pid = _get_client_pid(invocation);
_INFO("client Id = [%u]", pid);
- int return_code = _check_privilege_by_cookie(cookie, _DB_LABEL, _READ_WRITE_LABEL, true, 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;
}
if(owner_id == 0)
{
_INFO("gdbus own failed!!");
- return false;
+ return false;
}
_INFO("g_bus_own_name SUCCESS");
return true;
}
+
+
static void _initialize()
{
#if !GLIB_CHECK_VERSION(2,35,0)
g_type_init();
#endif
+ int ret = -1;
if (_initialize_dbus() == false)
{ /* because dbus's initialize
_ERR("DBUS Initialization Failed");
exit(1);
}
+
+ ret = cynara_initialize(&p_cynara, NULL);
+ if(ret != CYNARA_API_SUCCESS) {
+ _ERR("CYNARA Initialization fail");
+ exit(1);
+ }
}
int main()
g_main_loop_run(mainloop);
+ cynara_finish(p_cynara);
+
_INFO("Ending Accounts SVC");
return 0;
}