1 #include <unistd.h>
2 #include <stdio.h>
3 #include <stdlib.h>
4 #include <errno.h>
5 #include <selinux/selinux.h>
6
chcon_main(int argc,char ** argv)7 int chcon_main(int argc, char **argv)
8 {
9 int rc, i;
10
11 if (argc < 3) {
12 fprintf(stderr, "usage: %s context path...\n", argv[0]);
13 exit(1);
14 }
15
16 for (i = 2; i < argc; i++) {
17 rc = setfilecon(argv[i], argv[1]);
18 if (rc < 0) {
19 fprintf(stderr, "%s: Could not label %s with %s: %s\n",
20 argv[0], argv[i], argv[1], strerror(errno));
21 exit(2);
22 }
23 }
24 exit(0);
25 }
26