Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #include "../common/common.c"
  2.  
  3. #define NAME "net0"
  4. #define UID 999
  5. #define GID 999
  6. #define PORT 2999
  7.  
  8. void run()
  9. {
  10. unsigned int i;
  11. unsigned int wanted;
  12.  
  13. wanted = random();
  14.  
  15. printf("Please send '%d' as a little endian 32bit int\n", wanted);
  16.  
  17. if(fread(&i, sizeof(i), 1, stdin) == NULL) {
  18. errx(1, ":(\n");
  19. }
  20.  
  21. if(i == wanted) {
  22. printf("Thank you sir/madam\n");
  23. } else {
  24. printf("I'm sorry, you sent %d instead\n", i);
  25. }
  26. }
  27.  
  28. int main(int argc, char **argv, char **envp)
  29. {
  30. int fd;
  31. char *username;
  32.  
  33. /* Run the process as a daemon */
  34. background_process(NAME, UID, GID);
  35.  
  36. /* Wait for socket activity and return */
  37. fd = serve_forever(PORT);
  38.  
  39. /* Set the client socket to STDIN, STDOUT, and STDERR */
  40. set_io(fd);
  41.  
  42. /* Don't do this :> */
  43. srandom(time(NULL));
  44.  
  45. run();
  46. }