[python26-paramiko: 24/33] - Fix race condition (#526341)

Andy Grimm arg at fedoraproject.org
Thu Jul 7 00:42:09 UTC 2011


commit 10225f4aa95217ce4ece5891dd7e7bac61142867
Author: Jeremy Katz <katzj at fedoraproject.org>
Date:   Wed Oct 14 01:57:55 2009 +0000

    - Fix race condition (#526341)

 paramiko-channel-race.patch |  103 +++++++++++++++++++++++++++++++++++++++++++
 python-paramiko.spec        |    7 +++-
 2 files changed, 109 insertions(+), 1 deletions(-)
---
diff --git a/paramiko-channel-race.patch b/paramiko-channel-race.patch
new file mode 100644
index 0000000..9c43e63
--- /dev/null
+++ b/paramiko-channel-race.patch
@@ -0,0 +1,103 @@
+Index: paramiko/channel.py
+===================================================================
+--- paramiko/channel.py	(revision 16146)
++++ paramiko/channel.py	(working copy)
+@@ -90,6 +90,7 @@
+         self.logger = util.get_logger('paramiko.transport')
+         self._pipe = None
+         self.event = threading.Event()
++        self.event_ready = False
+         self.combine_stderr = False
+         self.exit_status = -1
+         self.origin_addr = None
+@@ -152,7 +153,7 @@
+         # pixel height, width (usually useless)
+         m.add_int(0).add_int(0)
+         m.add_string('')
+-        self.event.clear()
++        self._event_pending()
+         self.transport._send_user_message(m)
+         self._wait_for_event()
+ 
+@@ -179,7 +180,7 @@
+         m.add_int(self.remote_chanid)
+         m.add_string('shell')
+         m.add_boolean(1)
+-        self.event.clear()
++        self._event_pending()
+         self.transport._send_user_message(m)
+         self._wait_for_event()
+ 
+@@ -207,7 +208,7 @@
+         m.add_string('exec')
+         m.add_boolean(True)
+         m.add_string(command)
+-        self.event.clear()
++        self._event_pending()
+         self.transport._send_user_message(m)
+         self._wait_for_event()
+ 
+@@ -234,7 +235,7 @@
+         m.add_string('subsystem')
+         m.add_boolean(True)
+         m.add_string(subsystem)
+-        self.event.clear()
++        self._event_pending()
+         self.transport._send_user_message(m)
+         self._wait_for_event()
+ 
+@@ -261,7 +262,7 @@
+         m.add_int(width)
+         m.add_int(height)
+         m.add_int(0).add_int(0)
+-        self.event.clear()
++        self._event_pending()
+         self.transport._send_user_message(m)
+         self._wait_for_event()
+ 
+@@ -374,7 +375,7 @@
+         m.add_string(auth_protocol)
+         m.add_string(auth_cookie)
+         m.add_int(screen_number)
+-        self.event.clear()
++        self._event_pending()
+         self.transport._send_user_message(m)
+         self._wait_for_event()
+         self.transport._set_x11_handler(handler)
+@@ -917,9 +918,10 @@
+         self.out_max_packet_size = max(max_packet_size, MIN_PACKET_SIZE)
+         self.active = 1
+         self._log(DEBUG, 'Max packet out: %d bytes' % max_packet_size)
+-
++        
+     def _request_success(self, m):
+         self._log(DEBUG, 'Sesch channel %d request ok' % self.chanid)
++        self.event_ready = True
+         self.event.set()
+         return
+ 
+@@ -1067,14 +1069,19 @@
+     def _log(self, level, msg, *args):
+         self.logger.log(level, "[chan " + self._name + "] " + msg, *args)
+ 
++    def _event_pending(self):
++        self.event.clear()
++        self.event_ready = False
++
+     def _wait_for_event(self):
+         self.event.wait()
+         assert self.event.isSet()
+-        if self.closed:
+-            e = self.transport.get_exception()
+-            if e is None:
+-                e = SSHException('Channel closed.')
+-            raise e
++        if self.event_ready:
++            return
++        e = self.transport.get_exception()
++        if e is None:
++            e = SSHException('Channel closed.')
++        raise e
+ 
+     def _set_closed(self):
+         # you are holding the lock.
diff --git a/python-paramiko.spec b/python-paramiko.spec
index 2f20d22..774f53e 100644
--- a/python-paramiko.spec
+++ b/python-paramiko.spec
@@ -4,7 +4,7 @@
 
 Name:           python-paramiko
 Version:        1.7.5
-Release:        1%{?dist}
+Release:        2%{?dist}
 Summary:        A SSH2 protocol library for python
 
 Group:          Development/Libraries
@@ -12,6 +12,7 @@ Group:          Development/Libraries
 License:        LGPLv2+
 URL:            http://www.lag.net/paramiko/
 Source0:        http://www.lag.net/paramiko/download/%{srcname}-%{version}.tar.gz
+Patch0: 	paramiko-channel-race.patch
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
 BuildArch:      noarch
@@ -36,6 +37,7 @@ encrypted tunnel. (This is how sftp works, for example.)
 
 %prep
 %setup -q -n %{srcname}-%{version}
+%patch0 -p0 -b .race
 %{__chmod} a-x demos/*
 %{__sed} -i -e '/^#!/,1d' demos/* paramiko/rng*
 
@@ -55,6 +57,9 @@ rm -rf $RPM_BUILD_ROOT
 %{python_sitelib}/*
 
 %changelog
+* Tue Oct 13 2009 Jeremy Katz <katzj at fedoraproject.org> - 1.7.5-2
+- Fix race condition (#526341)
+
 * Thu Jul 23 2009 Jeffrey C. Ollie <jeff at ocjtech.us> - 1.7.5-1
 - v1.7.5 (Ernest) 19jul09
 - -----------------------


More information about the scm-commits mailing list