Guido van Rossum | 6c15046 | 1995-04-28 22:28:39 +0000 | [diff] [blame] | 1 | Filesystem, RCS and CVS client and server classes |
| 2 | ================================================= |
| 3 | |
Guido van Rossum | 6ea3f92 | 1995-06-21 02:19:55 +0000 | [diff] [blame] | 4 | *** See the security warning at the end of this file! *** |
| 5 | |
Guido van Rossum | 5f07b84 | 1995-04-26 22:57:11 +0000 | [diff] [blame] | 6 | This directory contains various modules and classes that support |
Guido van Rossum | 6c15046 | 1995-04-28 22:28:39 +0000 | [diff] [blame] | 7 | remote file system operations. |
| 8 | |
| 9 | rrcs.py Remote RCS client command line interface |
| 10 | rrcs Script to put in your bin directory |
| 11 | |
| 12 | rcvs.py Remote CVS client command line interface |
| 13 | rcvs Script to put in your bin directory |
| 14 | |
| 15 | sumtree.py Old demo for FSProxy |
| 16 | cmptree.py First FSProxy client (used to sync from the Mac) |
| 17 | |
| 18 | cvslib.py CVS admin files classes (used by rrcs) |
| 19 | rcsclient.py Return an RCSProxyClient instance |
| 20 | (has reasonable default server/port/directory) |
| 21 | |
| 22 | FSProxy.py Filesystem interface classes |
| 23 | RCSProxy.py RCS interface classes |
| 24 | |
| 25 | client.py Client class |
| 26 | server.py Server class |
| 27 | |
Guido van Rossum | 6ea3f92 | 1995-06-21 02:19:55 +0000 | [diff] [blame] | 28 | security.py Security mix-in class (not very secure I think) |
| 29 | |
Guido van Rossum | 6c15046 | 1995-04-28 22:28:39 +0000 | [diff] [blame] | 30 | cmdfw.py CommandFrameWork class |
| 31 | (used by rcvs, should be used by rrcs as well) |
| 32 | |
| 33 | |
| 34 | Client/Server operation |
| 35 | ----------------------- |
| 36 | |
| 37 | The Client and Server classes implement a simple-minded RPC protocol, |
| 38 | using Python's pickle module to transfer arguments, return values and |
| 39 | exceptions with the most generality. The Server class is instantiated |
| 40 | with a port number on which it should listen for requests; the Client |
| 41 | class is instantiated with a host name and a port number where it |
| 42 | should connect to. Once a client is connected, a TCP connection is |
| 43 | maintained between client and server. |
| 44 | |
| 45 | The Server class currently handles only one connection at a time; |
| 46 | however it could be rewritten to allow various modes of operations, |
| 47 | using multiple threads or processes or the select() system call as |
| 48 | desired to serve multiple clients simultaneously (when using select(), |
| 49 | still handling one request at a time). This would not require |
| 50 | rewriting of the Client class. It may also be possible to adapt the |
| 51 | code to use UDP instead of TCP, but then both classes will have to be |
| 52 | rewritten (and unless extensive acknowlegements and request serial |
| 53 | numbers are used, the server should handle duplicate requests, so its |
| 54 | semantics should be idempotent -- shrudder). |
| 55 | |
| 56 | Even though the FSProxy and RCSProxy modules define client classes, |
| 57 | the client class is fully generic -- what methods it supports is |
| 58 | determined entirely by the server. The server class, however, must be |
| 59 | derived from. This is generally done as follows: |
| 60 | |
| 61 | from server import Server |
| 62 | from client import Client |
| 63 | |
| 64 | # Define a class that performs the operations locally |
| 65 | class MyClassLocal: |
| 66 | def __init__(self): ... |
| 67 | def _close(self): ... |
| 68 | |
| 69 | # Derive a server class using multiple inheritance |
| 70 | class MyClassServer(MyClassLocal, Server): |
| 71 | def __init__(self, address): |
| 72 | # Must initialize MyClassLocal as well as Server |
| 73 | MyClassLocal.__init__(self) |
| 74 | Server.__init__(self, address) |
| 75 | def _close(self): |
| 76 | Server._close() |
| 77 | MyClassLocal._close() |
| 78 | |
| 79 | # A dummy client class |
| 80 | class MyClassClient(Client): pass |
| 81 | |
| 82 | Note that because MyClassLocal isn't used in the definition of |
| 83 | MyClassClient, it would actually be better to place it in a separate |
| 84 | module so the definition of MyClassLocal isn't executed when we only |
| 85 | instantiate a client. |
| 86 | |
| 87 | The modules client and server should probably be renamed to Client and |
| 88 | Server in order to match the class names. |
Guido van Rossum | 6ea3f92 | 1995-06-21 02:19:55 +0000 | [diff] [blame] | 89 | |
| 90 | |
| 91 | *** Security warning: this version requires that you have a file |
| 92 | $HOME/.python_keyfile at the server and client side containing two comma- |
| 93 | separated numbers. The security system at the moment makes no guarantees |
| 94 | of actuallng being secure -- however it requires that the key file |
| 95 | exists and contains the same numbers at both ends for this to work. |
| 96 | (You can specify an alternative keyfile in $PYTHON_KEYFILE). |
| 97 | Have a look at the Security class in security.py for details; |
| 98 | basically, if the key file contains (x, y), then the security server |
| 99 | class chooses a random number z (the challenge) in the range 10..100000 |
| 100 | and the client must be able to produce pow(z, x, y) (i.e. z**x mod y). |