Blame libselinux/utils/getpidcon.c
|
Chris PeBenito |
473ea7 |
#include <unistd.h>
|
|
Chris PeBenito |
473ea7 |
#include <stdio.h>
|
|
Chris PeBenito |
473ea7 |
#include <stdlib.h>
|
|
Chris PeBenito |
473ea7 |
#include <selinux/selinux.h>
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
int main(int argc, char **argv)
|
|
Chris PeBenito |
473ea7 |
{
|
|
Chris PeBenito |
473ea7 |
pid_t pid;
|
|
Chris PeBenito |
473ea7 |
char *buf;
|
|
Chris PeBenito |
473ea7 |
int rc;
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
if (argc != 2) {
|
|
Chris PeBenito |
473ea7 |
fprintf(stderr, "usage: %s pid\n", argv[0]);
|
|
Chris PeBenito |
473ea7 |
exit(1);
|
|
Chris PeBenito |
473ea7 |
}
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
if (sscanf(argv[1], "%d", &pid) != 1) {
|
|
Chris PeBenito |
473ea7 |
fprintf(stderr, "%s: invalid pid %s\n", argv[0], argv[1]);
|
|
Chris PeBenito |
473ea7 |
exit(2);
|
|
Chris PeBenito |
473ea7 |
}
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
rc = getpidcon(pid, &buf;;
|
|
Chris PeBenito |
473ea7 |
if (rc < 0) {
|
|
Chris PeBenito |
473ea7 |
fprintf(stderr, "%s: getpidcon() failed\n", argv[0]);
|
|
Chris PeBenito |
473ea7 |
exit(3);
|
|
Chris PeBenito |
473ea7 |
}
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
printf("%s\n", buf);
|
|
Chris PeBenito |
473ea7 |
freecon(buf);
|
|
Chris PeBenito |
473ea7 |
exit(0);
|
|
Chris PeBenito |
473ea7 |
}
|