#define DATA_SIZE 4096
#define SHA1_HASH_LEN 20
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define __packed __attribute__((packed))
enum evm_ima_xattr_type {
enum ima_state {
IMA_STATE_DISABLED,
- IMA_STATE_ENABLED,
+ IMA_STATE_IGNORE,
+ IMA_STATE_ENFORCE,
IMA_STATE_FIX
};
int ima_set_policy(const char **policy, const char *policy_sig);
int ima_set_policy_file(const char *policy_path);
+#ifdef __cplusplus
+}
+#endif
+
+
#endif
*state = IMA_STATE_DISABLED;
return LIB_SUCCESS;
case '1':
- *state = IMA_STATE_ENABLED;
+ *state = IMA_STATE_IGNORE;
return LIB_SUCCESS;
case '2':
+ *state = IMA_STATE_ENFORCE;
+ return LIB_SUCCESS;
+ case '4':
*state = IMA_STATE_FIX;
return LIB_SUCCESS;
default:
case IMA_STATE_DISABLED:
buff = '0';
break;
- case IMA_STATE_ENABLED:
+ case IMA_STATE_IGNORE:
buff = '1';
break;
- case IMA_STATE_FIX:
+ case IMA_STATE_ENFORCE:
buff = '2';
break;
+ case IMA_STATE_FIX:
+ buff = '4';
+ break;
default:
log_err("Wrong IMA state\n");
close(fd);
- return LIB_ERROR_UNKNOWN;
+ return LIB_ERROR_INPUT_PARAM;
}
if (write(fd, &buff, sizeof(buff)) < 0) {
while (counter < len) {
ret = write(fd, &(policy_path[counter]), len - counter);
if (ret < 0) {
- log_err("Error while writing to the kernel interface\n");
+ log_err("Error while writing to the kernel interface (%s)\n", strerror(errno));
ret_code = LIB_ERROR_SYSCALL;
goto out;
}