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 <stdio.h>
Chris PeBenito 473ea7
#include "selinux_internal.h"
Chris PeBenito 473ea7
#include "policy.h"
Chris PeBenito 473ea7
#include <limits.h>
Chris PeBenito 473ea7
Chris PeBenito 473ea7
int security_check_context_raw(security_context_t con)
Chris PeBenito 473ea7
{
Chris PeBenito 473ea7
	char path[PATH_MAX];
Chris PeBenito 473ea7
	int fd, ret;
Chris PeBenito 473ea7
Chris PeBenito 473ea7
	snprintf(path, sizeof path, "%s/context", 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
	ret = write(fd, con, strlen(con)+1);
Chris PeBenito 473ea7
	close(fd);
Chris PeBenito 473ea7
	if (ret < 0)
Chris PeBenito 473ea7
		return -1;
Chris PeBenito 473ea7
	return 0;
Chris PeBenito 473ea7
}
Chris PeBenito 473ea7
hidden_def(security_check_context_raw)
Chris PeBenito 473ea7
Chris PeBenito 473ea7
int security_check_context(security_context_t con)
Chris PeBenito 473ea7
{
Chris PeBenito 473ea7
	int ret;
Chris PeBenito 473ea7
	security_context_t rcon = con;
Chris PeBenito 473ea7
Chris PeBenito 473ea7
	if (context_translations && trans_to_raw_context(con, &rcon))
Chris PeBenito 473ea7
		return -1;
Chris PeBenito 473ea7
Chris PeBenito 473ea7
 	ret = security_check_context_raw(rcon);
Chris PeBenito 473ea7
Chris PeBenito 473ea7
	if (context_translations)
Chris PeBenito 473ea7
		freecon(rcon);
Chris PeBenito 473ea7
Chris PeBenito 473ea7
	return ret;
Chris PeBenito 473ea7
}
Chris PeBenito 473ea7
hidden_def(security_check_context)