summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2014-12-20 07:14:27 +0100
committerRemi Collet <fedora@famillecollet.com>2014-12-20 07:14:27 +0100
commitb19d09aa2aea5acd142de597e1fa77cb4462254f (patch)
treec8cd020fc7c529c73a564d38c6283a05dc7ef338
parent6d60df25b515671f7e99c1b39dd8422ddc366d5e (diff)
libssh2: 1.4.3 for EL-5 (sync with EL-7)
-rw-r--r--0001-sftp-seek-Don-t-flush-buffers-on-same-offset.patch54
-rw-r--r--0002-sftp-statvfs-Along-error-path-reset-the-correct-stat.patch26
-rw-r--r--0003-sftp-Add-support-for-fsync-OpenSSH-extension.patch223
-rw-r--r--0004-partially-revert-window_size-explicit-adjustments-on.patch69
-rw-r--r--0005-channel.c-fix-a-use-after-free.patch26
-rw-r--r--libssh2-1.4.2-utf8.patch14
-rw-r--r--libssh2.spec142
7 files changed, 510 insertions, 44 deletions
diff --git a/0001-sftp-seek-Don-t-flush-buffers-on-same-offset.patch b/0001-sftp-seek-Don-t-flush-buffers-on-same-offset.patch
new file mode 100644
index 0000000..9acbd6d
--- /dev/null
+++ b/0001-sftp-seek-Don-t-flush-buffers-on-same-offset.patch
@@ -0,0 +1,54 @@
+From 486bb376218a37fe15318d7724d6eada36b81e6c Mon Sep 17 00:00:00 2001
+From: "Richard W.M. Jones" <rjones@redhat.com>
+Date: Tue, 26 Mar 2013 17:58:04 +0100
+Subject: [PATCH 1/3] sftp: seek: Don't flush buffers on same offset
+
+Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
+---
+ src/sftp.c | 27 +++++++++++++++------------
+ 1 file changed, 15 insertions(+), 12 deletions(-)
+
+diff --git a/src/sftp.c b/src/sftp.c
+index d0536dd..3760025 100644
+--- a/src/sftp.c
++++ b/src/sftp.c
+@@ -2132,21 +2132,24 @@ libssh2_sftp_fstat_ex(LIBSSH2_SFTP_HANDLE *hnd,
+ LIBSSH2_API void
+ libssh2_sftp_seek64(LIBSSH2_SFTP_HANDLE *handle, libssh2_uint64_t offset)
+ {
+- if(handle) {
+- handle->u.file.offset = handle->u.file.offset_sent = offset;
+- /* discard all pending requests and currently read data */
+- sftp_packetlist_flush(handle);
++ if(!handle)
++ return;
++ if(handle->u.file.offset == offset && handle->u.file.offset_sent == offset)
++ return;
+
+- /* free the left received buffered data */
+- if (handle->u.file.data_left) {
+- LIBSSH2_FREE(handle->sftp->channel->session, handle->u.file.data);
+- handle->u.file.data_left = handle->u.file.data_len = 0;
+- handle->u.file.data = NULL;
+- }
++ handle->u.file.offset = handle->u.file.offset_sent = offset;
++ /* discard all pending requests and currently read data */
++ sftp_packetlist_flush(handle);
+
+- /* reset EOF to False */
+- handle->u.file.eof = FALSE;
++ /* free the left received buffered data */
++ if (handle->u.file.data_left) {
++ LIBSSH2_FREE(handle->sftp->channel->session, handle->u.file.data);
++ handle->u.file.data_left = handle->u.file.data_len = 0;
++ handle->u.file.data = NULL;
+ }
++
++ /* reset EOF to False */
++ handle->u.file.eof = FALSE;
+ }
+
+ /* libssh2_sftp_seek
+--
+1.8.1.4
+
diff --git a/0002-sftp-statvfs-Along-error-path-reset-the-correct-stat.patch b/0002-sftp-statvfs-Along-error-path-reset-the-correct-stat.patch
new file mode 100644
index 0000000..83ca15e
--- /dev/null
+++ b/0002-sftp-statvfs-Along-error-path-reset-the-correct-stat.patch
@@ -0,0 +1,26 @@
+From a12f3ffab579b514eeb7fdfaca0ade271961cdb4 Mon Sep 17 00:00:00 2001
+From: "Richard W.M. Jones" <rjones@redhat.com>
+Date: Mon, 8 Apr 2013 17:30:10 +0100
+Subject: [PATCH 2/3] sftp: statvfs: Along error path, reset the correct
+ 'state' variable.
+
+---
+ src/sftp.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/sftp.c b/src/sftp.c
+index 3760025..65fa77a 100644
+--- a/src/sftp.c
++++ b/src/sftp.c
+@@ -2752,7 +2752,7 @@ static int sftp_statvfs(LIBSSH2_SFTP *sftp, const char *path,
+ "Error waiting for FXP EXTENDED REPLY");
+ } else if (data_len < 93) {
+ LIBSSH2_FREE(session, data);
+- sftp->fstatvfs_state = libssh2_NB_state_idle;
++ sftp->statvfs_state = libssh2_NB_state_idle;
+ return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
+ "SFTP Protocol Error: short response");
+ }
+--
+1.8.1.4
+
diff --git a/0003-sftp-Add-support-for-fsync-OpenSSH-extension.patch b/0003-sftp-Add-support-for-fsync-OpenSSH-extension.patch
new file mode 100644
index 0000000..cc1cbb4
--- /dev/null
+++ b/0003-sftp-Add-support-for-fsync-OpenSSH-extension.patch
@@ -0,0 +1,223 @@
+From 6e0d757f24a45252c4cae9ea09732eda2562c767 Mon Sep 17 00:00:00 2001
+From: "Richard W.M. Jones" <rjones@redhat.com>
+Date: Tue, 9 Apr 2013 11:42:09 +0200
+Subject: [PATCH 3/3] sftp: Add support for fsync (OpenSSH extension).
+
+The new libssh2_sftp_fsync API causes data and metadata in the
+currently open file to be committed to disk at the server.
+
+This is an OpenSSH extension to the SFTP protocol. See:
+
+https://bugzilla.mindrot.org/show_bug.cgi?id=1798
+---
+ docs/Makefile.am | 1 +
+ docs/libssh2_sftp_fsync.3 | 39 +++++++++++++++++++
+ include/libssh2_sftp.h | 1 +
+ src/sftp.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++
+ src/sftp.h | 5 +++
+ 5 files changed, 143 insertions(+)
+ create mode 100644 docs/libssh2_sftp_fsync.3
+
+diff --git a/docs/Makefile.am b/docs/Makefile.am
+index e4cf487..e6ab394 100644
+--- a/docs/Makefile.am
++++ b/docs/Makefile.am
+@@ -120,6 +120,7 @@ dist_man_MANS = \
+ libssh2_sftp_fstat.3 \
+ libssh2_sftp_fstat_ex.3 \
+ libssh2_sftp_fstatvfs.3 \
++ libssh2_sftp_fsync.3 \
+ libssh2_sftp_get_channel.3 \
+ libssh2_sftp_init.3 \
+ libssh2_sftp_last_error.3 \
+diff --git a/docs/libssh2_sftp_fsync.3 b/docs/libssh2_sftp_fsync.3
+new file mode 100644
+index 0000000..646760a
+--- /dev/null
++++ b/docs/libssh2_sftp_fsync.3
+@@ -0,0 +1,39 @@
++.TH libssh2_sftp_fsync 3 "8 Apr 2013" "libssh2 1.4.4" "libssh2 manual"
++.SH NAME
++libssh2_sftp_fsync - synchronize file to disk
++.SH SYNOPSIS
++.nf
++#include <libssh2.h>
++#include <libssh2_sftp.h>
++
++int
++libssh2_sftp_fsync(LIBSSH2_SFTP_HANDLE *handle)
++.fi
++.SH DESCRIPTION
++This function causes the remote server to synchronize the file
++data and metadata to disk (like fsync(2)).
++
++For this to work requires fsync@openssh.com support on the server.
++
++\fIhandle\fP - SFTP File Handle as returned by
++.BR libssh2_sftp_open_ex(3)
++
++.SH RETURN VALUE
++Returns 0 on success or negative on failure. If used in non-blocking mode, it
++returns LIBSSH2_ERROR_EAGAIN when it would otherwise block. While
++LIBSSH2_ERROR_EAGAIN is a negative number, it isn't really a failure per se.
++.SH ERRORS
++\fILIBSSH2_ERROR_ALLOC\fP - An internal memory allocation call failed.
++
++\fILIBSSH2_ERROR_SOCKET_SEND\fP - Unable to send data on socket.
++
++\fILIBSSH2_ERROR_SFTP_PROTOCOL\fP - An invalid SFTP protocol response
++was received on the socket, or an SFTP operation caused an errorcode
++to be returned by the server. In particular, this can be returned if
++the SSH server does not support the fsync operation: the SFTP subcode
++\fILIBSSH2_FX_OP_UNSUPPORTED\fP will be returned in this case.
++
++.SH AVAILABILITY
++Added in libssh2 1.4.4 and OpenSSH 6.3.
++.SH SEE ALSO
++.BR fsync(2)
+diff --git a/include/libssh2_sftp.h b/include/libssh2_sftp.h
+index 74884fb..677faf2 100644
+--- a/include/libssh2_sftp.h
++++ b/include/libssh2_sftp.h
+@@ -247,6 +247,7 @@ LIBSSH2_API int libssh2_sftp_readdir_ex(LIBSSH2_SFTP_HANDLE *handle, \
+
+ LIBSSH2_API ssize_t libssh2_sftp_write(LIBSSH2_SFTP_HANDLE *handle,
+ const char *buffer, size_t count);
++LIBSSH2_API int libssh2_sftp_fsync(LIBSSH2_SFTP_HANDLE *handle);
+
+ LIBSSH2_API int libssh2_sftp_close_handle(LIBSSH2_SFTP_HANDLE *handle);
+ #define libssh2_sftp_close(handle) libssh2_sftp_close_handle(handle)
+diff --git a/src/sftp.c b/src/sftp.c
+index 65fa77a..01017fd 100644
+--- a/src/sftp.c
++++ b/src/sftp.c
+@@ -986,6 +986,10 @@ sftp_shutdown(LIBSSH2_SFTP *sftp)
+ LIBSSH2_FREE(session, sftp->symlink_packet);
+ sftp->symlink_packet = NULL;
+ }
++ if (sftp->fsync_packet) {
++ LIBSSH2_FREE(session, sftp->fsync_packet);
++ sftp->fsync_packet = NULL;
++ }
+
+ sftp_packet_flush(sftp);
+
+@@ -2014,6 +2018,99 @@ libssh2_sftp_write(LIBSSH2_SFTP_HANDLE *hnd, const char *buffer,
+
+ }
+
++static int sftp_fsync(LIBSSH2_SFTP_HANDLE *handle)
++{
++ LIBSSH2_SFTP *sftp = handle->sftp;
++ LIBSSH2_CHANNEL *channel = sftp->channel;
++ LIBSSH2_SESSION *session = channel->session;
++ /* 34 = packet_len(4) + packet_type(1) + request_id(4) +
++ string_len(4) + strlen("fsync@openssh.com")(17) + handle_len(4) */
++ uint32_t packet_len = handle->handle_len + 34;
++ size_t data_len;
++ unsigned char *packet, *s, *data;
++ ssize_t rc;
++ uint32_t retcode;
++
++ if (sftp->fsync_state == libssh2_NB_state_idle) {
++ _libssh2_debug(session, LIBSSH2_TRACE_SFTP,
++ "Issuing fsync command");
++ s = packet = LIBSSH2_ALLOC(session, packet_len);
++ if (!packet) {
++ return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
++ "Unable to allocate memory for FXP_EXTENDED "
++ "packet");
++ }
++
++ _libssh2_store_u32(&s, packet_len - 4);
++ *(s++) = SSH_FXP_EXTENDED;
++ sftp->fsync_request_id = sftp->request_id++;
++ _libssh2_store_u32(&s, sftp->fsync_request_id);
++ _libssh2_store_str(&s, "fsync@openssh.com", 17);
++ _libssh2_store_str(&s, handle->handle, handle->handle_len);
++
++ sftp->fsync_state = libssh2_NB_state_created;
++ } else {
++ packet = sftp->fsync_packet;
++ }
++
++ if (sftp->fsync_state == libssh2_NB_state_created) {
++ rc = _libssh2_channel_write(channel, 0, packet, packet_len);
++ if (rc == LIBSSH2_ERROR_EAGAIN ||
++ (0 <= rc && rc < (ssize_t)packet_len)) {
++ sftp->fsync_packet = packet;
++ return LIBSSH2_ERROR_EAGAIN;
++ }
++
++ LIBSSH2_FREE(session, packet);
++ sftp->fsync_packet = NULL;
++
++ if (rc < 0) {
++ sftp->fsync_state = libssh2_NB_state_idle;
++ return _libssh2_error(session, LIBSSH2_ERROR_SOCKET_SEND,
++ "_libssh2_channel_write() failed");
++ }
++ sftp->fsync_state = libssh2_NB_state_sent;
++ }
++
++ rc = sftp_packet_require(sftp, SSH_FXP_STATUS,
++ sftp->fsync_request_id, &data, &data_len);
++ if (rc == LIBSSH2_ERROR_EAGAIN) {
++ return rc;
++ } else if (rc) {
++ sftp->fsync_state = libssh2_NB_state_idle;
++ return _libssh2_error(session, rc,
++ "Error waiting for FXP EXTENDED REPLY");
++ }
++
++ sftp->fsync_state = libssh2_NB_state_idle;
++
++ retcode = _libssh2_ntohu32(data + 5);
++ LIBSSH2_FREE(session, data);
++
++ if (retcode != LIBSSH2_FX_OK) {
++ sftp->last_errno = retcode;
++ return _libssh2_error(session, LIBSSH2_ERROR_SFTP_PROTOCOL,
++ "fsync failed");
++ }
++
++ return 0;
++}
++
++/* libssh2_sftp_fsync
++ * Commit data on the handle to disk.
++ */
++LIBSSH2_API int
++libssh2_sftp_fsync(LIBSSH2_SFTP_HANDLE *hnd)
++{
++ int rc;
++ if(!hnd)
++ return LIBSSH2_ERROR_BAD_USE;
++ BLOCK_ADJUST(rc, hnd->sftp->channel->session,
++ sftp_fsync(hnd));
++ return rc;
++}
++
++
+ /*
+ * sftp_fstat
+ *
+diff --git a/src/sftp.h b/src/sftp.h
+index 55bdb46..63e8139 100644
+--- a/src/sftp.h
++++ b/src/sftp.h
+@@ -175,6 +175,11 @@ struct _LIBSSH2_SFTP
+ /* State variable used in sftp_write() */
+ libssh2_nonblocking_states write_state;
+
++ /* State variables used in sftp_fsync() */
++ libssh2_nonblocking_states fsync_state;
++ unsigned char *fsync_packet;
++ uint32_t fsync_request_id;
++
+ /* State variables used in libssh2_sftp_readdir() */
+ libssh2_nonblocking_states readdir_state;
+ unsigned char *readdir_packet;
+--
+1.8.1.4
+
diff --git a/0004-partially-revert-window_size-explicit-adjustments-on.patch b/0004-partially-revert-window_size-explicit-adjustments-on.patch
new file mode 100644
index 0000000..fe7751a
--- /dev/null
+++ b/0004-partially-revert-window_size-explicit-adjustments-on.patch
@@ -0,0 +1,69 @@
+From 9e56b84c41efcaf3349f82a93c3dc854e172e5c4 Mon Sep 17 00:00:00 2001
+From: Kamil Dudka <kdudka@redhat.com>
+Date: Fri, 9 Aug 2013 16:22:08 +0200
+Subject: [PATCH 4/5] partially revert "window_size: explicit adjustments only"
+
+This partially reverts commit 03ca9020756a4e16f0294e5b35e9826ee6af2364
+in order to fix extreme slowdown when uploading to localhost via SFTP.
+
+I was able to repeat the issue on RHEL-7 on localhost only. It did not
+occur when uploading via network and it did not occur on a RHEL-6 box
+with the same version of libssh2.
+
+The problem was that sftp_read() used a read-ahead logic to figure out
+the window_size, but sftp_packet_read() called indirectly from
+sftp_write() did not use any read-ahead logic.
+---
+ src/channel.c | 29 +++++++++++++++++++++++++++++
+ 1 files changed, 29 insertions(+), 0 deletions(-)
+
+diff --git a/src/channel.c b/src/channel.c
+index 4f41e1f..d4ffdce 100644
+--- a/src/channel.c
++++ b/src/channel.c
+@@ -1759,6 +1759,15 @@ ssize_t _libssh2_channel_read(LIBSSH2_CHANNEL *channel, int stream_id,
+ channel->read_state = libssh2_NB_state_created;
+ }
+
++ /*
++ * =============================== NOTE ===============================
++ * I know this is very ugly and not a really good use of "goto", but
++ * this case statement would be even uglier to do it any other way
++ */
++ if (channel->read_state == libssh2_NB_state_jump1) {
++ goto channel_read_window_adjust;
++ }
++
+ rc = 1; /* set to >0 to let the while loop start */
+
+ /* Process all pending incoming packets in all states in order to "even
+@@ -1867,6 +1876,26 @@ ssize_t _libssh2_channel_read(LIBSSH2_CHANNEL *channel, int stream_id,
+ more off the network again */
+ channel->read_state = libssh2_NB_state_created;
+
++ if(channel->remote.window_size < (LIBSSH2_CHANNEL_WINDOW_DEFAULT*30)) {
++ /* the window is getting too narrow, expand it! */
++
++ channel_read_window_adjust:
++ channel->read_state = libssh2_NB_state_jump1;
++ /* the actual window adjusting may not finish so we need to deal with
++ this special state here */
++ rc = _libssh2_channel_receive_window_adjust(channel,
++ (LIBSSH2_CHANNEL_WINDOW_DEFAULT*60), 0, NULL);
++ if (rc)
++ return rc;
++
++ _libssh2_debug(session, LIBSSH2_TRACE_CONN,
++ "channel_read() filled %d adjusted %d",
++ bytes_read, buflen);
++ /* continue in 'created' state to drain the already read packages
++ first before starting to empty the socket further */
++ channel->read_state = libssh2_NB_state_created;
++ }
++
+ return bytes_read;
+ }
+
+--
+1.7.1
+
diff --git a/0005-channel.c-fix-a-use-after-free.patch b/0005-channel.c-fix-a-use-after-free.patch
new file mode 100644
index 0000000..8fa0a05
--- /dev/null
+++ b/0005-channel.c-fix-a-use-after-free.patch
@@ -0,0 +1,26 @@
+From 96e1078fced70e39e4163857ad8345ae9d24573f Mon Sep 17 00:00:00 2001
+From: Kamil Dudka <kdudka@redhat.com>
+Date: Wed, 14 Aug 2013 17:37:00 +0200
+Subject: [PATCH 5/5] channel.c: fix a use after free
+
+Bug: https://trac.libssh2.org/ticket/268
+---
+ src/channel.c | 2 --
+ 1 files changed, 0 insertions(+), 2 deletions(-)
+
+diff --git a/src/channel.c b/src/channel.c
+index d4ffdce..9f2c241 100644
+--- a/src/channel.c
++++ b/src/channel.c
+@@ -670,8 +670,6 @@ int _libssh2_channel_forward_cancel(LIBSSH2_LISTENER *listener)
+
+ LIBSSH2_FREE(session, listener);
+
+- listener->chanFwdCncl_state = libssh2_NB_state_idle;
+-
+ return 0;
+ }
+
+--
+1.7.1
+
diff --git a/libssh2-1.4.2-utf8.patch b/libssh2-1.4.2-utf8.patch
new file mode 100644
index 0000000..9177691
--- /dev/null
+++ b/libssh2-1.4.2-utf8.patch
@@ -0,0 +1,14 @@
+ NEWS | 2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+--- libssh2/NEWS
++++ libssh2/NEWS
+@@ -3552,7 +3552,7 @@ Simon Josefsson (16 Nov 2009)
+ - support arcfour128 cipher per RFC 4345
+
+ Daniel Stenberg (21 Oct 2009)
+-- [Cristian Rodríguez brought this change]
++- [Cristian Rodríguez brought this change]
+
+ add support for GCC visibility features
+
diff --git a/libssh2.spec b/libssh2.spec
index 81ed0ba..16bce64 100644
--- a/libssh2.spec
+++ b/libssh2.spec
@@ -1,19 +1,43 @@
+# Fedora 10 onwards support noarch subpackages; by using one, we can
+# put the arch-independent docs in a common subpackage and save lots
+# of space on the mirrors
+%if 0%{?fedora} > 9 || 0%{?rhel} > 5
+%global noarch_docs_package 1
+%else
+%global noarch_docs_package 0
+%endif
+
+# Define %%{__isa_bits} for old releases
+%{!?__isa_bits: %global __isa_bits %((echo '#include <bits/wordsize.h>'; echo __WORDSIZE) | cpp - | grep -Ex '32|64')}
+
Name: libssh2
-Version: 1.2.7
-Release: 1%{?dist}
+Version: 1.4.3
+Release: 8%{?dist}
Summary: A library implementing the SSH2 protocol
-
Group: System Environment/Libraries
License: BSD
-URL: http://www.libssh2.org
+URL: http://www.libssh2.org/
Source0: http://libssh2.org/download/libssh2-%{version}.tar.gz
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-
+Patch0: libssh2-1.4.2-utf8.patch
+Patch1: 0001-sftp-seek-Don-t-flush-buffers-on-same-offset.patch
+Patch2: 0002-sftp-statvfs-Along-error-path-reset-the-correct-stat.patch
+Patch3: 0003-sftp-Add-support-for-fsync-OpenSSH-extension.patch
+Patch4: 0004-partially-revert-window_size-explicit-adjustments-on.patch
+Patch5: 0005-channel.c-fix-a-use-after-free.patch
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(id -nu)
BuildRequires: openssl-devel
BuildRequires: zlib-devel
+BuildRequires: /usr/bin/man
-# tests
+# Test suite requirements - we run the OpenSSH server and try to connect to it
BuildRequires: openssh-server
+# We use matchpathcon to get the correct SELinux context for the ssh server
+# initialization script so that it can transition correctly in an SELinux
+# environment; matchpathcon is only available from FC-4 and moved from the
+# libselinux to libselinux-utils package in F-10
+%if (0%{?fedora} >= 4 || 0%{?rhel} >= 5) && !(0%{?fedora} >=17 || 0%{?rhel} >=7)
+BuildRequires: /usr/sbin/matchpathcon selinux-policy-targeted
+%endif
%description
libssh2 is a library implementing the SSH2 protocol as defined by
@@ -21,93 +45,123 @@ Internet Drafts: SECSH-TRANS(22), SECSH-USERAUTH(25),
SECSH-CONNECTION(23), SECSH-ARCH(20), SECSH-FILEXFER(06)*,
SECSH-DHGEX(04), and SECSH-NUMBERS(10).
-
%package devel
-Summary: Development files for %{name}
+Summary: Development files for libssh2
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
Requires: pkgconfig
%description devel
-The %{name}-devel package contains libraries and header files for
-developing applications that use %{name}.
+The libssh2-devel package contains libraries and header files for
+developing applications that use libssh2.
%package docs
-Summary: Documentation for %{name}
+Summary: Documentation for libssh2
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
+%if %{noarch_docs_package}
+BuildArch: noarch
+%endif
%description docs
-The %{name}-docs package contains man pages and examples for
-developing applications that use %{name}.
-
+The libssh2-docs package contains man pages and examples for
+developing applications that use libssh2.
%prep
%setup -q
-# make sure things are UTF-8...
-for i in ChangeLog NEWS ; do
- iconv --from=ISO-8859-1 --to=UTF-8 $i > new
- mv new $i
-done
+# Replace hard wired port number in the test suite to avoid collisions
+# between 32-bit and 64-bit builds running on a single build-host
+sed -i s/4711/47%{?__isa_bits}/ tests/ssh2.{c,sh}
+
+# Make sure things are UTF-8...
+%patch0 -p1
+
+# Three upstream patches required for qemu ssh block driver.
+%patch1 -p1
+%patch2 -p1
+%patch3 -p1
-# make it possible to launch OpenSSH server for testing purposes
-chcon -t initrc_exec_t tests/ssh2.sh || :
-chcon -Rt etc_t tests/etc || :
-chcon -t sshd_key_t tests/etc/{host,user} || :
+# http://thread.gmane.org/gmane.network.ssh.libssh2.devel/6428
+%patch4 -p1
+
+# https://trac.libssh2.org/ticket/268
+%patch5 -p1
+
+# Make sshd transition appropriately if building in an SELinux environment
+%if !(0%{?fedora} >= 17 || 0%{?rhel} >= 7)
+chcon $(/usr/sbin/matchpathcon -n /etc/rc.d/init.d/sshd) tests/ssh2.sh || :
+chcon -R $(/usr/sbin/matchpathcon -n /etc) tests/etc || :
+chcon $(/usr/sbin/matchpathcon -n /etc/ssh/ssh_host_key) tests/etc/{host,user} || :
+%endif
%build
%configure --disable-static --enable-shared
-
make %{?_smp_mflags}
+# Avoid polluting libssh2.pc with linker options (#947813)
+sed -i -e 's|[[:space:]]-Wl,[^[:space:]]*||' libssh2.pc
%install
rm -rf %{buildroot}
-
make install DESTDIR=%{buildroot} INSTALL="install -p"
-find %{buildroot} -name '*.la' -exec rm -f {} +
+find %{buildroot} -name '*.la' -exec rm -f {} \;
# clean things up a bit for packaging
-( cd example && make clean )
-find example/ -type d -name .deps -exec rm -rf {} +
-find example/ -type f '(' -name '*.am' -o -name '*.in' ')' -exec rm -v {} +
+make -C example clean
+rm -rf example/.deps
+find example/ -type f '(' -name '*.am' -o -name '*.in' ')' -exec rm -v {} \;
-# avoid multilib conflict on libssh2-docs
-mv -v example/Makefile example/Makefile.%{_arch}
+# avoid multilib conflict on libssh2-devel
+mv -v example example.%{_arch}
%check
-# sshd/loopback test fails under local build, with selinux enforcing
-%{?_without_sshd_tests:echo "Skipping sshd tests" ; echo "exit 0" > tests/ssh2.sh }
-(cd tests && make check)
+# The SSH test will fail if we don't have /dev/tty, as is the case in some
+# versions of mock (#672713)
+if [ ! -c /dev/tty ]; then
+ echo Skipping SSH test due to missing /dev/tty
+ echo "exit 0" > tests/ssh2.sh
+fi
+# Apparently it fails in the sparc and arm buildsystems too
+%ifarch %{sparc} %{arm}
+echo Skipping SSH test on sparc/arm
+echo "exit 0" > tests/ssh2.sh
+%endif
+make -C tests check
%clean
rm -rf %{buildroot}
-
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
-
%files
%defattr(-,root,root,-)
%doc AUTHORS ChangeLog COPYING README NEWS
-%{_libdir}/*.so.*
+%{_libdir}/libssh2.so.1
+%{_libdir}/libssh2.so.1.*
%files docs
%defattr(-,root,root,-)
-%doc COPYING HACKING example/
-%{_mandir}/man?/*
+%doc HACKING
+%{_mandir}/man3/libssh2_*.3*
%files devel
%defattr(-,root,root,-)
-%doc COPYING
-%{_includedir}/*
-%{_libdir}/*.so
-%{_libdir}/pkgconfig/*
+%doc example.%{_arch}/
+%{_includedir}/libssh2.h
+%{_includedir}/libssh2_publickey.h
+%{_includedir}/libssh2_sftp.h
+%{_libdir}/libssh2.so
+%{_libdir}/pkgconfig/libssh2.pc
%changelog
+* Sat Dec 20 2014 Remi Collet <RPMS@FamilleCollet.com> 1.4.3-8
+- sync with 1.4.3-8 from RHEL-7
+- ABI is compatible according to ABI compliance checker
+ http://upstream.rosalinux.ru/versions/libssh2.html
+
* Sun Jul 24 2011 Remi Collet <RPMS@FamilleCollet.com> 1.2.7-1
- rebuild for remi repo (EL-5)