Chris PeBenito 473ea7
#include <unistd.h>
Chris PeBenito 473ea7
#include <sys/types.h>
Chris PeBenito 473ea7
#include <fcntl.h>
Chris PeBenito 473ea7
#include <stdio.h>
Chris PeBenito 473ea7
#include <stdlib.h>
Chris PeBenito 473ea7
#include <errno.h>
Chris PeBenito 473ea7
#include <string.h>
Chris PeBenito 473ea7
#include <ctype.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, **ptr;
Chris PeBenito 473ea7
	int ret;
Chris PeBenito 473ea7
Chris PeBenito 473ea7
	if (argc != 3) {
Chris PeBenito 473ea7
		fprintf(stderr, "usage:  %s context user\n", argv[0]);
Chris PeBenito 473ea7
		exit(1);
Chris PeBenito 473ea7
	}
Chris PeBenito 473ea7
Chris PeBenito 473ea7
	ret = security_compute_user(argv[1], argv[2], &buf;;
Chris PeBenito 473ea7
	if (ret < 0) {
Chris PeBenito 473ea7
		fprintf(stderr, "%s:  security_compute_user(%s,%s) failed\n", argv[0], argv[1], argv[2]);
Chris PeBenito 473ea7
		exit(2);
Chris PeBenito 473ea7
	}
Chris PeBenito 473ea7
Chris PeBenito 473ea7
	if (!buf[0]) {
Chris PeBenito 473ea7
		printf("none\n");
Chris PeBenito 473ea7
		exit(0);
Chris PeBenito 473ea7
	}
Chris PeBenito 473ea7
Chris PeBenito 473ea7
	for (ptr = buf; *ptr; ptr++) {
Chris PeBenito 473ea7
		printf("%s\n", *ptr);
Chris PeBenito 473ea7
	}
Chris PeBenito 473ea7
	freeconary(buf);
Chris PeBenito 473ea7
	exit(0);
Chris PeBenito 473ea7
}