From: jkjo92 Date: Tue, 1 Aug 2017 10:45:03 +0000 (+0900) Subject: Migration from 3.0 to 4.0 X-Git-Tag: submit/tizen/20170801.110200 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8383b62a17628e05c781767261020ca631641963;p=platform%2Fcore%2Faccount%2Ffido-client.git Migration from 3.0 to 4.0 Change-Id: I540151a57555642d8f22d82985fe0a2287ec1b1c Signed-off-by: jkjo92 --- diff --git a/common/fido_json_handler.c b/common/fido_json_handler.c index 4dcb4f7..98ade9f 100755 --- a/common/fido_json_handler.c +++ b/common/fido_json_handler.c @@ -2406,7 +2406,7 @@ _uaf_composer_compose_dereg_request(_response_t *uaf_res) json_builder_add_string_value(header_root, uaf_res->header->app_id); json_builder_set_member_name(header_root, _JSON_KEY_OP); - json_builder_add_string_value(header_root, strdup(_UAF_OPERATION_NAME_KEY_DE_REG)); + json_builder_add_string_value(header_root, _UAF_OPERATION_NAME_KEY_DE_REG); json_builder_set_member_name(header_root, _JSON_KEY_SERVER_DATA); json_builder_add_string_value(header_root, uaf_res->header->server_data); @@ -2488,7 +2488,6 @@ _uaf_composer_compose_dereg_request(_response_t *uaf_res) _INFO("keyid=[%s]", key_id_enc); } SAFE_DELETE(key_id_enc); - } _INFO("after assertions"); @@ -2619,6 +2618,7 @@ _uaf_composer_compose_dereg_request(_response_t *uaf_res) json_object_set_string_member(authObject, _JSON_KEY_KEY_ID, (char *)key_id_enc); _INFO("keyid=[%s]", key_id_enc); } + SAFE_DELETE(key_id_enc); } json_node_take_object(authNode, authObject); json_array_add_element(authArray, authNode); diff --git a/common/fido_tlv_util.c b/common/fido_tlv_util.c old mode 100644 new mode 100755 index 5b2c28d..02d162f --- a/common/fido_tlv_util.c +++ b/common/fido_tlv_util.c @@ -139,11 +139,12 @@ _tlv_util_decode_reg_assertion(char *tlv_enc) } _INFO("Found TAG_KEYID"); + SAFE_DELETE(tlv_dec); return assrt_tlv; } } - + SAFE_DELETE(tlv_dec); return NULL; } diff --git a/packaging/fido-client.spec b/packaging/fido-client.spec old mode 100644 new mode 100755 index a667d9f..7843263 --- a/packaging/fido-client.spec +++ b/packaging/fido-client.spec @@ -123,6 +123,9 @@ install -m 0644 %SOURCE1 %{buildroot}/usr/share/dbus-1/system-services/org.tizen mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d install -m 0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/dbus-1/system.d/ +mkdir -p %{buildroot}%{_unitdir} +install -m 644 %SOURCE3 %{buildroot}%{_unitdir}/fido.service + mkdir -p %{buildroot}/usr/share/dbus-1/system-services install -m 0644 %SOURCE4 %{buildroot}/usr/share/dbus-1/system-services/org.tizen.dummyasm.service @@ -175,6 +178,7 @@ chsmack -a '_' %{_libdir}/fido/asm/ %if 0%{?tizen_version_major} >= 3 %attr(0644,root,root) /usr/share/dbus-1/system-services/org.tizen.fido.service +%attr(0644,root,root) %{_unitdir}/fido.service %else %{_libdir}/systemd/system/org.tizen.fido.service diff --git a/packaging/fido.service b/packaging/fido.service old mode 100644 new mode 100755 index 6d09e27..dadfb05 --- a/packaging/fido.service +++ b/packaging/fido.service @@ -1,9 +1,10 @@ [Unit] Description=FIDO Client service -After=tizen-runtime.target -Requires=tizen-runtime.target [Service] +User=service_fw +Group=service_fw +SmackProcessLabel=System Type=dbus BusName=org.tizen.fido ExecStart=/usr/bin/fido-service diff --git a/packaging/org.tizen.fido.service b/packaging/org.tizen.fido.service old mode 100644 new mode 100755 index 2bd3ab3..c8ab4ba --- a/packaging/org.tizen.fido.service +++ b/packaging/org.tizen.fido.service @@ -3,6 +3,5 @@ Description=FIDO Service D-Bus [D-BUS Service] Name=org.tizen.fido -Exec=/usr/bin/fido-service -User=service_fw -Group=service_fw +Exec=/bin/false +SystemdService=fido.service diff --git a/server/fido_app_id_handler.c b/server/fido_app_id_handler.c old mode 100644 new mode 100755 index 90637ea..dc38c69 --- a/server/fido_app_id_handler.c +++ b/server/fido_app_id_handler.c @@ -584,7 +584,7 @@ _verify_and_get_facet_id(const char *uaf_app_id, GDBusMethodInvocation *invocati cb_data->user_data = user_data; /*Case 1: UAF JSON does not have appID, so no check is required, put facetid*/ - if (uaf_app_id == NULL) { + if ((uaf_app_id == NULL) || (!strcmp(uaf_app_id, ""))) { _DBG("UAF msg does not have appID"); cb_data->real_app_id = __get_tz_facet_id_of_caller(app_id, invocation); g_timeout_add(2, __timer_expired, cb_data); diff --git a/server/fido_asm_plugin_manager.c b/server/fido_asm_plugin_manager.c index d812e34..d8c4e9f 100755 --- a/server/fido_asm_plugin_manager.c +++ b/server/fido_asm_plugin_manager.c @@ -173,8 +173,10 @@ __load_plugins(char **plugin_path) closedir(dir); - if (is_asm_found == false) + if (is_asm_found == false) { + _ERR("Failed to find asm"); return FIDO_ERROR_NOT_SUPPORTED; + } return FIDO_ERROR_NONE; } @@ -293,6 +295,7 @@ _asm_plugin_mgr_discover_all(_asm_plugin_discover_response_cb cb, void *user_dat cb_data->user_data = user_data; if (cb_data->asm_proxy_list_iter == NULL) { + _ERR("asm proxy table is empty"); free(cb_data); return FIDO_ERROR_NOT_SUPPORTED; } @@ -351,6 +354,7 @@ _on_asm_dbus_reply(GObject *proxy, GAsyncResult *res, gpointer user_data) if (dbus_resp != NULL) g_variant_unref(dbus_resp); + SAFE_DELETE(asm_response_json); SAFE_DELETE(cb_data); } @@ -372,7 +376,7 @@ _asm_ipc_send(const char *asm_id, const char *asm_request, _asm_ipc_response_cb _INFO("asm_request=[%s]", asm_request); if (asm_id == NULL) { - _ERR("dbus proxy failed"); + _ERR("asm id is NULL"); return FIDO_ERROR_NOT_SUPPORTED; } @@ -423,7 +427,7 @@ _asm_ipc_send_sync(const char *asm_id, const char *asm_req) _INFO("_asm_ipc_send_sync"); if (asm_id == NULL) { - _ERR("dbus proxy failed"); + _ERR("asm id is NULL"); return NULL; } @@ -459,6 +463,7 @@ _asm_ipc_send_sync(const char *asm_id, const char *asm_req) NULL, &error); + SAFE_DELETE(method_name); if (error != NULL) _ERR("g_dbus_proxy_call_sync failed [%s]", error->message); else diff --git a/server/fido_privilege_checker.c b/server/fido_privilege_checker.c old mode 100644 new mode 100755 index 59a9633..cbbe15f --- a/server/fido_privilege_checker.c +++ b/server/fido_privilege_checker.c @@ -95,9 +95,9 @@ __check_privilege_by_cynara(const char *client, const char *session, const char } return FIDO_ERROR_NONE; -#endif - +#else return FIDO_ERROR_NONE; +#endif } static int diff --git a/server/fido_server.c b/server/fido_server.c index d6c6201..b7b4bc5 100755 --- a/server/fido_server.c +++ b/server/fido_server.c @@ -36,9 +36,17 @@ #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 @@ -75,6 +83,7 @@ typedef struct _process_cb_data { } _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) @@ -179,6 +188,11 @@ _send_process_response(_process_cb_data_t *cb_data, int tz_err_code, char *uaf_r { _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) { @@ -234,6 +248,8 @@ _discover_response_intermediate_cb(GList *asm_response_list, void *user_data) if (asm_response_list != NULL) g_list_free_full(asm_response_list, __free_asm_discover_response_list_item); + + SAFE_DELETE(cb_data); } static int @@ -671,6 +687,7 @@ __handle_auth(_process_cb_data_t *cb_data, _matched_auth_data_t *matched_auth) _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; @@ -710,10 +727,13 @@ _ui_response_callback(int error_code, _ui_auth_data_t *selected_auth_data, void if (cb_data->type == _PROCESS_TYPE_REG) __handle_reg(cb_data, match_data); - else if (cb_data->type == _PROCESS_TYPE_AUTH) __handle_auth(cb_data, match_data); - + else { + _send_process_response(cb_data, FIDO_ERROR_UNKNOWN, NULL); + _free_matched_auth_data(match_data); + return; + } _free_matched_auth_data(match_data); } @@ -724,8 +744,10 @@ _asm_response_dereg_process(int error_code, const char *asm_response_json, void _dereg_q_t *dereg_q = (_dereg_q_t*)(user_data); _process_cb_data_t *cb_data = (_process_cb_data_t*)(dereg_q->cb_data); - if (cb_data == NULL) + if (cb_data == NULL) { + SAFE_DELETE(dereg_q); return; + } /*Process next dereg*/ GQueue *q = (GQueue*) (dereg_q->dereg_asm_in_q); @@ -741,6 +763,8 @@ _asm_response_dereg_process(int error_code, const char *asm_response_json, void g_queue_free(dereg_q->dereg_asm_in_q); dereg_q->dereg_asm_in_q = NULL; _INFO("After Deleting dereg_asm_in_q"); + + SAFE_DELETE(dereg_q); } } @@ -751,14 +775,17 @@ __process_dereg_queue(_dereg_q_t *dereg_q) _INFO("__process_dereg_queue"); GQueue *q = dereg_q->dereg_asm_in_q; - if (q == NULL) + if (q == NULL) { + SAFE_DELETE(dereg_q); return; + } if (g_queue_is_empty(q) == true) { _INFO("Deleting dereg_asm_in_q"); g_queue_free(dereg_q->dereg_asm_in_q); dereg_q->dereg_asm_in_q = NULL; _INFO("After Deleting dereg_asm_in_q"); + SAFE_DELETE(dereg_q); return; } @@ -811,6 +838,7 @@ __process_dereg_queue(_dereg_q_t *dereg_q) asm_req_json, _asm_response_dereg_process, dereg_q); } else { _send_process_response(cb_data, FIDO_ERROR_INVALID_PARAMETER, NULL); + SAFE_DELETE(dereg_q); } _free_matched_auth_dereg(dereg_data); @@ -1170,14 +1198,20 @@ _discover_response_cb_for_process(int tz_error_code, int error_code, GList *avai } } else { GList *allowed_auth_list_iter = allowed_auth_list; - _matched_auth_data_t *match_data = (_matched_auth_data_t *)(allowed_auth_list_iter->data); - - if (cb_data->type == _PROCESS_TYPE_REG) - __handle_reg(cb_data, match_data); - - else if (cb_data->type == _PROCESS_TYPE_AUTH) - __handle_auth(cb_data, match_data); + if (allowed_auth_list_iter != NULL) { + _matched_auth_data_t *match_data = (_matched_auth_data_t *)(allowed_auth_list_iter->data); + if (cb_data->type == _PROCESS_TYPE_REG) + __handle_reg(cb_data, match_data); + else if (cb_data->type == _PROCESS_TYPE_AUTH) + __handle_auth(cb_data, match_data); + else { + _send_process_response(cb_data, FIDO_ERROR_UNKNOWN, NULL); + if (allowed_auth_list != NULL) + g_list_free_full(allowed_auth_list, _free_matched_auth_data); + return; + } + } } if (allowed_auth_list != NULL) g_list_free_full(allowed_auth_list, _free_matched_auth_data); @@ -1242,6 +1276,9 @@ __facet_id_cb(int err, const char *facet_id, void *user_data) 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; @@ -1250,6 +1287,9 @@ _dbus_on_fido_init(Fido *object, GDBusMethodInvocation *invocation) 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 { @@ -1264,6 +1304,8 @@ gboolean _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, @@ -1341,6 +1383,7 @@ _dbus_on_fido_uaf_is_supported(Fido *object, GDBusMethodInvocation *invocation, { _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); } @@ -1351,6 +1394,7 @@ _dbus_on_fido_process_operation(Fido *object, GDBusMethodInvocation *invocation, { _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); } @@ -1359,6 +1403,7 @@ _dbus_on_fido_process_operation(Fido *object, GDBusMethodInvocation *invocation, _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; }*/ @@ -1438,6 +1483,31 @@ on_name_lost(GDBusConnection *connection, 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 __initialize_dbus(void) { @@ -1479,8 +1549,6 @@ __initialize(void) int main(void) { - GMainLoop *mainloop = NULL; - dlog_print(DLOG_INFO, "FIDO", "start"); _INFO("Starting FIDO SVC"); @@ -1488,8 +1556,10 @@ main(void) mainloop = g_main_loop_new(NULL, FALSE); __initialize(); + __set_timeout(_FIDO_SERVICE_BOOTUP_TIMEOUT); g_main_loop_run(mainloop); + g_main_loop_unref(mainloop); _INFO("Ending FIDO SVC"); return 0;