Home | History | Annotate | Download | only in utils
      1 #include <unistd.h>
      2 #include <stdio.h>
      3 #include <stdlib.h>
      4 #include <selinux/selinux.h>
      5 
      6 int main(int argc, char **argv)
      7 {
      8 	char *buf;
      9 	int rc, i;
     10 
     11 	if (argc < 2) {
     12 		fprintf(stderr, "usage:  %s path...\n", argv[0]);
     13 		exit(1);
     14 	}
     15 
     16 	for (i = 1; i < argc; i++) {
     17 		rc = getfilecon(argv[i], &buf);
     18 		if (rc < 0) {
     19 			fprintf(stderr, "%s:  getfilecon(%s) failed\n", argv[0],
     20 				argv[i]);
     21 			exit(2);
     22 		}
     23 		printf("%s\t%s\n", argv[i], buf);
     24 		freecon(buf);
     25 	}
     26 	exit(0);
     27 }
     28