Пример #1
0
 def initialize(self, client): # Note this is no thread safe
     """Set seq_num, init, handle, and context"""
     self.gss_seq_num = 0
     #d = gssapi.importName("nfs@%s" % client.remotehost)
     d = gssapi.importName("[email protected]")
     if d['major'] != gssapi.GSS_S_COMPLETE:
         raise SecError, "gssapi.importName returned: %s" % \
               show_major(d['major'])
     name = d['name']
     # We need to send NULLPROCs with token from initSecContext
     good_major = [gssapi.GSS_S_COMPLETE, gssapi.GSS_S_CONTINUE_NEEDED]
     self.init = 1
     reply_token = ''
     reply_major = ''
     context = buffer('')
     while True:
         #major, x, token, context, x, x, x = \
         d = gssapi.initSecContext(name, reply_token, context)
         major = d['major']
         context = d['context']
         if major not in good_major:
             raise SecError, "gssapi.initSecContext returned: %s" % \
                   show_major(major)
         if (major == gssapi.GSS_S_CONTINUE_NEEDED) and \
                (reply_major == gssapi.GSS_S_COMPLETE):
             raise SecError, "Unexpected GSS_S_COMPLETE from server"
         token = d['token']
         if reply_major != gssapi.GSS_S_COMPLETE:
             # FRED - sec 5.2.2 of RFC 2203 mentions possibility that
             # no token is returned.  But then how get handle?
             p = self.getpacker()
             p.reset()
             p.pack_opaque(token)
             data = p.get_buffer()
             reply = client.call(0, data)
             up = self.getunpacker()
             up.reset(reply)
             res = up.unpack_rpc_gss_init_res()
             up.done()
             reply_major = res.gss_major
             if reply_major not in good_major:
                 raise SecError, "Server returned: %s" % \
                       show_major(reply_major)
             self.init = 2
             reply_token = res.gss_token
         if major == gssapi.GSS_S_COMPLETE:
             if reply_major != gssapi.GSS_S_COMPLETE:
                 raise SecError, "Unexpected COMPLETE from client"
             break
     self.gss_context = context
     self.gss_handle = res.handle
     self.init = 0
Пример #2
0
 def initialize(self, client):  # Note this is no thread safe
     """Set seq_num, init, handle, and context"""
     self.gss_seq_num = 0
     #d = gssapi.importName("nfs@%s" % client.remotehost)
     d = gssapi.importName("[email protected]")
     if d['major'] != gssapi.GSS_S_COMPLETE:
         raise SecError, "gssapi.importName returned: %s" % \
               show_major(d['major'])
     name = d['name']
     # We need to send NULLPROCs with token from initSecContext
     good_major = [gssapi.GSS_S_COMPLETE, gssapi.GSS_S_CONTINUE_NEEDED]
     self.init = 1
     reply_token = ''
     reply_major = ''
     context = buffer('')
     while True:
         #major, x, token, context, x, x, x = \
         d = gssapi.initSecContext(name, reply_token, context)
         major = d['major']
         context = d['context']
         if major not in good_major:
             raise SecError, "gssapi.initSecContext returned: %s" % \
                   show_major(major)
         if (major == gssapi.GSS_S_CONTINUE_NEEDED) and \
                (reply_major == gssapi.GSS_S_COMPLETE):
             raise SecError, "Unexpected GSS_S_COMPLETE from server"
         token = d['token']
         if reply_major != gssapi.GSS_S_COMPLETE:
             # FRED - sec 5.2.2 of RFC 2203 mentions possibility that
             # no token is returned.  But then how get handle?
             p = self.getpacker()
             p.reset()
             p.pack_opaque(token)
             data = p.get_buffer()
             reply = client.call(0, data)
             up = self.getunpacker()
             up.reset(reply)
             res = up.unpack_rpc_gss_init_res()
             up.done()
             reply_major = res.gss_major
             if reply_major not in good_major:
                 raise SecError, "Server returned: %s" % \
                       show_major(reply_major)
             self.init = 2
             reply_token = res.gss_token
         if major == gssapi.GSS_S_COMPLETE:
             if reply_major != gssapi.GSS_S_COMPLETE:
                 raise SecError, "Unexpected COMPLETE from client"
             break
     self.gss_context = context
     self.gss_handle = res.handle
     self.init = 0