|
|
1.1 ! root 1: #include "uucp.h" ! 2: ! 3: ! 4: /******* ! 5: * shio(cmd, fi, fo, user) execute shell of command with ! 6: * char *cmd, *fi, *fo; fi and fo as standard input/output ! 7: * char *user; user name ! 8: * ! 9: * return codes: ! 10: * 0 - ok ! 11: * non zero - failed - status from child ! 12: */ ! 13: ! 14: shio(cmd, fi, fo, user) ! 15: char *cmd, *fi, *fo, *user; ! 16: { ! 17: int status, f; ! 18: int uid, pid, ret; ! 19: char path[MAXFULLNAME]; ! 20: ! 21: if (fi == NULL) ! 22: fi = "/dev/null"; ! 23: if (fo == NULL) ! 24: fo = "/dev/null"; ! 25: ! 26: DEBUG(3, "shio - %s\n", cmd); ! 27: if ((pid = fork()) == 0) { ! 28: close(Ifn); ! 29: close(Ofn); ! 30: close(0); ! 31: f = open(fi, 0); ! 32: ASSERT(f == 0, "BAD OPEN fileno %d", f); ! 33: close(1); ! 34: f = creat(fo, 0666); ! 35: ASSERT(f == 1, "BAD OPEN fileno %d", f); ! 36: if (gninfo(user, &uid, path) == 0) ! 37: setuid(uid); ! 38: execl(SHELL, "sh", "-c", cmd, 0); ! 39: exit(100); ! 40: } ! 41: while ((ret = wait(&status)) != pid && ret != -1); ! 42: DEBUG(3, "status %d\n", status); ! 43: return(status); ! 44: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.