blob: d594b9b4d7322d56e5297f733010792b937f0a6b [file] [log] [blame]
Stephen Smalley8290d102012-01-13 08:53:56 -05001#include <unistd.h>
2#include <stdio.h>
3#include <stdlib.h>
4#include <errno.h>
5#include <selinux/selinux.h>
6
7int 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}