#include <cynara-client.h>
#include <cynara-error.h>
#include <cynara-session.h>
+#include <pthread.h>
#include "vc_cmd_db.h"
#include "vc_config_mgr.h"
static int g_privilege_allowed = -1;
static cynara *p_cynara = NULL;
+static pthread_mutex_t g_cynara_mutex = PTHREAD_MUTEX_INITIALIZER;
static bool g_err_callback_status = false;
static int __check_privilege_initialize()
{
+ pthread_mutex_lock(&g_cynara_mutex);
+
int ret = cynara_initialize(&p_cynara, NULL);
- if (CYNARA_API_SUCCESS != ret)
- SLOG(LOG_ERROR, TAG_VCM, "[ERROR] fail to initialize");
+ if (NULL == p_cynara || CYNARA_API_SUCCESS != ret) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] fail to initialize(%d)", ret);
+ pthread_mutex_unlock(&g_cynara_mutex);
+ return ret;
+ }
+
+ SLOG(LOG_ERROR, TAG_VCM, "[DEBUG] success to initialize cynara");
+ pthread_mutex_unlock(&g_cynara_mutex);
return ret == CYNARA_API_SUCCESS;
}
static int __check_privilege(const char* uid, const char * privilege)
{
+ pthread_mutex_lock(&g_cynara_mutex);
FILE *fp = NULL;
char label_path[1024] = "/proc/self/attr/current";
char smack_label[1024] = {'\0',};
if (!p_cynara) {
+ SLOG(LOG_ERROR, TAG_VCM, "[ERROR] p_cynara is NULL");
+ pthread_mutex_unlock(&g_cynara_mutex);
return false;
}
pid_t pid = getpid();
char *session = cynara_session_from_pid(pid);
int ret = cynara_check(p_cynara, smack_label, session, uid, privilege);
- SLOG(LOG_DEBUG, TAG_VCM, "[Client]cynara_check returned %d(%s)", ret, (CYNARA_API_ACCESS_ALLOWED == ret) ? "Allowed" : "Denied");
+ SLOG(LOG_DEBUG, TAG_VCM, "[Client]cynara_check returned %d(%s), p_cynara(%p), label(%s), session(%s), uid(%s), priv(%s)", ret, (CYNARA_API_ACCESS_ALLOWED == ret) ? "Allowed" : "Denied", p_cynara, smack_label, session, uid, privilege);
if (session)
free(session);
- if (ret != CYNARA_API_ACCESS_ALLOWED)
+ if (ret != CYNARA_API_ACCESS_ALLOWED) {
+ pthread_mutex_unlock(&g_cynara_mutex);
return false;
+ }
+ pthread_mutex_unlock(&g_cynara_mutex);
return true;
}
static void __check_privilege_deinitialize()
{
- if (p_cynara)
+ pthread_mutex_lock(&g_cynara_mutex);
+ if (p_cynara) {
+ SLOG(LOG_ERROR, TAG_VCM, "[DEBUG] cynara finish");
cynara_finish(p_cynara);
+ }
p_cynara = NULL;
+ pthread_mutex_unlock(&g_cynara_mutex);
}
static int __vc_mgr_check_privilege()
__check_privilege_deinitialize();
}
+ g_privilege_allowed = 1;
return VC_ERROR_NONE;
}
if (0 != __vc_mgr_get_feature_enabled()) {
- SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported");
+ SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] not supported");
return VC_ERROR_NOT_SUPPORTED;
}
vc_mgr_client_use_callback(g_vc_m);
service_changed_callback(previous_service_state, service_state, user_data);
vc_mgr_client_not_use_callback(g_vc_m);
- SLOG(LOG_DEBUG, TAG_VCM, "Service state changed callback is called");
+ SLOG(LOG_INFO, TAG_VCM, "Service state changed callback is called");
} else {
SLOG(LOG_WARN, TAG_VCM, "[WARNING] Service state changed callback is null");
}
vc_mgr_client_use_callback(g_vc_m);
changed_callback(before_state, current_state, user_data);
vc_mgr_client_not_use_callback(g_vc_m);
- SLOG(LOG_DEBUG, TAG_VCM, "State changed callback is called");
+ SLOG(LOG_INFO, TAG_VCM, "State changed callback is called");
} else {
SLOG(LOG_WARN, TAG_VCM, "[WARNING] State changed callback is null");
}
return EINA_FALSE;
}
- SLOG(LOG_DEBUG, TAG_VCM, "@@@");
+ SLOG(LOG_ERROR, TAG_VCM, "@@@");
return EINA_FALSE;
}
ret = vc_mgr_dbus_request_hello();
if (ret == 0) {
- SLOG(LOG_DEBUG, TAG_VCM, "Success to request hello. retry count(%d)", retry_count);
+ SLOG(LOG_INFO, TAG_VCM, "Success to request hello. retry count(%d)", retry_count);
break;
} else {
retry_count++;
static void __end_prepare_thread(void *data, Ecore_Thread *thread)
{
- SLOG(LOG_DEBUG, TAG_VCM, "@@@ End prepare thread");
+ SLOG(LOG_INFO, TAG_VCM, "@@@ End prepare thread");
}
int vc_mgr_prepare(void)
SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] Prepare");
if (0 != __vc_mgr_get_feature_enabled()) {
- SLOG(LOG_DEBUG, TAG_VCM, "@@@ [Manager] not supported");
+ SLOG(LOG_ERROR, TAG_VCM, "@@@ [Manager] not supported");
return VC_ERROR_NOT_SUPPORTED;
}
return VC_ERROR_INVALID_STATE;
}
+ ecore_thread_main_loop_begin();
ecore_thread_run(__start_prepare_thread, __end_prepare_thread, NULL, NULL);
+ ecore_thread_main_loop_end();
SLOG(LOG_DEBUG, TAG_VCM, "@@@");
snprintf(if_name, 64, "%s", VC_MANAGER_SERVICE_INTERFACE);
if (dbus_message_is_method_call(msg, if_name, VCD_MANAGER_METHOD_HELLO)) {
- SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get Hello");
+ SLOG(LOG_INFO, TAG_VCM, "@@@ Get Hello");
int pid = 0;
int response = -1;
if (!dbus_connection_send(g_m_conn_listener, reply, NULL))
SLOG(LOG_ERROR, TAG_VCM, "@@ vc get hello : fail to send reply");
else
- SLOG(LOG_DEBUG, TAG_VCM, "@@ vc get hello : result(%d)", response);
+ SLOG(LOG_INFO, TAG_VCM, "@@ vc get hello : result(%d)", response);
dbus_connection_flush(g_m_conn_listener);
dbus_message_unref(reply);
dbus_error_free(&err);
}
- SLOG(LOG_DEBUG, TAG_VCM, "@@ state changed : %d", state);
+ SLOG(LOG_INFO, TAG_VCM, "@@ state changed : %d", state);
__vc_mgr_cb_service_state(state);
} /* VCD_MANAGER_METHOD_ALL_RESULT */
else if (dbus_message_is_signal(msg, if_name, VCD_MANAGER_METHOD_ERROR)) {
- SLOG(LOG_DEBUG, TAG_VCM, "@@@ Get Error");
+ SLOG(LOG_INFO, TAG_VCM, "@@@ Get Error");
int reason;
int daemon_pid;
char* err_msg = NULL;
} /* NameOwnerChanged */
else {
- SLOG(LOG_DEBUG, TAG_VCM, "Message is NOT valid");
+ SLOG(LOG_INFO, TAG_VCM, "Message is NOT valid");
dbus_message_unref(msg);
break;
}
dbus_connection_set_exit_on_disconnect(g_m_conn_listener, false);
- SLOG(LOG_DEBUG, TAG_VCM, "service name is %s", VC_MANAGER_SERVICE_NAME);
+ SLOG(LOG_INFO, TAG_VCM, "service name is %s", VC_MANAGER_SERVICE_NAME);
/* register our name on the bus, and check for errors */
ret = dbus_bus_request_name(g_m_conn_listener, VC_MANAGER_SERVICE_NAME, DBUS_NAME_FLAG_REPLACE_EXISTING, &err);
return -1;
}
- SLOG(LOG_DEBUG, TAG_VCM, "[DBUS] Reconnect");
+ SLOG(LOG_INFO, TAG_VCM, "[DBUS] Reconnect");
return 0;
}
bool sender_connected = dbus_connection_get_is_connected(g_m_conn_sender);
bool listener_connected = dbus_connection_get_is_connected(g_m_conn_listener);
- SLOG(LOG_DEBUG, TAG_VCM, "[DBUS] Sender(%s) Listener(%s)",
+ SLOG(LOG_INFO, TAG_VCM, "[DBUS] Sender(%s) Listener(%s)",
sender_connected ? "Connected" : "Not connected", listener_connected ? "Connected" : "Not connected");
if (false == sender_connected || false == listener_connected) {
SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr initialize : Fail to make message ");
return VC_ERROR_OPERATION_FAILED;
} else {
- SLOG(LOG_DEBUG, TAG_VCM, "@@ vc mgr initialize : pid(%d)", pid);
+ SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr initialize : pid(%d)", pid);
}
dbus_message_append_args(msg,
dbus_error_free(&err);
}
- SLOG(LOG_DEBUG, TAG_VCM, "@@ vc mgr initialize : result = %d, service state = %d, foreground = %d, daemon_pid = %d",
+ SLOG(LOG_INFO, TAG_VCM, "@@ vc mgr initialize : result = %d, service state = %d, foreground = %d, daemon_pid = %d",
result, *service_state, *foreground, *daemon_pid);
} else {
SLOG(LOG_ERROR, TAG_VCM, "@@ vc mgr initialize : result = %d", result);