qpopper.patch 5.5 KB

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