head 1.2; access; symbols pkgsrc-2015Q1:1.1.0.38 pkgsrc-2015Q1-base:1.1 pkgsrc-2014Q4:1.1.0.36 pkgsrc-2014Q4-base:1.1 pkgsrc-2014Q3:1.1.0.34 pkgsrc-2014Q3-base:1.1 pkgsrc-2014Q2:1.1.0.32 pkgsrc-2014Q2-base:1.1 pkgsrc-2014Q1:1.1.0.30 pkgsrc-2014Q1-base:1.1 pkgsrc-2013Q4:1.1.0.28 pkgsrc-2013Q4-base:1.1 pkgsrc-2013Q3:1.1.0.26 pkgsrc-2013Q3-base:1.1 pkgsrc-2013Q2:1.1.0.24 pkgsrc-2013Q2-base:1.1 pkgsrc-2013Q1:1.1.0.22 pkgsrc-2013Q1-base:1.1 pkgsrc-2012Q4:1.1.0.20 pkgsrc-2012Q4-base:1.1 pkgsrc-2012Q3:1.1.0.18 pkgsrc-2012Q3-base:1.1 pkgsrc-2012Q2:1.1.0.16 pkgsrc-2012Q2-base:1.1 pkgsrc-2012Q1:1.1.0.14 pkgsrc-2012Q1-base:1.1 pkgsrc-2011Q4:1.1.0.12 pkgsrc-2011Q4-base:1.1 pkgsrc-2011Q3:1.1.0.10 pkgsrc-2011Q3-base:1.1 pkgsrc-2011Q2:1.1.0.8 pkgsrc-2011Q2-base:1.1 pkgsrc-2011Q1:1.1.0.6 pkgsrc-2011Q1-base:1.1 pkgsrc-2010Q4:1.1.0.4 pkgsrc-2010Q4-base:1.1 pkgsrc-2010Q3:1.1.0.2; locks; strict; comment @# @; 1.2 date 2015.04.13.23.12.44; author rodent; state dead; branches; next 1.1; commitid NgZhNHAKgraV6uhy; 1.1 date 2010.11.23.08.24.04; author tron; state Exp; branches 1.1.2.1; next ; 1.1.2.1 date 2010.11.23.08.24.04; author spz; state dead; branches; next 1.1.2.2; 1.1.2.2 date 2010.11.23.21.50.06; author spz; state Exp; branches; next ; desc @@ 1.2 log @Removing python26. EOL'd quite some ago and discussed a couple times on tech-pkg@@ and pkgsrc-users@@. @ text @$NetBSD: patch-ba,v 1.1 2010/11/23 08:24:04 tron Exp $ Fix for CVE-2010-3492, taken from the Python SVN repository: http://svn.python.org/view?view=rev&revision=86084 --- Doc/library/asyncore.rst.orig 2010-05-19 15:14:45.000000000 +0100 +++ Doc/library/asyncore.rst 2010-11-22 18:11:58.000000000 +0000 @@@@ -211,10 +211,13 @@@@ .. method:: accept() Accept a connection. The socket must be bound to an address and listening - for connections. The return value is a pair ``(conn, address)`` where - *conn* is a *new* socket object usable to send and receive data on the - connection, and *address* is the address bound to the socket on the other - end of the connection. + for connections. The return value can be either ``None`` or a pair + ``(conn, address)`` where *conn* is a *new* socket object usable to send + and receive data on the connection, and *address* is the address bound to + the socket on the other end of the connection. + When ``None`` is returned it means the connection didn't take place, in + which case the server should just ignore this event and keep listening + for further incoming connections. .. method:: close() @@@@ -224,6 +227,12 @@@@ flushed). Sockets are automatically closed when they are garbage-collected. +.. class:: dispatcher_with_send() + + A :class:`dispatcher` subclass which adds simple buffered output capability, + useful for simple clients. For more sophisticated usage use + :class:`asynchat.async_chat`. + .. class:: file_dispatcher() A file_dispatcher takes a file descriptor or file object along with an @@@@ -240,7 +249,7 @@@@ socket for use by the :class:`file_dispatcher` class. Availability: UNIX. -.. _asyncore-example: +.. _asyncore-example-1: asyncore Example basic HTTP client ---------------------------------- @@@@ -250,7 +259,7 @@@@ import asyncore, socket - class http_client(asyncore.dispatcher): + class HTTPClient(asyncore.dispatcher): def __init__(self, host, path): asyncore.dispatcher.__init__(self) @@@@ -274,6 +283,45 @@@@ sent = self.send(self.buffer) self.buffer = self.buffer[sent:] - c = http_client('www.python.org', '/') + client = HTTPClient('www.python.org', '/') asyncore.loop() + +.. _asyncore-example-2: + +asyncore Example basic echo server +---------------------------------- + +Here is abasic echo server that uses the :class:`dispatcher` class to accept +connections and dispatches the incoming connections to a handler:: + + import asyncore + import socket + + class EchoHandler(asyncore.dispatcher_with_send): + + def handle_read(self): + data = self.recv(8192) + self.send(data) + + class EchoServer(asyncore.dispatcher): + + def __init__(self, host, port): + asyncore.dispatcher.__init__(self) + self.create_socket(socket.AF_INET, socket.SOCK_STREAM) + self.set_reuse_addr() + self.bind((host, port)) + self.listen(5) + + def handle_accept(self): + pair = self.accept() + if pair is None: + pass + else: + sock, addr = pair + print 'Incoming connection from %s' % repr(addr) + handler = EchoHandler(sock) + + server = EchoServer('localhost', 8080) + asyncore.loop() + @ 1.1 log @Add fix for CVE-2010-3492 and update the fix for CVE-2010-3493. Both fixes taken from the Python 2.7 branch in the Python SVN repository. @ text @d1 1 a1 1 $NetBSD$ @ 1.1.2.1 log @file patch-ba was added on branch pkgsrc-2010Q3 on 2010-11-23 21:50:06 +0000 @ text @d1 104 @ 1.1.2.2 log @Pullup ticket 3279 - requested by tron security fixes Revisions pulled up: - pkgsrc/lang/python26/Makefile 1.31 - pkgsrc/lang/python26/distinfo 1.29 Files added: pkgsrc/lang/python26/patches/patch-ba pkgsrc/lang/python26/patches/patch-bb pkgsrc/lang/python26/patches/patch-bc ------------------------------------------------------------------------- Module Name: pkgsrc Committed By: tez Date: Wed Nov 17 18:44:07 UTC 2010 Modified Files: pkgsrc/lang/python26: Makefile distinfo Log Message: Add fix for SA41968 (CVE-2010-3493) from the 2.7 branch repo http://svn.python.org/view/python/branches/release27-maint/Lib/smtpd.py?r1=86084&r2=82503&view=patch To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 pkgsrc/lang/python26/Makefile cvs rdiff -u -r1.27 -r1.28 pkgsrc/lang/python26/distinfo ------------------------------------------------------------------------- Module Name: pkgsrc Committed By: tron Date: Tue Nov 23 08:24:05 UTC 2010 Modified Files: pkgsrc/lang/python26: Makefile distinfo Added Files: pkgsrc/lang/python26/patches: patch-ba patch-bb patch-bc Log Message: Add fix for CVE-2010-3492 and update the fix for CVE-2010-3493. Both fixes taken from the Python 2.7 branch in the Python SVN repository. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 pkgsrc/lang/python26/Makefile cvs rdiff -u -r1.28 -r1.29 pkgsrc/lang/python26/distinfo cvs rdiff -u -r0 -r1.1 pkgsrc/lang/python26/patches/patch-ba \ pkgsrc/lang/python26/patches/patch-bb \ pkgsrc/lang/python26/patches/patch-bc @ text @a0 104 $NetBSD: patch-ba,v 1.1 2010/11/23 08:24:04 tron Exp $ Fix for CVE-2010-3492, taken from the Python SVN repository: http://svn.python.org/view?view=rev&revision=86084 --- Doc/library/asyncore.rst.orig 2010-05-19 15:14:45.000000000 +0100 +++ Doc/library/asyncore.rst 2010-11-22 18:11:58.000000000 +0000 @@@@ -211,10 +211,13 @@@@ .. method:: accept() Accept a connection. The socket must be bound to an address and listening - for connections. The return value is a pair ``(conn, address)`` where - *conn* is a *new* socket object usable to send and receive data on the - connection, and *address* is the address bound to the socket on the other - end of the connection. + for connections. The return value can be either ``None`` or a pair + ``(conn, address)`` where *conn* is a *new* socket object usable to send + and receive data on the connection, and *address* is the address bound to + the socket on the other end of the connection. + When ``None`` is returned it means the connection didn't take place, in + which case the server should just ignore this event and keep listening + for further incoming connections. .. method:: close() @@@@ -224,6 +227,12 @@@@ flushed). Sockets are automatically closed when they are garbage-collected. +.. class:: dispatcher_with_send() + + A :class:`dispatcher` subclass which adds simple buffered output capability, + useful for simple clients. For more sophisticated usage use + :class:`asynchat.async_chat`. + .. class:: file_dispatcher() A file_dispatcher takes a file descriptor or file object along with an @@@@ -240,7 +249,7 @@@@ socket for use by the :class:`file_dispatcher` class. Availability: UNIX. -.. _asyncore-example: +.. _asyncore-example-1: asyncore Example basic HTTP client ---------------------------------- @@@@ -250,7 +259,7 @@@@ import asyncore, socket - class http_client(asyncore.dispatcher): + class HTTPClient(asyncore.dispatcher): def __init__(self, host, path): asyncore.dispatcher.__init__(self) @@@@ -274,6 +283,45 @@@@ sent = self.send(self.buffer) self.buffer = self.buffer[sent:] - c = http_client('www.python.org', '/') + client = HTTPClient('www.python.org', '/') asyncore.loop() + +.. _asyncore-example-2: + +asyncore Example basic echo server +---------------------------------- + +Here is abasic echo server that uses the :class:`dispatcher` class to accept +connections and dispatches the incoming connections to a handler:: + + import asyncore + import socket + + class EchoHandler(asyncore.dispatcher_with_send): + + def handle_read(self): + data = self.recv(8192) + self.send(data) + + class EchoServer(asyncore.dispatcher): + + def __init__(self, host, port): + asyncore.dispatcher.__init__(self) + self.create_socket(socket.AF_INET, socket.SOCK_STREAM) + self.set_reuse_addr() + self.bind((host, port)) + self.listen(5) + + def handle_accept(self): + pair = self.accept() + if pair is None: + pass + else: + sock, addr = pair + print 'Incoming connection from %s' % repr(addr) + handler = EchoHandler(sock) + + server = EchoServer('localhost', 8080) + asyncore.loop() + @