From: Janusz Kozerski Date: Mon, 28 Apr 2014 08:59:47 +0000 (+0200) Subject: Disabling libimaevm error checking is now possible by define. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F86%2F21386%2F1;p=platform%2Fcore%2Fsecurity%2Fima-evm-reference-utils.git Disabling libimaevm error checking is now possible by define. Add define that can be used to test the UI without checking the values reduned by libimaevm (no library error checking). Change-Id: Iae86a87bbd003a4685bd1eb62ee3bc8cf3fe1221 Signed-off-by: Janusz Kozerski --- diff --git a/src/im-main-menu.c b/src/im-main-menu.c index d57abfc..a326c69 100644 --- a/src/im-main-menu.c +++ b/src/im-main-menu.c @@ -29,6 +29,10 @@ #include "im-load-policy.h" #include "im-get-policy.h" +// FIXME: For testing/debug purpose only +// This flag cause that errors from libimaevm will be ignored. +//#define DO_NOT_CHECK_ERROR + static int _ima_state; // 0 for disabled, 1 for enabled static int _ima_fix_state; // 0 for fix off (ima enabled), 1 for fix on @@ -170,16 +174,18 @@ static void genlist_ima_enable_disable_clicked_cb(void *data, Evas_Object *obj, if (_ima_fix_state == 1) { ret = ima_set_state(IMA_STATE_FIX); printf("result of ima_set_state(IMA_STATE_FIX): %d\n", ret); - // FIXME: this code is commented for testing purpose - // if (ret) // Error - // goto out; +#ifndef DO_NOT_CHECK_ERROR + if (ret != LIB_SUCCESS) // Error + goto out; +#endif } else { ret = ima_set_state(IMA_STATE_ENABLED); printf("result of ima_set_state(IMA_STATE_ENABLED): %d\n", ret); - // FIXME: this code is commented for testing purpose - // if (ret) // Error - // goto out; +#ifndef DO_NOT_CHECK_ERROR + if (ret != LIB_SUCCESS) // Error + goto out; +#endif } _ima_state = 1; ((ItemData_t *)data)->check_status = EINA_TRUE; @@ -188,14 +194,18 @@ static void genlist_ima_enable_disable_clicked_cb(void *data, Evas_Object *obj, else { // Turning off the IMA ret = ima_set_state(IMA_STATE_DISABLED); printf("result of ima_set_state(IMA_STATE_DISABLED): %d\n", ret); - // FIXME: this code is commented for testing purpose - // if (ret) // Error - // goto out; +#ifndef DO_NOT_CHECK_ERROR + if (ret != LIB_SUCCESS) // Error + goto out; +#endif _ima_state = 0; ((ItemData_t *)data)->check_status = EINA_FALSE; _ima_disable_all_items(it); } -// out: +#ifndef DO_NOT_CHECK_ERROR +out: +#endif + elm_genlist_item_update(it); elm_genlist_item_selected_set(it, EINA_FALSE); } @@ -214,9 +224,10 @@ static void genlist_ima_fix_mode_enable_disable_clicked_cb(void *data, Evas_Obje if (_ima_state == 1) { // If IMA is enabled then turn on FIX mode ret = ima_set_state(IMA_STATE_FIX); printf("result of ima_set_state(FIX): %d\n", ret); - // FIXME: this code is commented for testing purpose - // if (ret) // Error - // goto out; +#ifndef DO_NOT_CHECK_ERROR + if (ret != LIB_SUCCESS) // Error + goto out; +#endif } // If IMA is disabled then just change the state in UI _ima_fix_state = 1; @@ -226,21 +237,25 @@ static void genlist_ima_fix_mode_enable_disable_clicked_cb(void *data, Evas_Obje if (_ima_state == 1) { ret = ima_set_state(IMA_STATE_ENABLED); printf("result of ima_set_state(IMA_STATE_ENABLED): %d\n", ret); - // FIXME: this code is commented for testing purpose - // if (ret) // Error - // goto out; +#ifndef DO_NOT_CHECK_ERROR + if (ret != LIB_SUCCESS) // Error + goto out; +#endif } // If IMA is disabled then just change the state in UI _ima_fix_state = 0; ((ItemData_t *)data)->check_status = EINA_FALSE; } -//out: +#ifndef DO_NOT_CHECK_ERROR +out: +#endif + elm_genlist_item_selected_set(it, EINA_FALSE); elm_genlist_item_update(it); } // ------------------ EVM ------------------ -// FIXME: Copy-paste code. Merge it with IMA switch callbacks if possible +// FIXME: Copy-paste code. Merge it with IMA switch callbacks if possible. static void genlist_evm_enable_disable_clicked_cb(void *data, Evas_Object *obj, void *event_info) { @@ -257,16 +272,18 @@ static void genlist_evm_enable_disable_clicked_cb(void *data, Evas_Object *obj, if (_evm_fix_state == 1) { ret = evm_set_state(EVM_STATE_FIX); printf("result of evm_set_state(EVM_STATE_FIX): %d\n", ret); - // FIXME: this code is commented for testing purpose - // if (ret) // Error - // goto out; +#ifndef DO_NOT_CHECK_ERROR + if (ret != LIB_SUCCESS) // Error + goto out; +#endif } else { ret = evm_set_state(EVM_STATE_ENABLED); printf("result of evm_set_state(EVM_STATE_ENABLED): %d\n", ret); - // FIXME: this code is commented for testing purpose - // if (ret) // Error - // goto out; +#ifndef DO_NOT_CHECK_ERROR + if (ret != LIB_SUCCESS) // Error + goto out; +#endif } _evm_state = 1; ((ItemData_t *)data)->check_status = EINA_TRUE; @@ -275,14 +292,18 @@ static void genlist_evm_enable_disable_clicked_cb(void *data, Evas_Object *obj, else { // Turning off the EVM ret = evm_set_state(EVM_STATE_DISABLED); printf("result of evm_set_state(EVM_STATE_DISABLED): %d\n", ret); - // FIXME: this code is commented for testing purpose - // if (ret) // Error - // goto out; +#ifndef DO_NOT_CHECK_ERROR + if (ret != LIB_SUCCESS) // Error + goto out; +#endif _evm_state = 0; ((ItemData_t *)data)->check_status = EINA_FALSE; _ima_disable_all_items(it); } -// out: +#ifndef DO_NOT_CHECK_ERROR +out: +#endif + elm_genlist_item_update(it); elm_genlist_item_selected_set(it, EINA_FALSE); } @@ -301,9 +322,10 @@ static void genlist_evm_fix_mode_enable_disable_clicked_cb(void *data, Evas_Obje if (_evm_state == 1) { // If EVM is enabled then turn on FIX mode ret = evm_set_state(EVM_STATE_FIX); printf("result of evm_set_state(FIX): %d\n", ret); - // FIXME: this code is commented for testing purpose - // if (ret) // Error - // goto out; +#ifndef DO_NOT_CHECK_ERROR + if (ret != LIB_SUCCESS) // Error + goto out; +#endif } // If EVM is disabled then just change the state in UI _evm_fix_state = 1; @@ -313,15 +335,19 @@ static void genlist_evm_fix_mode_enable_disable_clicked_cb(void *data, Evas_Obje if (_evm_state == 1) { ret = evm_set_state(EVM_STATE_ENABLED); printf("result of evm_set_state(EVM_STATE_ENABLED): %d\n", ret); - // FIXME: this code is commented for testing purpose - // if (ret) // Error - // goto out; +#ifndef DO_NOT_CHECK_ERROR + if (ret != LIB_SUCCESS) // Error + goto out; +#endif } // If EVM is disabled then just change the state in UI _evm_fix_state = 0; ((ItemData_t *)data)->check_status = EINA_FALSE; } -//out: +#ifndef DO_NOT_CHECK_ERROR +out: +#endif + elm_genlist_item_selected_set(it, EINA_FALSE); elm_genlist_item_update(it); }