Update of /cvsroot/tmda/tmda/bin
In directory sc8-pr-cvs1:/tmp/cvs-serv21414/bin

Modified Files:
        tmda-gui tmda-manager 
Log Message:
Since ssl support is not available on server side, let's drop it from
the manager and wrap the latter with stunnel.

tmda-gui now is able to talk ssli when -s option is used.


Index: tmda-gui
===================================================================
RCS file: /cvsroot/tmda/tmda/bin/tmda-gui,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- tmda-gui    14 Dec 2002 02:09:02 -0000      1.14
+++ tmda-gui    14 Dec 2002 11:01:13 -0000      1.15
@@ -54,6 +54,10 @@
       See the NOTE below for security advisory.
       This is mandatory if you don't have a local installation of TMDA.
 
+   -s
+   --ssl
+      Connect to the server with SSL.
+
 NOTE: This is early alpha software, so please try it, and send your
 comments to the [EMAIL PROTECTED] mailing list.
 
@@ -141,6 +145,24 @@
 ProtoError = "Protocole Error"
 AuthError = "Authentication Error"
 
+class SSL_socket:
+    """Wrapper class to socket.ssl to add readline method."""
+    def __init__(self, sock):
+        self._sock = socket.ssl(sock)
+
+    def __getattr__(self, attr):
+        return getattr(self._sock, attr)
+
+    def readline(self):
+        line = []
+        c = self._sock.read(1)
+        while c:
+            line.append(c)
+            if c == '\n':
+                return ''.join(line)
+            c = self._sock.read(1)
+        raise IOError, "Broken pipe"
+
 def connectToServer(host, auth):
     global sock, sin, sout
     if sock:
@@ -148,8 +170,11 @@
         return 0
     sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     sock.connect(host)
-    sin = sock.makefile('r', 0)
-    sout = sock.makefile('w', 0)
+    if use_ssl:
+        sin = sout = SSL_socket(sock)
+    else:
+        sin = sock.makefile('r', 0)
+        sout = sock.makefile('w', 0)
     # eat up greetings from manager
     ## FIXME: maybe check the protocol version ?
     cc = sin.read(1)
@@ -293,9 +318,10 @@
 
 try:
     opts, args = getopt.getopt(sys.argv[1:],
-                               'H:U:pVh',
+                               'H:U:spVh',
                                         ['host=',
                                          'user=',
+                                         'ssl',
                                          'pending',
                                          'version',
                                          'help'])
@@ -305,6 +331,7 @@
 pending_first = 0
 host = None
 port = 8765
+use_ssl = None
 for opt, arg in opts:
     if opt in ('-h', '--help'):
         usage(0)
@@ -316,6 +343,8 @@
         sys.exit()
     if opt in ('-p', '--pending'):
         pending_first = 1
+    if opt in ('-s', '--ssl'):
+        use_ssl = 1
     elif opt in ('-H', '--host'):
         using_network=1
         try:

Index: tmda-manager
===================================================================
RCS file: /cvsroot/tmda/tmda/bin/tmda-manager,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- tmda-manager        14 Dec 2002 02:07:37 -0000      1.1
+++ tmda-manager        14 Dec 2002 11:01:15 -0000      1.2
@@ -382,7 +382,7 @@
         print 'exit'
         return self.do_exit(args)
 
-def connection(hostport, ssl=0):
+def connection(hostport):
     stdin = sys.stdin
     stdout = sys.stdout
     import socket
@@ -406,12 +406,8 @@
             conn, addr = sock.accept()
             pid = os.fork()
             if not pid:
-                if ssl:
-                    ## FIXME: ssl support doesn't work
-                    sin = sout = socket.ssl(conn)
-                else:
-                    sin = conn.makefile('r', 0)
-                    sout = conn.makefile('w', 0)
+                sin = conn.makefile('r', 0)
+                sout = conn.makefile('w', 0)
                 print 'accepted connection from %s:%s' % addr
                 try:
                     TMDAShell('+', sin, sout, stdout).mainLoop()
@@ -420,7 +416,7 @@
                     sys.stdout = stdout
                     print msg
                 sys.stdin = stdin
-                print 'closing connection to ' + repr(addr)
+                print 'closing connection from %s:%s' % addr
                 sin.close()
                 sout.close()
                 break
@@ -432,7 +428,7 @@
 
 def main():
     if daemon_mode:
-        connection(hostport, 0)
+        connection(hostport)
     else:
         TMDAShell().mainLoop()
 

_______________________________________
tmda-cvs mailing list
http://tmda.net/lists/listinfo/tmda-cvs

Reply via email to