Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 20f9960

Browse files
committed
Add explicit auth call
1 parent 749d0bb commit 20f9960

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

Demo/rpc/mountclient.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# version of a protocol, use multiple inheritance as shown below.
99

1010

11+
import rpc
1112
from rpc import Packer, Unpacker, TCPClient, UDPClient
1213

1314
MOUNTPROG = 100005
@@ -76,6 +77,18 @@ def addpackers(self):
7677
self.packer = MountPacker().init()
7778
self.unpacker = MountUnpacker().init('')
7879

80+
# This function is called to gobble up a suitable
81+
# authentication object for a call to procedure 'proc'.
82+
# (Experiments suggest that for Mnt/Unmnt, Unix authentication
83+
# is necessary, while the other calls require no
84+
# authentication.)
85+
def mkcred(self, proc):
86+
if proc not in (1, 3, 4): # not Mnt/Unmnt/Unmntall
87+
return rpc.AUTH_NULL, ''
88+
if self.cred == None:
89+
self.cred = rpc.AUTH_UNIX, rpc.make_auth_unix_default()
90+
return self.cred
91+
7992
# The methods Mnt, Dump etc. each implement one Remote
8093
# Procedure Call. Their general structure is
8194
# self.start_call(<procedure-number>)

0 commit comments

Comments
 (0)