Chris PeBenito 473ea7
#include <unistd.h>
Chris PeBenito 473ea7
#include <sys/types.h>
Chris PeBenito 473ea7
#include <stdio.h>
Chris PeBenito 473ea7
#include <stdlib.h>
Chris PeBenito 473ea7
#include <errno.h>
Chris PeBenito 473ea7
#include <selinux/selinux.h>
Chris PeBenito 473ea7
Chris PeBenito 473ea7
int main(int argc, char **argv) 
Chris PeBenito 473ea7
{
Chris PeBenito 473ea7
	char *buf;
Chris PeBenito 473ea7
	security_class_t tclass;
Chris PeBenito 473ea7
	int ret;
Chris PeBenito 473ea7
Chris PeBenito 473ea7
	if (argc != 4) {
Chris PeBenito 473ea7
		fprintf(stderr, "usage:  %s scontext tcontext tclass\n", argv[0]);
Chris PeBenito 473ea7
		exit(1);
Chris PeBenito 473ea7
	}
Chris PeBenito 473ea7
	
Chris PeBenito 473ea7
	tclass = string_to_security_class(argv[3]);
Chris PeBenito 473ea7
	if (!tclass) {
Chris PeBenito 473ea7
		fprintf(stderr, "%s:  invalid class '%s'\n", argv[0], argv[3]);
Chris PeBenito 473ea7
		exit(2);
Chris PeBenito 473ea7
	}
Chris PeBenito 473ea7
Chris PeBenito 473ea7
	ret = security_compute_relabel(argv[1], argv[2], tclass, &buf;;
Chris PeBenito 473ea7
	if (ret < 0) {
Chris PeBenito 473ea7
		fprintf(stderr, "%s:  security_compute_relabel failed\n", argv[0]);
Chris PeBenito 473ea7
		exit(3);
Chris PeBenito 473ea7
	}
Chris PeBenito 473ea7
Chris PeBenito 473ea7
	printf("%s\n", buf);
Chris PeBenito 473ea7
	freecon(buf);
Chris PeBenito 473ea7
	exit(0);
Chris PeBenito 473ea7
}