from rpc import Packer, Unpacker, TCPClient, UDPClient
+# Program number and version for the mount protocol
+# Size of the 'fhandle' opaque structure
self.packer = MountPacker().init()
self.unpacker = MountUnpacker().init('')
- # This function is called to gobble up a suitable
+ # This method is called by Client.init to bind the socket
+ # to a particular network interface and port. We use the
+ # default network interface, but if we're running as root,
+ # we want to bind to a reserved port
+ port = rpc.bindresvport(self.sock, '')
+ self.sock.bind(('', 0))
+ # This function is called to cough up a suitable
# authentication object for a call to procedure 'proc'.
- # (Experiments suggest that for Mnt/Umnt, Unix authentication
- # is necessary, while the other calls require no
- def mkcred(self, proc):
- if proc not in (1, 3, 4): # not Mnt/Umnt/Umntall
- return rpc.AUTH_NULL, ''
self.cred = rpc.AUTH_UNIX, rpc.make_auth_unix_default()
# A little test program for the Mount client. This takes a host as
# command line argument (default the local machine), prints its export
-# list, and attempt to mount and unmount each exported files system.
+# list, and attempts to mount and unmount each exported files system.
+# An optional first argument of -t or -u specifies the protocol to use
+# (TCP or UDP), default is UDP.
+ if sys.argv[1:] and sys.argv == '-t':
+ elif sys.argv[1:] and sys.argv == '-u':
if sys.argv[1:]: host = sys.argv
- mcl =