• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <unistd.h>
2 #include <sys/types.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
6 #include <errno.h>
7 #include <selinux/selinux.h>
8 
main(int argc,char ** argv)9 int main(int argc, char **argv)
10 {
11 	security_class_t tclass;
12 	int ret;
13 
14 	if (argc != 5) {
15 		fprintf(stderr, "usage:  %s scontext tcontext tclass newcontext\n",
16 			argv[0]);
17 		exit(1);
18 	}
19 
20 	tclass = string_to_security_class(argv[3]);
21 	if (!tclass) {
22 		fprintf(stderr, "%s:  invalid class '%s'\n", argv[0], argv[3]);
23 		exit(2);
24 	}
25 
26 	ret = security_validatetrans(argv[1], argv[2], tclass, argv[4]);
27 	printf("security_validatetrans returned %d errno: %s\n", ret, strerror(errno));
28 
29 	return ret;
30 }
31