qpopper.patch 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. Index: popper/main.c
  2. --- popper/main.c.orig 2003-01-02 03:39:02.000000000 +0100
  3. +++ popper/main.c 2003-09-18 22:04:57.000000000 +0200
  4. @@ -226,12 +226,6 @@
  5. err_out = msg_out = fopen ( "/dev/null", "w+" ); /* until we get set up */
  6. /*
  7. - * Ensure default port & address is in network order
  8. - */
  9. - addr = htonl ( addr );
  10. - port = htons ( port );
  11. -
  12. - /*
  13. * Set defaults for Qargc and Qargv
  14. */
  15. Qargc = argc;
  16. @@ -256,43 +250,34 @@
  17. ptr = argv [ 1 ];
  18. if ( argc >= 2 && ( *ptr == ':' || isdigit ( (int) *ptr ) ) )
  19. {
  20. - unsigned long a = addr;
  21. - unsigned short n = port;
  22. - char b [ 25 ] = "";
  23. - char *q = b;
  24. -
  25. - /*
  26. - * We might have an ip address first
  27. - */
  28. - if ( strchr ( ptr, '.' ) != NULL )
  29. - while ( *ptr == '.' || isdigit ( (int) *ptr ) )
  30. - *q++ = *ptr++;
  31. -
  32. - if ( *b != '\0' )
  33. - {
  34. - a = inet_addr ( b );
  35. - ptr = strchr ( ptr, ':' );
  36. - if ( ptr != NULL )
  37. - ptr++;
  38. + char *cpIp = NULL;
  39. + char *cpPort = NULL;
  40. + char *cpDup;
  41. + char *cp;
  42. +
  43. + if ((cpDup = strdup(ptr)) == NULL)
  44. + err_dump ( HERE, "unable to allocate memory to examine first argument" );
  45. + if ((cp = strchr(cpDup, ':')) != NULL) {
  46. + *cp++ = '\0'; /* a colon means both ip and port are given, split them */
  47. + if (*cpDup != '\0') /* do not accept empty strings */
  48. + cpIp = cpDup;
  49. + if (*cp != '\0') /* do not accept empty strings */
  50. + cpPort = cp;
  51. }
  52. - else
  53. - {
  54. - ptr = argv [ 1 ];
  55. - if ( *ptr == ':' )
  56. - ptr++;
  57. + else {
  58. + if (strchr (ptr, '.') != NULL)
  59. + cpIp = cpDup; /* no colon but a dot means a ip is given */
  60. + else
  61. + cpPort = cpDup; /* no colon and no dot means a port is given */
  62. }
  63. + if (cpIp != NULL )
  64. + addr = inet_addr(cpIp);
  65. + if (cpPort != NULL )
  66. + port = atoi(cpPort);
  67. + free(cpDup);
  68. - /*
  69. - * We might have a port number
  70. - */
  71. - if ( ptr != NULL )
  72. - n = atoi ( ptr );
  73. -
  74. - if ( a == BAD_ADDR || n == 0 || n > USHRT_MAX )
  75. + if ( addr == BAD_ADDR || port == 0 || port > USHRT_MAX )
  76. err_dump ( HERE, "invalid address and/or port: \"%s\"", argv[1] );
  77. -
  78. - port = htons ( n );
  79. - addr = a;
  80. /*
  81. * Since we consumed the first specified parameter,
  82. @@ -310,6 +295,8 @@
  83. Qargv [ rslt - 1 ] = argv [ rslt ];
  84. Qargc = argc - 1;
  85. }
  86. + /* Ensure address remains and default port becomes network byte order */
  87. + port = htons ( port );
  88. /*
  89. * Open the log
  90. @@ -477,6 +464,22 @@
  91. #endif /* not _DEBUG */
  92. +#ifdef PIDFILE
  93. + /*
  94. + * Write PID file. -- RSE
  95. + */
  96. + {
  97. + pid_t pid;
  98. + FILE *fp;
  99. +
  100. + pid = getpid();
  101. + if ((fp = fopen(PIDFILE, "w")) == NULL)
  102. + err_dump(HERE, "Can't write pidfile '%s'", PIDFILE);
  103. + fprintf(fp, "%ld\n", (long)pid);
  104. + fclose(fp);
  105. + }
  106. +#endif
  107. +
  108. /*
  109. * Set up the socket on which we listen
  110. */
  111. @@ -510,17 +513,9 @@
  112. rslt = bind ( sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr) );
  113. if ( rslt < 0 )
  114. {
  115. - if ( errno == EADDRINUSE )
  116. - {
  117. - fprintf ( stderr, "%s:%d in use\n",
  118. - inet_ntoa ( serv_addr.sin_addr ),
  119. - ntohs ( serv_addr.sin_port ) );
  120. - return 1;
  121. - }
  122. - else
  123. - err_dump ( HERE, "Can't bind local address %s:%d",
  124. - inet_ntoa ( serv_addr.sin_addr ),
  125. - ntohs ( serv_addr.sin_port ) );
  126. + err_dump ( HERE, "Can't bind local address %s:%d",
  127. + inet_ntoa ( serv_addr.sin_addr ),
  128. + ntohs ( serv_addr.sin_port ) );
  129. }
  130. TRACE ( trace_file, POP_DEBUG, HERE,
  131. Index: pop_dropcopy.c
  132. --- popper/pop_dropcopy.c.orig 2003-01-02 03:39:02.000000000 +0100
  133. +++ popper/pop_dropcopy.c 2003-10-01 17:33:31.000000000 +0200
  134. @@ -1231,6 +1231,10 @@
  135. return pop_msg ( p, POP_FAILURE, HERE,
  136. "[SYS/TEMP] Unable to get temp drop name" );
  137. + /*
  138. + * OpenPKG: enforce usage of "spool-dir" configuration option
  139. + */
  140. +#if 0
  141. if ( stat ( p->temp_drop, &mybuf ) == -1 || mybuf.st_size <= 0 ) {
  142. if ( genpath ( p,
  143. p->temp_drop,
  144. @@ -1239,6 +1243,7 @@
  145. return pop_msg ( p, POP_FAILURE, HERE,
  146. "[SYS/TEMP] Unable to get temp drop name" );
  147. }
  148. +#endif
  149. }
  150. else {
  151. /*