#include "im-uigadget.h"
#include "im-get-xattrs.h"
-#define GET_XATTRS_DEFAULT_PATH "/"
+#define GET_XATTRS_DEFAULT_PATH "/root/ima-test/"
#define MESSAGE_BEGIN "IDS_ST_GET_XATTRS_MSG_BEGIN" // "Xattrs of:"
#define MESSAGE_IMA ":<br>security.ima: "
#define MESSAGE_EVM "<br>security.evm: "
ad->file_action = im_get_xattrs_wrapper;
ad->fileselector_default_path = GET_XATTRS_DEFAULT_PATH;
- //show_file_selector(ad, dgettext(PACKAGE, FILE_SELECTOR_TITLE));
+ show_file_selector(ad, dgettext(PACKAGE, FILE_SELECTOR_TITLE));
// FIXME: For testing:
- im_get_xattrs_wrapper (ad, "/home/root/file");
+ //im_get_xattrs_wrapper (ad, "/home/root/file");
+}
+
+static void im_print_xattr (char* xattr, char** out)
+{
+ if (!xattr || !out)
+ return;
+
+ int i, j;
+ int len = strlen(xattr);
+ *out = calloc(sizeof(char), (len*2 + 1 ));
+
+ for (i = 0, j = 0; i < len; ++i) {
+ sprintf(&((*out)[j]), "%x", (unsigned char) xattr[i]);
+ if ((unsigned char) xattr[i] < 0x10)
+ j += 1;
+ else
+ j += 2;
+ }
}
int im_get_xattrs_wrapper (struct ug_data *ad, const char* const file_path)
LOGD("Enter function: %s", __func__);
int ret;
+ char* tmp = NULL;
char* ima_xattr = NULL;
char* evm_xattr = NULL;
- ret = ima_get_xattr(file_path, &ima_xattr);
+ ret = ima_get_xattr(file_path, &tmp);
if (ret != LIB_SUCCESS) {
LOGE("ima_get_xattr (%s) failed (%d)", file_path, ret);
goto out;
}
- ret = evm_get_xattr(file_path, &evm_xattr);
+ //LOGD("IMA xattr: %x", tmp);
+ im_print_xattr(tmp, &ima_xattr);
+ free(tmp);
+ tmp = NULL;
+
+ ret = evm_get_xattr(file_path, &tmp);
if (ret != LIB_SUCCESS) {
LOGE("evm_get_xattr (%s) failed (%d)", file_path, ret);
goto out;
}
+ //LOGD("EVM xattr: %x", tmp);
+ im_print_xattr(tmp, &evm_xattr);
+ free(tmp);
+ tmp = NULL;
- size_t size = strlen(dgettext(PACKAGE, IDS_ST_GET_XATTRS_MSG_BEGIN)) +
+ size_t size = strlen(dgettext(PACKAGE, "IDS_ST_GET_XATTRS_MSG_BEGIN")) +
strlen(file_path) +
strlen(MESSAGE_IMA) +
strlen(ima_xattr) +
strlen(evm_xattr) + 1; // Use asprintf?
ad->popup_content = malloc(sizeof(char) * size); // One more char to add NULL at the end
snprintf(ad->popup_content, size, "%s%s%s%s%s%s",
- dgettext(PACKAGE, IDS_ST_GET_XATTRS_MSG_BEGIN),
+ dgettext(PACKAGE, "IDS_ST_GET_XATTRS_MSG_BEGIN"),
file_path,
MESSAGE_IMA,
ima_xattr,
#include "im-compromised-list.h"
#include "im-load-policy.h"
#include "im-get-policy.h"
+#include "im-get-xattrs.h"
// FIXME: For testing/debug purpose only
// This flag cause that errors from libimaevm will be ignored.
elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_TRUE);
nf_it = _add_genlist_item(genlist, ITC_TYPE_LIST, dgettext(PACKAGE, "IDS_ST_GET_FILE_XATTRS"),
- NULL, im_check_file_cb, ad);
+ NULL, im_get_xattrs_cb, ad);
elm_object_item_domain_text_translatable_set(nf_it, PACKAGE, EINA_TRUE);
nf_it = elm_naviframe_item_push(ad->navi_bar, dgettext(PACKAGE, "IDS_ST_IMA_EVM_SETUP_MAIN"),