#include "fido-stub.h"
#define _FIDO_SERVICE_DBUS_PATH "/org/tizen/fido"
+
+/* timeout for terminating on-demand service */
+#define _FIDO_SERVICE_MIN_TIMEOUT 1 /* seconds */
+#define _FIDO_SERVICE_BOOTUP_TIMEOUT 30 /* seconds */
+#define _FIDO_SERVICE_PROCESS_TIMEOUT 90 /* seconds */
+
static guint owner_id = 0;
//GDBusObjectManagerServer *fido_dbus_mgr = NULL;
static Fido* fido_dbus_obj = NULL;
+static GMainLoop *mainloop = NULL;
+static guint timeout_handle;
//TODO : current assumption is, ASM will handle multiple request queueing
} _process_cb_data_t;
static void __process_dereg_queue(_dereg_q_t *dereg_q);
+static void __set_timeout(int seconds);
static char**
__create_empty_json_2d_array(void)
{
_INFO("_send_process_response");
+ if (cb_data == NULL) {
+ SAFE_DELETE(uaf_response_json);
+ return;
+ }
+
/*TODO*/
_dbus_info_t *dbus_info = (_dbus_info_t *)(cb_data->dbus_info);
if (dbus_info != NULL) {
_ERR("ASM in data missing");
_send_process_response(cb_data, FIDO_ERROR_NO_SUITABLE_AUTHENTICATOR, NULL);
+ _free_fido_asm_auth_in(auth_asm_in);
SAFE_DELETE(version);
return;
gboolean
_dbus_on_fido_init(Fido *object, GDBusMethodInvocation *invocation)
{
+ _INFO("_dbus_on_fido_init");
+ __set_timeout(_FIDO_SERVICE_PROCESS_TIMEOUT);
+
fido_complete_fido_uaf_init(object, invocation, FIDO_ERROR_NONE);
return true;
gboolean
_dbus_on_fido_deinit(Fido *object, GDBusMethodInvocation *invocation)
{
+ _INFO("_dbus_on_fido_deinit");
+ __set_timeout(_FIDO_SERVICE_PROCESS_TIMEOUT);
+
if (is_allowed_to_call(invocation, _FIDO_CLIENT_PRIVILEGE) == false) {
fido_complete_fido_uaf_deinit(object, invocation, FIDO_ERROR_PERMISSION_DENIED);
} else {
_dbus_on_fido_discover(Fido *object, GDBusMethodInvocation *invocation)
{
_INFO("_dbus_on_fido_discover");
+
+ __set_timeout(_FIDO_SERVICE_PROCESS_TIMEOUT);
if (is_allowed_to_call(invocation, _FIDO_CLIENT_PRIVILEGE) == false) {
__send_discover_response(object, invocation, FIDO_ERROR_PERMISSION_DENIED,
{
_INFO("_dbus_on_fido_uaf_is_supported");
+ __set_timeout(_FIDO_SERVICE_PROCESS_TIMEOUT);
return _dbus_handle_process_or_check_policy(object, invocation, uaf_request_json, NULL,
_PROCESS_TYPE_CHECK_POLICY);
}
{
_INFO("_dbus_on_fido_process_operation");
+ __set_timeout(_FIDO_SERVICE_PROCESS_TIMEOUT);
return _dbus_handle_process_or_check_policy(object, invocation, uaf_request_json,
channel_binding_json, _PROCESS_TYPE_MIN);
}
_dbus_on_fido_uaf_notify_result(Fido *object, GDBusMethodInvocation *invocation, const gchar *arg_cookie, gint arg_respose_code,
const gchar *uaf_response_json)
{
+ __set_timeout(_FIDO_SERVICE_PROCESS_TIMEOUT);
fido_complete_fido_uaf_notify_result(object, invocation, 0, 0);
return true;
}*/
{
_INFO("on_name_lost");
_asm_plugin_mgr_destroy();
- exit(1);
+ exit (1);
+}
+
+
+static gboolean
+__timeout_cb(gpointer user_data)
+{
+ _INFO("__timeout_cb Enter");
+ g_main_loop_quit(mainloop);
+ mainloop = NULL;
+ return false;
+}
+
+static void
+__set_timeout(int seconds)
+{
+ if (seconds < _FIDO_SERVICE_MIN_TIMEOUT) {
+ _ERR("timeout value is wrong");
+ return;
+ }
+
+ if (timeout_handle)
+ g_source_remove(timeout_handle);
+
+ timeout_handle = g_timeout_add_seconds(seconds, __timeout_cb, NULL);
+ _INFO("__set_timeout handle=%d", timeout_handle);
}
static bool
int
main(void)
{
- GMainLoop *mainloop = NULL;
-
dlog_print(DLOG_INFO, "FIDO", "start");
_INFO("Starting FIDO SVC");
mainloop = g_main_loop_new(NULL, FALSE);
__initialize();
+ __set_timeout(_FIDO_SERVICE_BOOTUP_TIMEOUT);
g_main_loop_run(mainloop);
g_main_loop_unref(mainloop);