Yet another 9p implementation in Python


Mercurial repository hosted on bitbucket:: http://bitbucket.org/f2f/py9p/


This code started its life as Tim Newsham's py9p implementation, which I found insufficient for our needs. There have been sweeping changes, bugfixes and hopefully improvements, but that has all resulted in a substantially different codebase, warranting a separate release. The code now mirrors much closely Russ Cox's work in lib9p (both Plan 9 and Plan9Port). This has resulted in a somewhat more bloated codebase. Unfortunately many of the original hacks that Tim had so cleverly put in the old code had to make way to more elaborate (read wordy) code. The only part that's true to the original is the Marshal code for converting 9p messages to and from the wire.

If you find the code messy and the programming bad, it's most likely my fault. I am a relative newbie to Python and besides a few lambdas sprinkled here and there I'm still treating the whole thing like C.

Below is a short list of changes:


Examples:

Here's a sample session without authentication:

 cl.py -n andrey@localhost:10001
 9p> ls
 sample1 sample2
 9p> ls -l
 -rw-r--r-- uid gid 1024                 sample1
 -rw-r--r-- uid gid 1024                 sample2
 9p> cat sample2
 The time is now Mon Feb 23 18:10:58 2009. thank you for asking.
 9p>

 The localsrv.py code is not very well tested. I'm using my servers at
 all times, but here's an example:

 server:
 $ ./localsrv.py -n -p 9999

 client side (debugging on):
 $ cl.py -d -n andrey@localhost:9999
 connecting as andrey to localhost, port 9999
 -3-> Tversion 65535 (16384, '9P2000')
 <-3- Rversion 65535 [8320L, '9P2000']
 -3-> Tauth 1 (10, 'andrey', '')
 <-3- Rerror 1 "no auth info: access allowed to user 'none' only"
 -3-> Tattach 1 (11, 4294967295L, 'andrey', '')
 <-3- Rattach 1 (230L, 0L, 6016018094L)
 -3-> Twalk 1 ((11, 12, []),)
 <-3- Rwalk 1 []
 9p>

 server side with authentication provided by Ron's 9grid.net server:

 $ examples/localsrv.py -p 9999 andrey 9grid.net
 Password:
 ...

 client side with auth:
 $ cl.py -n andrey@localhost:9999
 Password required
 $ cl.py -a 9grid.net andrey@localhost:9999
 Password:
 9p> ls
 fileZPdTQh fileVeOBNd 499318989b021 ....
 

This code is still in beta. I'd say it works as well as the original but has more features. I have it deployed on our data centre and am seeing a bug every week. Documentation is lacking, I apologize. A lot of the code is perhaps not very well cleaned up: I'm working on it. Hope you find it useful!

The distribution includes:


mirtchovski at gmail