| 1 | #include <unistd.h> |
| 2 | #include <sys/types.h> |
| 3 | #include <fcntl.h> |
| 4 | #include <stdio.h> |
| 5 | #include <stdlib.h> |
| 6 | #include <errno.h> |
| 7 | #include <string.h> |
| 8 | #include <ctype.h> |
| 9 | #include <selinux/selinux.h> |
| 10 | |
| 11 | int main(int argc, char **argv) |
| 12 | { |
| 13 | char **buf, **ptr; |
| 14 | int ret; |
| 15 | |
| 16 | if (argc != 3) { |
| 17 | fprintf(stderr, "usage: %s context user\n", argv[0]); |
| 18 | exit(1); |
| 19 | } |
| 20 | |
| 21 | ret = security_compute_user(argv[1], argv[2], &buf); |
| 22 | if (ret < 0) { |
| 23 | fprintf(stderr, "%s: security_compute_user(%s,%s) failed\n", |
| 24 | argv[0], argv[1], argv[2]); |
| 25 | exit(2); |
| 26 | } |
| 27 | |
| 28 | if (!buf[0]) { |
| 29 | printf("none\n"); |
| 30 | exit(0); |
| 31 | } |
| 32 | |
| 33 | for (ptr = buf; *ptr; ptr++) { |
| 34 | printf("%s\n", *ptr); |
| 35 | } |
| 36 | freeconary(buf); |
| 37 | exit(0); |
| 38 | } |