Chris PeBenito 473ea7
#include <unistd.h>
Chris PeBenito 473ea7
#include <sys/types.h>
Chris PeBenito 473ea7
#include <fcntl.h>
Chris PeBenito 473ea7
#include <stdlib.h>
Chris PeBenito 473ea7
#include <errno.h>
Chris PeBenito 473ea7
#include <string.h>
Chris PeBenito 473ea7
#include "selinux_internal.h"
Chris PeBenito 473ea7
#include "policy.h"
Chris PeBenito 473ea7
#include <stdio.h>
Chris PeBenito 473ea7
#include <limits.h>
Chris PeBenito 473ea7
Chris PeBenito 473ea7
int security_setenforce(int value)
Chris PeBenito 473ea7
{
Chris PeBenito 473ea7
	int fd, ret;
Chris PeBenito 473ea7
	char path[PATH_MAX];
Chris PeBenito 473ea7
	char buf[20];
Chris PeBenito 473ea7
Chris PeBenito 473ea7
	snprintf(path, sizeof path, "%s/enforce", selinux_mnt);
Chris PeBenito 473ea7
	fd = open(path, O_RDWR);
Chris PeBenito 473ea7
	if (fd < 0)
Chris PeBenito 473ea7
		return -1;
Chris PeBenito 473ea7
Chris PeBenito 473ea7
	snprintf(buf, sizeof buf, "%d", value);
Chris PeBenito 473ea7
	ret = write(fd, buf, strlen(buf));
Chris PeBenito 473ea7
	close(fd);
Chris PeBenito 473ea7
	if (ret < 0)
Chris PeBenito 473ea7
		return -1;
Chris PeBenito 473ea7
Chris PeBenito 473ea7
	return 0;
Chris PeBenito 473ea7
}
Chris PeBenito 473ea7
hidden_def(security_setenforce)