aba7ab1e5f
The following steps are used to execute the tests using the standard test interface: Docker sudo ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory) TEST_SUBJECTS=docker:docker.io/library/fedora:26 TEST_ARTIFACTS=$PWD/artifacts ansible-playbook --tags container tests.yml Classic sudo ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory) TEST_SUBJECTS="" TEST_ARTIFACTS=$PWD/artifacts ansible-playbook --tags classic tests.yml https://src.fedoraproject.org/rpms/libselinux/pull-request/1
58 lines
1.7 KiB
C
58 lines
1.7 KiB
C
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <selinux/selinux.h>
|
|
#include <selinux/context.h>
|
|
#include <selinux/label.h>
|
|
#include <selinux/restorecon.h>
|
|
|
|
int main(int argc, char **argv) {
|
|
unsigned int flags = 0;
|
|
char *path = NULL;
|
|
|
|
if (argc < 2) {
|
|
fprintf(stderr, "Invalid number of arguments\n");
|
|
return 1;
|
|
}
|
|
|
|
// set path
|
|
if (strcmp(argv[1], "EMPTY") == 0) {
|
|
path = "";
|
|
}
|
|
else if (strcmp(argv[1], "NULL") == 0) {
|
|
path = NULL;
|
|
}
|
|
else {
|
|
path = argv[1];
|
|
}
|
|
|
|
// set flags (if any)
|
|
if (argc >= 3) {
|
|
for (int i = 2; i < argc; i++)
|
|
if (strcmp(argv[i], "IGNORE_DIGEST") == 0)
|
|
flags |= SELINUX_RESTORECON_IGNORE_DIGEST;
|
|
else if (strcmp(argv[i], "NOCHANGE") == 0)
|
|
flags |= SELINUX_RESTORECON_NOCHANGE;
|
|
else if (strcmp(argv[i], "VERBOSE") == 0)
|
|
flags |= SELINUX_RESTORECON_VERBOSE;
|
|
else if (strcmp(argv[i], "PROGRESS") == 0)
|
|
flags |= SELINUX_RESTORECON_PROGRESS;
|
|
else if (strcmp(argv[i], "RECURSE") == 0)
|
|
flags |= SELINUX_RESTORECON_RECURSE;
|
|
else if (strcmp(argv[i], "SET_SPECFILE_CTX") == 0)
|
|
flags |= SELINUX_RESTORECON_SET_SPECFILE_CTX;
|
|
else if (strcmp(argv[i], "REALPATH") == 0)
|
|
flags |= SELINUX_RESTORECON_REALPATH;
|
|
else if (strcmp(argv[i], "XDEV") == 0)
|
|
flags |= SELINUX_RESTORECON_XDEV;
|
|
else {
|
|
fprintf(stderr, "Invalid flag %s\n", argv[i]);
|
|
return 1;
|
|
}
|
|
|
|
}
|
|
|
|
printf("Running selinux_restorecon(\"%s\", %#08x);\n", path, flags);
|
|
|
|
return selinux_restorecon(path, flags);
|
|
}
|