e5a5dd6cc4
The following change imports google/capsicum-test@9333154 from GitHub, omitting the embedded version of googletest, as well as the incomplete libcasper. This test suite helps verify capsicum(3) support via functional tests written in the GoogleTest test framework. Kernel support for capsicum(4) is tested by side-effect of testing capsicum(3). NB: as discussed in a previous [closed] PR [1], the casper(3) tests are incomplete/buggy and will not pass on FreeBSD. Thus, I have no intention of integrating them into the build/test on FreeBSD as-is. The import command used was: ``` curl -L https://github.com/google/capsicum-test/tarball/9333154 | tar --strip-components=1 -xvzf - -C dist/ rm -Rf dist/*/ ``` 1. https://github.com/google/capsicum-test/pull/26 Reviewed by: emaste (mentor) Differential Revision: https://reviews.freebsd.org/D19261
39 lines
1.0 KiB
C
39 lines
1.0 KiB
C
#include <sys/types.h>
|
|
#include <fcntl.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
|
|
int main(int argc, char* argv[]) {
|
|
if (argc == 2 && !strcmp(argv[1], "--pass")) {
|
|
fprintf(stderr,"[%d] %s immediately returning 0\n", getpid(), argv[0]);
|
|
return 0;
|
|
}
|
|
|
|
if (argc == 2 && !strcmp(argv[1], "--fail")) {
|
|
fprintf(stderr,"[%d] %s immediately returning 1\n", getpid(), argv[0]);
|
|
return 1;
|
|
}
|
|
|
|
if (argc == 2 && !strcmp(argv[1], "--checkroot")) {
|
|
int rc = (geteuid() == 0);
|
|
fprintf(stderr,"[uid:%d] %s immediately returning (geteuid() == 0) = %d\n", geteuid(), argv[0], rc);
|
|
return rc;
|
|
}
|
|
|
|
if (argc == 2 && !strcmp(argv[1], "--capmode")) {
|
|
/* Expect to already be in capability mode: check we can't open a file */
|
|
int rc = 0;
|
|
|
|
int fd = open("/etc/passwd", O_RDONLY);
|
|
if (fd > 0) {
|
|
fprintf(stderr,"[%d] %s unexpectedly able to open file\n", getpid(), argv[0]);
|
|
rc = 1;
|
|
}
|
|
fprintf(stderr,"[%d] %s --capmode returning %d\n", getpid(), argv[0], rc);
|
|
return rc;
|
|
}
|
|
|
|
return -1;
|
|
}
|