int ima_get_policy(char*** policy);
int ima_free_policy(char **policy);
int ima_set_policy(const char **policy, const char *policy_sig);
+int ima_set_policy_file(const char *policy_path);
#endif
return LIB_SUCCESS;
}
+int ima_set_policy_file(const char *policy_path)
+{
+ int ret_code = LIB_SUCCESS;
+ int counter;
+ int len;
+ int ret;
+ int fd = -1;
+
+ if (!policy_path || policy_path[0] == '\0')
+ return LIB_ERROR_INPUT_PARAM;
+
+ /* open and write to kernel interface */
+ fd = open(IMA_POLICY_INTERFACE, O_WRONLY);
+ if (fd < 0) {
+ log_err("Cannot open kernel interface\n");
+ ret_code = LIB_ERROR_SYSCALL;
+ goto out;
+ }
+
+ counter = 0;
+ len = strlen(policy_path);
+ while (counter < len) {
+ ret = write(fd, &(policy_path[counter]), len - counter);
+ if (ret < 0) {
+ log_err("Error while writing to the kernel interface\n");
+ ret_code = LIB_ERROR_SYSCALL;
+ goto out;
+ }
+ counter += ret;
+ }
+
+out:
+ if (fd > -1)
+ close(fd);
+ return ret_code;
+}
int ima_set_policy(const char **policy, const char *policy_sig)
{