]> pd.if.org Git - startuptools/blob - chids.c
startup program improvements
[startuptools] / chids.c
1 /*
2  * set id
3  */
4
5 #include <stdlib.h>
6 #include <unistd.h>
7 #include <sys/types.h>
8 #include <pwd.h>
9
10 #include "exec.c"
11 #include "die.c"
12
13 int main(int ac, char *av[]) {
14         struct passwd *pw;
15
16         pw = getpwnam(av[1]);
17         if (!pw) {
18                 errordie("getpwnam");
19                 exit(EXIT_FAILURE);
20         }
21         
22         if (seteuid(pw->pw_uid) == -1) {
23                 errordie("seteuid");
24                 exit(EXIT_FAILURE);
25         };
26
27         do_exec(2, ac, av);
28
29         /* shouldn't get here... */
30         return EXIT_FAILURE;
31 }