curl.patch 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. Index: lib/ftp.c
  2. --- lib/ftp.c.orig 2007-07-02 00:01:19 +0200
  3. +++ lib/ftp.c 2007-08-29 10:07:14 +0200
  4. @@ -2371,8 +2371,7 @@
  5. struct ftp_conn *ftpc = &conn->proto.ftpc;
  6. (void)instate; /* no use for this yet */
  7. - /* some need password anyway, and others just return 2xx ignored */
  8. - if((ftpcode == 331 || ftpcode/100 == 2) && (ftpc->state == FTP_USER)) {
  9. + if((ftpcode == 331) && (ftpc->state == FTP_USER)) {
  10. /* 331 Password required for ...
  11. (the server requires to send the user's password too) */
  12. NBFTPSENDF(conn, "PASS %s", ftp->passwd?ftp->passwd:"");
  13. Index: lib/ssh.c
  14. --- lib/ssh.c.orig 2007-07-06 22:13:24 +0200
  15. +++ lib/ssh.c 2007-08-29 10:07:14 +0200
  16. @@ -70,6 +70,24 @@
  17. #endif
  18. #endif /* !WIN32 */
  19. +#if defined(LIBSSH2_VERSION_NUM)
  20. +# if LIBSSH2_VERSION_NUM >= 0x001000
  21. +# define HAVE_LIBSSH2_NBLOCK 1
  22. +# else
  23. +# define HAVE_LIBSSH2_NBLOCK 0
  24. +# endif
  25. +#else /* !defined(LIBSSH2_VERSION_NUM) */
  26. +# if defined(LIBSSH2_APINO)
  27. +# if LIBSSH2_APINO >= 200706012030
  28. +# define HAVE_LIBSSH2_NBLOCK 1
  29. +# else
  30. +# define HAVE_LIBSSH2_NBLOCK 0
  31. +# endif
  32. +# else /* !defined(LIBSSH2_APINO) */
  33. +# define HAVE_LIBSSH2_NBLOCK 0
  34. +# endif /* defined(LIBSSH2_APINO) */
  35. +#endif /* defined(LIBSSH2_VERSION_NUM) */
  36. +
  37. #if (defined(NETWARE) && defined(__NOVELL_LIBC__))
  38. #undef in_addr_t
  39. #define in_addr_t unsigned long
  40. @@ -239,7 +257,7 @@
  41. (void)abstract;
  42. }
  43. -#if (LIBSSH2_APINO >= 200706012030)
  44. +#if HAVE_LIBSSH2_NBLOCK
  45. /*
  46. * SSH State machine related code
  47. */
  48. @@ -854,7 +872,7 @@
  49. infof(data, "SSH socket: %d\n", sock);
  50. #endif /* CURL_LIBSSH2_DEBUG */
  51. -#if (LIBSSH2_APINO >= 200706012030)
  52. +#if HAVE_LIBSSH2_NBLOCK
  53. state(conn, SSH_S_STARTUP);
  54. if (data->state.used_interface == Curl_if_multi)
  55. @@ -1134,7 +1152,7 @@
  56. * the destination file will be named the same name as the last directory
  57. * in the path.
  58. */
  59. -#if (LIBSSH2_APINO >= 200706012030)
  60. +#if HAVE_LIBSSH2_NBLOCK
  61. do {
  62. scp->ssh_channel = libssh2_scp_send_ex(scp->ssh_session, scp->path,
  63. conn->data->set.new_file_perms,
  64. @@ -1169,7 +1187,7 @@
  65. */
  66. curl_off_t bytecount;
  67. memset(&sb, 0, sizeof(struct stat));
  68. -#if (LIBSSH2_APINO >= 200706012030)
  69. +#if HAVE_LIBSSH2_NBLOCK
  70. do {
  71. scp->ssh_channel = libssh2_scp_recv(scp->ssh_session, scp->path, &sb);
  72. if (!scp->ssh_channel &&
  73. @@ -1217,7 +1235,7 @@
  74. scp->path = NULL;
  75. if (scp->ssh_channel) {
  76. -#if (LIBSSH2_APINO >= 200706012030)
  77. +#if HAVE_LIBSSH2_NBLOCK
  78. if (conn->data->set.upload) {
  79. while ((rc = libssh2_channel_send_eof(scp->ssh_channel)) ==
  80. LIBSSH2_ERROR_EAGAIN);
  81. @@ -1248,7 +1266,7 @@
  82. }
  83. if (scp->ssh_session) {
  84. -#if (LIBSSH2_APINO >= 200706012030)
  85. +#if HAVE_LIBSSH2_NBLOCK
  86. while (libssh2_session_disconnect(scp->ssh_session, "Shutdown") ==
  87. LIBSSH2_ERROR_EAGAIN);
  88. #else /* !(LIBSSH2_APINO >= 200706012030) */
  89. @@ -1279,7 +1297,7 @@
  90. * NOTE: we should not store nor rely on connection-related data to be
  91. * in the SessionHandle struct
  92. */
  93. -#if defined(LIBSSH2CHANNEL_EAGAIN) && (LIBSSH2_APINO < 200706012030)
  94. +#if defined(LIBSSH2CHANNEL_EAGAIN) && defined(LIBSSH2_APINO) && (LIBSSH2_APINO < 200706012030)
  95. nwrite = (ssize_t)
  96. libssh2_channel_writenb(conn->data->reqdata.proto.ssh->ssh_channel,
  97. mem, len);
  98. @@ -1287,7 +1305,7 @@
  99. nwrite = (ssize_t)
  100. libssh2_channel_write(conn->data->reqdata.proto.ssh->ssh_channel,
  101. mem, len);
  102. -#if (LIBSSH2_APINO >= 200706012030)
  103. +#if HAVE_LIBSSH2_NBLOCK
  104. if (nwrite == LIBSSH2_ERROR_EAGAIN) {
  105. return 0;
  106. }
  107. @@ -1313,7 +1331,7 @@
  108. * in the SessionHandle struct
  109. */
  110. -#if defined(LIBSSH2CHANNEL_EAGAIN) && (LIBSSH2_APINO < 200706012030)
  111. +#if defined(LIBSSH2CHANNEL_EAGAIN) && defined(LIBSSH2_APINO) && (LIBSSH2_APINO < 200706012030)
  112. /* we prefer the non-blocking API but that didn't exist previously */
  113. nread = (ssize_t)
  114. libssh2_channel_readnb(conn->data->reqdata.proto.ssh->ssh_channel,
  115. @@ -1358,7 +1376,7 @@
  116. * If this is not done the destination file will be named the
  117. * same name as the last directory in the path.
  118. */
  119. -#if (LIBSSH2_APINO >= 200706012030)
  120. +#if HAVE_LIBSSH2_NBLOCK
  121. do {
  122. sftp->sftp_handle =
  123. libssh2_sftp_open(sftp->sftp_session, sftp->path,
  124. @@ -1446,7 +1464,7 @@
  125. int len, totalLen, currLen;
  126. char *line;
  127. -#if (LIBSSH2_APINO >= 200706012030)
  128. +#if HAVE_LIBSSH2_NBLOCK
  129. do {
  130. sftp->sftp_handle =
  131. libssh2_sftp_opendir(sftp->sftp_session, sftp->path);
  132. @@ -1471,7 +1489,7 @@
  133. #endif /* !(LIBSSH2_APINO >= 200706012030) */
  134. do {
  135. -#if (LIBSSH2_APINO >= 200706012030)
  136. +#if HAVE_LIBSSH2_NBLOCK
  137. while ((len = libssh2_sftp_readdir(sftp->sftp_handle, filename,
  138. PATH_MAX, &attrs)) ==
  139. LIBSSH2_ERROR_EAGAIN);
  140. @@ -1589,7 +1607,7 @@
  141. char linkPath[PATH_MAX + 1];
  142. snprintf(linkPath, PATH_MAX, "%s%s", sftp->path, filename);
  143. -#if (LIBSSH2_APINO >= 200706012030)
  144. +#if HAVE_LIBSSH2_NBLOCK
  145. while ((len = libssh2_sftp_readlink(sftp->sftp_session, linkPath,
  146. filename, PATH_MAX)) ==
  147. LIBSSH2_ERROR_EAGAIN);
  148. @@ -1614,7 +1632,7 @@
  149. break;
  150. }
  151. } while (1);
  152. -#if (LIBSSH2_APINO >= 200706012030)
  153. +#if HAVE_LIBSSH2_NBLOCK
  154. while (libssh2_sftp_closedir(sftp->sftp_handle) == LIBSSH2_ERROR_EAGAIN);
  155. #else /* !(LIBSSH2_APINO >= 200706012030) */
  156. libssh2_sftp_closedir(sftp->sftp_handle);
  157. @@ -1628,7 +1646,7 @@
  158. /*
  159. * Work on getting the specified file
  160. */
  161. -#if (LIBSSH2_APINO >= 200706012030)
  162. +#if HAVE_LIBSSH2_NBLOCK
  163. do {
  164. sftp->sftp_handle =
  165. libssh2_sftp_open(sftp->sftp_session, sftp->path, LIBSSH2_FXF_READ,
  166. @@ -1654,7 +1672,7 @@
  167. }
  168. #endif /* !(LIBSSH2_APINO >= 200706012030) */
  169. -#if (LIBSSH2_APINO >= 200706012030)
  170. +#if HAVE_LIBSSH2_NBLOCK
  171. while ((rc = libssh2_sftp_stat(sftp->sftp_session, sftp->path, &attrs))
  172. == LIBSSH2_ERROR_EAGAIN);
  173. #else /* !(LIBSSH2_APINO >= 200706012030) */
  174. @@ -1686,7 +1704,7 @@
  175. bytecount, FALSE, NULL, -1, NULL);
  176. #endif
  177. while (res == CURLE_OK) {
  178. -#if (LIBSSH2_APINO >= 200706012030)
  179. +#if HAVE_LIBSSH2_NBLOCK
  180. ssize_t nread;
  181. while ((nread = libssh2_sftp_read(data->reqdata.proto.ssh->sftp_handle,
  182. @@ -1702,7 +1720,7 @@
  183. if (nread > 0)
  184. buf[nread] = 0;
  185. -#if (LIBSSH2_APINO >= 200706012030)
  186. +#if HAVE_LIBSSH2_NBLOCK
  187. if (nread <= 0)
  188. break;
  189. #else /* !(LIBSSH2_APINO >= 200706012030) */
  190. @@ -1753,7 +1771,7 @@
  191. sftp->homedir = NULL;
  192. if (sftp->sftp_handle) {
  193. -#if (LIBSSH2_APINO >= 200706012030)
  194. +#if HAVE_LIBSSH2_NBLOCK
  195. while ((ret = libssh2_sftp_close(sftp->sftp_handle)) ==
  196. LIBSSH2_ERROR_EAGAIN);
  197. if (ret < 0) {
  198. @@ -1773,7 +1791,7 @@
  199. }
  200. if (sftp->sftp_session) {
  201. -#if (LIBSSH2_APINO >= 200706012030)
  202. +#if HAVE_LIBSSH2_NBLOCK
  203. while ((ret = libssh2_sftp_shutdown(sftp->sftp_session)) ==
  204. LIBSSH2_ERROR_EAGAIN);
  205. if (ret < 0) {
  206. @@ -1787,7 +1805,7 @@
  207. }
  208. if (sftp->ssh_channel) {
  209. -#if (LIBSSH2_APINO >= 200706012030)
  210. +#if HAVE_LIBSSH2_NBLOCK
  211. while ((ret = libssh2_channel_close(sftp->ssh_channel)) ==
  212. LIBSSH2_ERROR_EAGAIN);
  213. if (ret < 0) {
  214. @@ -1801,7 +1819,7 @@
  215. }
  216. if (sftp->ssh_session) {
  217. -#if (LIBSSH2_APINO >= 200706012030)
  218. +#if HAVE_LIBSSH2_NBLOCK
  219. while (libssh2_session_disconnect(sftp->ssh_session, "Shutdown") ==
  220. LIBSSH2_ERROR_EAGAIN);
  221. #else /* !(LIBSSH2_APINO >= 200706012030) */
  222. @@ -1828,14 +1846,14 @@
  223. ssize_t nwrite; /* libssh2_sftp_write() used to return size_t in 0.14
  224. but is changed to ssize_t in 0.15! */
  225. -#if defined(LIBSSH2SFTP_EAGAIN) && (LIBSSH2_APINO < 200706012030)
  226. +#if defined(LIBSSH2SFTP_EAGAIN) && defined(LIBSSH2_APINO) && (LIBSSH2_APINO < 200706012030)
  227. /* we prefer the non-blocking API but that didn't exist previously */
  228. nwrite = (ssize_t)
  229. libssh2_sftp_writenb(conn->data->reqdata.proto.ssh->sftp_handle, mem, len);
  230. #else
  231. nwrite = (ssize_t)
  232. libssh2_sftp_write(conn->data->reqdata.proto.ssh->sftp_handle, mem, len);
  233. -#if (LIBSSH2_APINO >= 200706012030)
  234. +#if HAVE_LIBSSH2_NBLOCK
  235. if (nwrite == LIBSSH2_ERROR_EAGAIN) {
  236. return 0;
  237. }
  238. @@ -1857,7 +1875,7 @@
  239. /* libssh2_sftp_read() returns size_t !*/
  240. -#if defined(LIBSSH2SFTP_EAGAIN) && (LIBSSH2_APINO < 200706012030)
  241. +#if defined(LIBSSH2SFTP_EAGAIN) && defined(LIBSSH2_APINO) && (LIBSSH2_APINO < 200706012030)
  242. /* we prefer the non-blocking API but that didn't exist previously */
  243. nread = (ssize_t)
  244. libssh2_sftp_readnb(conn->data->reqdata.proto.ssh->sftp_handle, mem, len);
  245. @@ -2058,7 +2076,7 @@
  246. return err;
  247. }
  248. memset(&attrs, 0, sizeof(LIBSSH2_SFTP_ATTRIBUTES));
  249. -#if (LIBSSH2_APINO >= 200706012030)
  250. +#if HAVE_LIBSSH2_NBLOCK
  251. while ((ret = libssh2_sftp_stat(sftp_session,
  252. path2, &attrs)) ==
  253. LIBSSH2_ERROR_EAGAIN);
  254. @@ -2112,7 +2130,7 @@
  255. }
  256. /* Now send the completed structure... */
  257. -#if (LIBSSH2_APINO >= 200706012030)
  258. +#if HAVE_LIBSSH2_NBLOCK
  259. while ((ret = libssh2_sftp_setstat(sftp_session, path2, &attrs)) ==
  260. LIBSSH2_ERROR_EAGAIN);
  261. if (ret != 0) {
  262. @@ -2148,7 +2166,7 @@
  263. free(path1);
  264. return err;
  265. }
  266. -#if (LIBSSH2_APINO >= 200706012030)
  267. +#if HAVE_LIBSSH2_NBLOCK
  268. while ((ret = libssh2_sftp_symlink(sftp_session, path1, path2)) ==
  269. LIBSSH2_ERROR_EAGAIN);
  270. if (ret != 0) {
  271. @@ -2171,7 +2189,7 @@
  272. #endif /* !(LIBSSH2_APINO >= 200706012030) */
  273. }
  274. else if (curl_strnequal(item->data, "mkdir ", 6)) { /* create dir */
  275. -#if (LIBSSH2_APINO >= 200706012030)
  276. +#if HAVE_LIBSSH2_NBLOCK
  277. while ((ret = libssh2_sftp_mkdir(sftp_session, path1, 0744)) ==
  278. LIBSSH2_ERROR_EAGAIN);
  279. if (ret != 0) {
  280. @@ -2202,7 +2220,7 @@
  281. free(path1);
  282. return err;
  283. }
  284. -#if (LIBSSH2_APINO >= 200706012030)
  285. +#if HAVE_LIBSSH2_NBLOCK
  286. while ((ret = libssh2_sftp_rename(sftp_session, path1, path2)) ==
  287. LIBSSH2_ERROR_EAGAIN);
  288. if (ret != 0) {
  289. @@ -2225,7 +2243,7 @@
  290. #endif /* !(LIBSSH2_APINO >= 200706012030) */
  291. }
  292. else if (curl_strnequal(item->data, "rmdir ", 6)) { /* delete dir */
  293. -#if (LIBSSH2_APINO >= 200706012030)
  294. +#if HAVE_LIBSSH2_NBLOCK
  295. while ((ret = libssh2_sftp_rmdir(sftp_session, path1)) ==
  296. LIBSSH2_ERROR_EAGAIN);
  297. if (ret != 0) {
  298. @@ -2246,7 +2264,7 @@
  299. #endif /* !(LIBSSH2_APINO >= 200706012030) */
  300. }
  301. else if (curl_strnequal(item->data, "rm ", 3)) { /* delete file */
  302. -#if (LIBSSH2_APINO >= 200706012030)
  303. +#if HAVE_LIBSSH2_NBLOCK
  304. while ((ret = libssh2_sftp_unlink(sftp_session, path1)) ==
  305. LIBSSH2_ERROR_EAGAIN);
  306. if (ret != 0) {
  307. @@ -2296,7 +2314,7 @@
  308. infof(conn->data, "Creating directory '%s'\n", sftp->path);
  309. /* 'mode' - parameter is preliminary - default to 0644 */
  310. -#if (LIBSSH2_APINO >= 200706012030)
  311. +#if HAVE_LIBSSH2_NBLOCK
  312. while ((rc = libssh2_sftp_mkdir(sftp->sftp_session, sftp->path,
  313. conn->data->set.new_directory_perms)) ==
  314. LIBSSH2_ERROR_EAGAIN);