Blame libselinux/utils/compute_av.c
|
Chris PeBenito |
473ea7 |
#include <unistd.h>
|
|
Chris PeBenito |
473ea7 |
#include <sys/types.h>
|
|
Chris PeBenito |
473ea7 |
#include <stdio.h>
|
|
Chris PeBenito |
473ea7 |
#include <stdlib.h>
|
|
Chris PeBenito |
473ea7 |
#include <errno.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 |
struct av_decision avd;
|
|
Chris PeBenito |
473ea7 |
security_class_t tclass;
|
|
Chris PeBenito |
473ea7 |
int ret;
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
if (argc != 4) {
|
|
Chris PeBenito |
473ea7 |
fprintf(stderr, "usage: %s scontext tcontext tclass\n", argv[0]);
|
|
Chris PeBenito |
473ea7 |
exit(1);
|
|
Chris PeBenito |
473ea7 |
}
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
tclass = string_to_security_class(argv[3]);
|
|
Chris PeBenito |
473ea7 |
if (!tclass) {
|
|
Chris PeBenito |
473ea7 |
fprintf(stderr, "%s: invalid class '%s'\n", argv[0], argv[3]);
|
|
Chris PeBenito |
473ea7 |
exit(2);
|
|
Chris PeBenito |
473ea7 |
}
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
ret = security_compute_av(argv[1], argv[2], tclass, 1, &avd);
|
|
Chris PeBenito |
473ea7 |
if (ret < 0) {
|
|
Chris PeBenito |
473ea7 |
fprintf(stderr, "%s: security_compute_av failed\n", argv[0]);
|
|
Chris PeBenito |
473ea7 |
exit(3);
|
|
Chris PeBenito |
473ea7 |
}
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
printf("allowed=");
|
|
Chris PeBenito |
473ea7 |
print_access_vector(tclass, avd.allowed);
|
|
Chris PeBenito |
473ea7 |
printf("\n");
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
if (avd.decided != ~0U) {
|
|
Chris PeBenito |
473ea7 |
printf("decided=");
|
|
Chris PeBenito |
473ea7 |
print_access_vector(tclass, avd.decided);
|
|
Chris PeBenito |
473ea7 |
printf("\n");
|
|
Chris PeBenito |
473ea7 |
}
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
if (avd.auditallow) {
|
|
Chris PeBenito |
473ea7 |
printf("auditallow=");
|
|
Chris PeBenito |
473ea7 |
print_access_vector(tclass, avd.auditallow);
|
|
Chris PeBenito |
473ea7 |
printf("\n");
|
|
Chris PeBenito |
473ea7 |
}
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
if (avd.auditdeny != ~0U) {
|
|
Chris PeBenito |
473ea7 |
printf("auditdeny");
|
|
Chris PeBenito |
473ea7 |
print_access_vector(tclass, avd.auditdeny);
|
|
Chris PeBenito |
473ea7 |
printf("\n");
|
|
Chris PeBenito |
473ea7 |
}
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
exit(0);
|
|
Chris PeBenito |
473ea7 |
}
|