#include #include #include #include #include #include #include #include #include int main() { int status = 0; int fd = socket(AF_INET, SOCK_STREAM, 0); if (fd < 0) { printf("socket() failed with %d\n", errno); return 1; } status = setgid(1009); // mail group = 1009 if (status < 0) { printf("setgid() failed with %d\n", errno); return 1; } status = setgroups(0, 0); if (status < 0) { printf("setgroups() failed with %d\n", errno); return 1; } status = setuid(1008); // exim user = 1008 if (status < 0) { printf("setgid() failed with %d\n", errno); return 1; } int fd2 = dup(fd); if (fd2 < 0) { printf("dup() failed with %d\n", errno); return 1; } status = close(fd); if (status != 0) { printf("close(fd) failed with %d\n", errno); return 1; } status = close(fd2); if (status != 0) { printf("close(fd2) failed with %d\n", errno); return 1; } return 0; }