blob: ea6c274e18bfb55bb9d3d4f863a71f1eaa79214f [file] [log] [blame]
Joshua Brindle13cd4c82008-08-19 15:30:36 -04001#include <unistd.h>
2#include <stdio.h>
3#include <stdlib.h>
4#include <selinux/selinux.h>
5
6int main(int argc, char **argv)
7{
8 pid_t pid;
9 char *buf;
10 int rc;
11
12 if (argc != 2) {
13 fprintf(stderr, "usage: %s pid\n", argv[0]);
14 exit(1);
15 }
16
17 if (sscanf(argv[1], "%d", &pid) != 1) {
18 fprintf(stderr, "%s: invalid pid %s\n", argv[0], argv[1]);
19 exit(2);
20 }
21
22 rc = getpidcon(pid, &buf);
23 if (rc < 0) {
24 fprintf(stderr, "%s: getpidcon() failed\n", argv[0]);
25 exit(3);
26 }
27
28 printf("%s\n", buf);
29 freecon(buf);
Unto Sten5d8f44e2019-05-10 20:10:37 +030030 exit(EXIT_SUCCESS);
Joshua Brindle13cd4c82008-08-19 15:30:36 -040031}