1 /* This is a baby program that is run as root from the runtest script. It is
2 passed the Exim uid and gid as arguments, and the name of a file in the
3 test-suite directory. It gives up all supplementary groups, changes to the
4 given uid/gid, and then tries to read the file. The yield is 0 if that is
5 successful, and non-zero otherwise (use different values to aid debugging). See
6 comments in the exim.c source file about the use of setgroups() for getting rid
7 of extraneous groups. */
19 int main(int argc, char **argv)
23 struct passwd *pw = getpwnam(argv[2]);
24 struct group *gr = getgrnam(argv[3]);
26 if (pw == NULL) return 1;
27 if (gr == NULL) return 2;
28 if (setgroups(0, NULL) != 0 && setgroups(1, group_list) != 0) return 4;
29 if (setgid(gr->gr_gid) != 0) return 5;
30 if (setuid(pw->pw_uid) != 0) return 6;
32 fd = open(argv[1], O_RDONLY);