|
|
1.1 ! root 1: /* usage: dispatch <ipc args> */ ! 2: /* TODO: connect input to /dev/null if peer wants no output, ! 3: connect output to logfile if peer wants no input. */ ! 4: ! 5: #include <sys/types.h> ! 6: #include <sys/sockets.h> ! 7: #include <netinet/in.h> ! 8: #include <netdb.h> ! 9: #include <string.h> ! 10: #include "../paths.h" ! 11: ! 12: int ! 13: main(int argc, char *argv[]) ! 14: { ! 15: char c, d; ! 16: char *args[3]; ! 17: int fd; ! 18: ! 19: if (chdir(LDIR) < 0) ! 20: return 1; ! 21: ! 22: /* TODO: at this point, perform rshd style authentication check, ! 23: set the appropriate user id, and all that. See what kind of ! 24: args we can get from inetd. */ ! 25: ! 26: if (read(0, &c, 1) != 1) ! 27: return 1; ! 28: do ! 29: if (read(0, &d, 1) != 1) ! 30: return 1; ! 31: while (d); ! 32: ! 33: fd = open("/dev/null", 1); ! 34: dup2(fd, 2); ! 35: if (fd > 2) ! 36: close(fd); ! 37: ! 38: switch (c) { ! 39: case 's': ! 40: args[0] = "showq"; ! 41: execv("showq", args); ! 42: break; ! 43: case 't': ! 44: args[0] = "transmit"; ! 45: execv("transmit", args); ! 46: break; ! 47: case 'n': ! 48: args[0] = "notice"; ! 49: execv("notice", args); ! 50: break; ! 51: } ! 52: ! 53: return 1; ! 54: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.