Explorar o código

allow one to build cURL with SSH support

Ralf S. Engelschall %!s(int64=18) %!d(string=hai) anos
pai
achega
88dd62cfdc
Modificáronse 2 ficheiros con 335 adicións e 2 borrados
  1. 325 1
      curl/curl.patch
  2. 10 1
      curl/curl.spec

+ 325 - 1
curl/curl.patch

@@ -1,6 +1,6 @@
 Index: lib/ftp.c
 --- lib/ftp.c.orig	2007-07-02 00:01:19 +0200
-+++ lib/ftp.c	2007-07-20 09:20:11 +0200
++++ lib/ftp.c	2007-08-29 10:07:14 +0200
 @@ -2371,8 +2371,7 @@
    struct ftp_conn *ftpc = &conn->proto.ftpc;
    (void)instate; /* no use for this yet */
@@ -11,3 +11,327 @@ Index: lib/ftp.c
      /* 331 Password required for ...
         (the server requires to send the user's password too) */
      NBFTPSENDF(conn, "PASS %s", ftp->passwd?ftp->passwd:"");
+Index: lib/ssh.c
+--- lib/ssh.c.orig	2007-07-06 22:13:24 +0200
++++ lib/ssh.c	2007-08-29 10:07:14 +0200
+@@ -70,6 +70,24 @@
+ #endif
+ #endif /* !WIN32 */
+ 
++#if defined(LIBSSH2_VERSION_NUM)
++# if LIBSSH2_VERSION_NUM >= 0x001000
++#  define HAVE_LIBSSH2_NBLOCK 1
++# else
++#  define HAVE_LIBSSH2_NBLOCK 0
++# endif
++#else /* !defined(LIBSSH2_VERSION_NUM) */
++# if defined(LIBSSH2_APINO)
++#  if LIBSSH2_APINO >= 200706012030
++#   define HAVE_LIBSSH2_NBLOCK 1
++#  else
++#   define HAVE_LIBSSH2_NBLOCK 0
++#  endif
++# else /* !defined(LIBSSH2_APINO) */
++#  define HAVE_LIBSSH2_NBLOCK 0
++# endif /* defined(LIBSSH2_APINO) */
++#endif /* defined(LIBSSH2_VERSION_NUM) */
++
+ #if (defined(NETWARE) && defined(__NOVELL_LIBC__))
+ #undef in_addr_t
+ #define in_addr_t unsigned long
+@@ -239,7 +257,7 @@
+   (void)abstract;
+ }
+ 
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+ /*
+  * SSH State machine related code
+  */
+@@ -854,7 +872,7 @@
+   infof(data, "SSH socket: %d\n", sock);
+ #endif /* CURL_LIBSSH2_DEBUG */
+ 
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+   state(conn, SSH_S_STARTUP);
+ 
+   if (data->state.used_interface == Curl_if_multi)
+@@ -1134,7 +1152,7 @@
+      * the destination file will be named the same name as the last directory
+      * in the path.
+      */
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+     do {
+       scp->ssh_channel = libssh2_scp_send_ex(scp->ssh_session, scp->path,
+                                              conn->data->set.new_file_perms,
+@@ -1169,7 +1187,7 @@
+      */
+     curl_off_t bytecount;
+     memset(&sb, 0, sizeof(struct stat));
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+     do {
+       scp->ssh_channel = libssh2_scp_recv(scp->ssh_session, scp->path, &sb);
+       if (!scp->ssh_channel &&
+@@ -1217,7 +1235,7 @@
+   scp->path = NULL;
+ 
+   if (scp->ssh_channel) {
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+     if (conn->data->set.upload) {
+       while ((rc = libssh2_channel_send_eof(scp->ssh_channel)) ==
+              LIBSSH2_ERROR_EAGAIN);
+@@ -1248,7 +1266,7 @@
+   }
+ 
+   if (scp->ssh_session) {
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+     while (libssh2_session_disconnect(scp->ssh_session, "Shutdown") ==
+            LIBSSH2_ERROR_EAGAIN);
+ #else /* !(LIBSSH2_APINO >= 200706012030) */
+@@ -1279,7 +1297,7 @@
+    * NOTE: we should not store nor rely on connection-related data to be
+    * in the SessionHandle struct
+    */
+-#if defined(LIBSSH2CHANNEL_EAGAIN) && (LIBSSH2_APINO < 200706012030)
++#if defined(LIBSSH2CHANNEL_EAGAIN) && defined(LIBSSH2_APINO) && (LIBSSH2_APINO < 200706012030)
+   nwrite = (ssize_t)
+     libssh2_channel_writenb(conn->data->reqdata.proto.ssh->ssh_channel,
+                             mem, len);
+@@ -1287,7 +1305,7 @@
+   nwrite = (ssize_t)
+     libssh2_channel_write(conn->data->reqdata.proto.ssh->ssh_channel,
+                           mem, len);
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+   if (nwrite == LIBSSH2_ERROR_EAGAIN) {
+     return 0;
+   }
+@@ -1313,7 +1331,7 @@
+    * in the SessionHandle struct
+    */
+ 
+-#if defined(LIBSSH2CHANNEL_EAGAIN) && (LIBSSH2_APINO < 200706012030)
++#if defined(LIBSSH2CHANNEL_EAGAIN) && defined(LIBSSH2_APINO) && (LIBSSH2_APINO < 200706012030)
+   /* we prefer the non-blocking API but that didn't exist previously */
+   nread = (ssize_t)
+     libssh2_channel_readnb(conn->data->reqdata.proto.ssh->ssh_channel,
+@@ -1358,7 +1376,7 @@
+      *          If this is not done the destination file will be named the
+      *          same name as the last directory in the path.
+      */
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+     do {
+       sftp->sftp_handle =
+         libssh2_sftp_open(sftp->sftp_session, sftp->path,
+@@ -1446,7 +1464,7 @@
+       int len, totalLen, currLen;
+       char *line;
+ 
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+       do {
+         sftp->sftp_handle =
+           libssh2_sftp_opendir(sftp->sftp_session, sftp->path);
+@@ -1471,7 +1489,7 @@
+ #endif /* !(LIBSSH2_APINO >= 200706012030) */
+ 
+       do {
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+         while ((len = libssh2_sftp_readdir(sftp->sftp_handle, filename,
+                                            PATH_MAX, &attrs)) ==
+                LIBSSH2_ERROR_EAGAIN);
+@@ -1589,7 +1607,7 @@
+               char linkPath[PATH_MAX + 1];
+ 
+               snprintf(linkPath, PATH_MAX, "%s%s", sftp->path, filename);
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+               while ((len = libssh2_sftp_readlink(sftp->sftp_session, linkPath,
+                                                   filename, PATH_MAX)) ==
+                      LIBSSH2_ERROR_EAGAIN);
+@@ -1614,7 +1632,7 @@
+           break;
+         }
+       } while (1);
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+       while (libssh2_sftp_closedir(sftp->sftp_handle) == LIBSSH2_ERROR_EAGAIN);
+ #else /* !(LIBSSH2_APINO >= 200706012030) */
+       libssh2_sftp_closedir(sftp->sftp_handle);
+@@ -1628,7 +1646,7 @@
+       /*
+        * Work on getting the specified file
+        */
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+       do {
+         sftp->sftp_handle =
+           libssh2_sftp_open(sftp->sftp_session, sftp->path, LIBSSH2_FXF_READ,
+@@ -1654,7 +1672,7 @@
+       }
+ #endif /* !(LIBSSH2_APINO >= 200706012030) */
+ 
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+       while ((rc = libssh2_sftp_stat(sftp->sftp_session, sftp->path, &attrs))
+              == LIBSSH2_ERROR_EAGAIN);
+ #else /* !(LIBSSH2_APINO >= 200706012030) */
+@@ -1686,7 +1704,7 @@
+                                 bytecount, FALSE, NULL, -1, NULL);
+ #endif
+       while (res == CURLE_OK) {
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+         ssize_t nread;
+ 
+         while ((nread = libssh2_sftp_read(data->reqdata.proto.ssh->sftp_handle,
+@@ -1702,7 +1720,7 @@
+         if (nread > 0)
+           buf[nread] = 0;
+ 
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+         if (nread <= 0)
+           break;
+ #else /* !(LIBSSH2_APINO >= 200706012030) */
+@@ -1753,7 +1771,7 @@
+   sftp->homedir = NULL;
+ 
+   if (sftp->sftp_handle) {
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+     while ((ret = libssh2_sftp_close(sftp->sftp_handle)) ==
+            LIBSSH2_ERROR_EAGAIN);
+     if (ret < 0) {
+@@ -1773,7 +1791,7 @@
+   }
+ 
+   if (sftp->sftp_session) {
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+     while ((ret = libssh2_sftp_shutdown(sftp->sftp_session)) ==
+            LIBSSH2_ERROR_EAGAIN);
+     if (ret < 0) {
+@@ -1787,7 +1805,7 @@
+   }
+ 
+   if (sftp->ssh_channel) {
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+     while ((ret = libssh2_channel_close(sftp->ssh_channel)) ==
+            LIBSSH2_ERROR_EAGAIN);
+     if (ret < 0) {
+@@ -1801,7 +1819,7 @@
+   }
+ 
+   if (sftp->ssh_session) {
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+     while (libssh2_session_disconnect(sftp->ssh_session, "Shutdown") ==
+            LIBSSH2_ERROR_EAGAIN);
+ #else /* !(LIBSSH2_APINO >= 200706012030) */
+@@ -1828,14 +1846,14 @@
+   ssize_t nwrite;   /* libssh2_sftp_write() used to return size_t in 0.14
+                        but is changed to ssize_t in 0.15! */
+ 
+-#if defined(LIBSSH2SFTP_EAGAIN) && (LIBSSH2_APINO < 200706012030)
++#if defined(LIBSSH2SFTP_EAGAIN) && defined(LIBSSH2_APINO) && (LIBSSH2_APINO < 200706012030)
+   /* we prefer the non-blocking API but that didn't exist previously */
+   nwrite = (ssize_t)
+     libssh2_sftp_writenb(conn->data->reqdata.proto.ssh->sftp_handle, mem, len);
+ #else
+   nwrite = (ssize_t)
+     libssh2_sftp_write(conn->data->reqdata.proto.ssh->sftp_handle, mem, len);
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+   if (nwrite == LIBSSH2_ERROR_EAGAIN) {
+     return 0;
+   }
+@@ -1857,7 +1875,7 @@
+ 
+   /* libssh2_sftp_read() returns size_t !*/
+ 
+-#if defined(LIBSSH2SFTP_EAGAIN) && (LIBSSH2_APINO < 200706012030)
++#if defined(LIBSSH2SFTP_EAGAIN) && defined(LIBSSH2_APINO) && (LIBSSH2_APINO < 200706012030)
+   /* we prefer the non-blocking API but that didn't exist previously */
+   nread = (ssize_t)
+     libssh2_sftp_readnb(conn->data->reqdata.proto.ssh->sftp_handle, mem, len);
+@@ -2058,7 +2076,7 @@
+           return err;
+         }
+         memset(&attrs, 0, sizeof(LIBSSH2_SFTP_ATTRIBUTES));
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+         while ((ret = libssh2_sftp_stat(sftp_session,
+                                         path2, &attrs)) ==
+                LIBSSH2_ERROR_EAGAIN);
+@@ -2112,7 +2130,7 @@
+         }
+ 
+         /* Now send the completed structure... */
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+         while ((ret = libssh2_sftp_setstat(sftp_session, path2, &attrs)) ==
+                LIBSSH2_ERROR_EAGAIN);
+         if (ret != 0) {
+@@ -2148,7 +2166,7 @@
+           free(path1);
+           return err;
+         }
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+         while ((ret = libssh2_sftp_symlink(sftp_session, path1, path2)) ==
+                LIBSSH2_ERROR_EAGAIN);
+         if (ret != 0) {
+@@ -2171,7 +2189,7 @@
+ #endif /* !(LIBSSH2_APINO >= 200706012030) */
+       }
+       else if (curl_strnequal(item->data, "mkdir ", 6)) { /* create dir */
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+         while ((ret = libssh2_sftp_mkdir(sftp_session, path1, 0744)) ==
+                LIBSSH2_ERROR_EAGAIN);
+         if (ret != 0) {
+@@ -2202,7 +2220,7 @@
+           free(path1);
+           return err;
+         }
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+         while ((ret = libssh2_sftp_rename(sftp_session, path1, path2)) ==
+                LIBSSH2_ERROR_EAGAIN);
+         if (ret != 0) {
+@@ -2225,7 +2243,7 @@
+ #endif /* !(LIBSSH2_APINO >= 200706012030) */
+       }
+       else if (curl_strnequal(item->data, "rmdir ", 6)) { /* delete dir */
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+         while ((ret = libssh2_sftp_rmdir(sftp_session, path1)) ==
+                LIBSSH2_ERROR_EAGAIN);
+         if (ret != 0) {
+@@ -2246,7 +2264,7 @@
+ #endif /* !(LIBSSH2_APINO >= 200706012030) */
+       }
+       else if (curl_strnequal(item->data, "rm ", 3)) { /* delete file */
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+         while ((ret = libssh2_sftp_unlink(sftp_session, path1)) ==
+                LIBSSH2_ERROR_EAGAIN);
+         if (ret != 0) {
+@@ -2296,7 +2314,7 @@
+ 
+       infof(conn->data, "Creating directory '%s'\n", sftp->path);
+       /* 'mode' - parameter is preliminary - default to 0644 */
+-#if (LIBSSH2_APINO >= 200706012030)
++#if HAVE_LIBSSH2_NBLOCK
+       while ((rc = libssh2_sftp_mkdir(sftp->sftp_session, sftp->path,
+                                       conn->data->set.new_directory_perms)) ==
+              LIBSSH2_ERROR_EAGAIN);

+ 10 - 1
curl/curl.spec

@@ -33,11 +33,12 @@ Class:        BASE
 Group:        Web
 License:      MIT-style
 Version:      7.16.4
-Release:      20070720
+Release:      20070829
 
 #   package options
 %option       with_ssl       yes
 %option       with_zlib      yes
+%option       with_ssh       no
 %option       with_idn       no
 %option       with_ares      no
 %option       with_kerberos  no
@@ -71,6 +72,10 @@ PreReq:       ares
 BuildPreReq:  kerberos
 PreReq:       kerberos
 %endif
+%if "%{with_ssh}" == "yes"
+BuildPreReq:  libssh2
+PreReq:       libssh2
+%endif
 AutoReq:      no
 AutoReqProv:  no
 
@@ -141,7 +146,11 @@ AutoReqProv:  no
 %else
         --without-gssapi \
 %endif
+%if "%{with_ssh}" == "yes"
+        --with-libssh2=%{l_prefix} \
+%else
         --without-libssh2 \
+%endif
         --disable-shared
     %{l_make} %{l_mflags -O}