Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #include "../common/common.c"
  2.  
  3. #define NAME "net2"
  4. #define UID 997
  5. #define GID 997
  6. #define PORT 2997
  7.  
  8. void run()
  9. {
  10. unsigned int quad[4];
  11. int i;
  12. unsigned int result, wanted;
  13.  
  14. result = 0;
  15. for(i = 0; i < 4; i++) {
  16. quad[i] = random();
  17. result += quad[i];
  18.  
  19. if(write(0, &(quad[i]), sizeof(result)) != sizeof(result)) {
  20. errx(1, ":(\n");
  21. }
  22. }
  23.  
  24. if(read(0, &wanted, sizeof(result)) != sizeof(result)) {
  25. errx(1, ":<\n");
  26. }
  27.  
  28.  
  29. if(result == wanted) {
  30. printf("you added them correctly\n");
  31. } else {
  32. printf("sorry, try again. invalid\n");
  33. }
  34. }
  35.  
  36. int main(int argc, char **argv, char **envp)
  37. {
  38. int fd;
  39. char *username;
  40.  
  41. /* Run the process as a daemon */
  42. background_process(NAME, UID, GID);
  43.  
  44. /* Wait for socket activity and return */
  45. fd = serve_forever(PORT);
  46.  
  47. /* Set the client socket to STDIN, STDOUT, and STDERR */
  48. set_io(fd);
  49.  
  50. /* Don't do this :> */
  51. srandom(time(NULL));
  52.  
  53. run();
  54. }