1*670b568eSEd Maste #include <sys/types.h>
2*670b568eSEd Maste #include <fcntl.h>
3*670b568eSEd Maste #include <stdio.h>
4*670b568eSEd Maste #include <string.h>
5*670b568eSEd Maste #include <unistd.h>
6*670b568eSEd Maste
main(int argc,char * argv[])7*670b568eSEd Maste int main(int argc, char* argv[]) {
8*670b568eSEd Maste if (argc == 2 && !strcmp(argv[1], "--pass")) {
9*670b568eSEd Maste fprintf(stderr,"[%d] %s immediately returning 0\n", getpid(), argv[0]);
10*670b568eSEd Maste return 0;
11*670b568eSEd Maste }
12*670b568eSEd Maste
13*670b568eSEd Maste if (argc == 2 && !strcmp(argv[1], "--fail")) {
14*670b568eSEd Maste fprintf(stderr,"[%d] %s immediately returning 1\n", getpid(), argv[0]);
15*670b568eSEd Maste return 1;
16*670b568eSEd Maste }
17*670b568eSEd Maste
18*670b568eSEd Maste if (argc == 2 && !strcmp(argv[1], "--checkroot")) {
19*670b568eSEd Maste int rc = (geteuid() == 0);
20*670b568eSEd Maste fprintf(stderr,"[uid:%d] %s immediately returning (geteuid() == 0) = %d\n", geteuid(), argv[0], rc);
21*670b568eSEd Maste return rc;
22*670b568eSEd Maste }
23*670b568eSEd Maste
24*670b568eSEd Maste if (argc == 2 && !strcmp(argv[1], "--capmode")) {
25*670b568eSEd Maste /* Expect to already be in capability mode: check we can't open a file */
26*670b568eSEd Maste int rc = 0;
27*670b568eSEd Maste
28*670b568eSEd Maste int fd = open("/etc/passwd", O_RDONLY);
29*670b568eSEd Maste if (fd > 0) {
30*670b568eSEd Maste fprintf(stderr,"[%d] %s unexpectedly able to open file\n", getpid(), argv[0]);
31*670b568eSEd Maste rc = 1;
32*670b568eSEd Maste }
33*670b568eSEd Maste fprintf(stderr,"[%d] %s --capmode returning %d\n", getpid(), argv[0], rc);
34*670b568eSEd Maste return rc;
35*670b568eSEd Maste }
36*670b568eSEd Maste
37*670b568eSEd Maste return -1;
38*670b568eSEd Maste }
39