Пример #1
0
 def pack_Memo(self, data):
     if hasattr(self, 'filter_Memo'):
         data = getattr(self, 'filter_Memo')(data)
     if data.type is None:
         raise TypeError('data.type == None')
     self.pack_MemoType(data.type)
     if data.type == const.MEMO_NONE:
         pass
     elif data.type == const.MEMO_TEXT:
         if data.text is None:
             raise TypeError('data.text == None')
         if len(data.text) > 28 and self.check_array:
             raise XDRError('array length too long for data.text')
         self.pack_string(data.text)
     elif data.type == const.MEMO_ID:
         if data.id is None:
             raise TypeError('data.id == None')
         self.pack_uint64(data.id)
     elif data.type == const.MEMO_HASH:
         if data.hash is None:
             raise TypeError('data.hash == None')
         self.pack_Hash(data.hash)
     elif data.type == const.MEMO_RETURN:
         if data.retHash is None:
             raise TypeError('data.retHash == None')
         self.pack_Hash(data.retHash)
     else:
         raise XDRError('bad switch=%s' % data.type)
Пример #2
0
 def unpack_authsys_parms(self) -> types.authsys_parms:
     data = types.authsys_parms()
     data.stamp = self.unpack_uint()
     data.machinename = self.unpack_string()
     if len(data.machinename) > 255 and self.check_array:
         raise XDRError('array length too long for data.machinename')
     data.uid = self.unpack_uint()
     data.gid = self.unpack_uint()
     data.gids = self.unpack_array(self.unpack_uint)
     if len(data.gids) > 16 and self.check_array:
         raise XDRError('array length too long for data.gids')
     if hasattr(self, 'filter_authsys_parms'):
         data = getattr(self, 'filter_authsys_parms')(data)
     return data
Пример #3
0
 def unpack_opaque_auth(self):
     data = types.opaque_auth()
     data.flavor = self.unpack_auth_flavor()
     data.body = self.unpack_opaque()
     if len(data.body) > 400:
         raise XDRError('array length too long for data.body')
     return data
Пример #4
0
 def unpack_PublicKeyType(self):
     data = self.unpack_int()
     if self.check_enum and data not in [const.PUBLIC_KEY_TYPE_ED25519]:
         raise XDRError('value=%s not in enum PublicKeyType' % data)
     if hasattr(self, 'filter_PublicKeyType'):
         data = getattr(self, 'filter_PublicKeyType')(data)
     return data
Пример #5
0
 def pack_accept_stat(self, data):
     if data not in [
             const.SUCCESS, const.PROG_UNAVAIL, const.PROG_MISMATCH,
             const.PROC_UNAVAIL, const.GARBAGE_ARGS, const.SYSTEM_ERR
     ]:
         raise XDRError('value=%s not in enum accept_stat' % data)
     self.pack_int(data)
Пример #6
0
 def unpack_string64(self):
     data = self.unpack_string()
     if len(data) > 64 and self.check_array:
         raise XDRError('array length too long for data')
     if hasattr(self, 'filter_string64'):
         data = getattr(self, 'filter_string64')(data)
     return data
Пример #7
0
 def pack_auth_flavor(self, data):
     if data not in [
             const.AUTH_NONE, const.AUTH_SYS, const.AUTH_SHORT,
             const.AUTH_DH, const.RPCSEC_GSS
     ]:
         raise XDRError('value=%s not in enum auth_flavor' % data)
     self.pack_int(data)
Пример #8
0
 def unpack_msg_type(self) -> int:
     data = self.unpack_int()
     if self.check_enum and data not in [const.CALL, const.REPLY]:
         raise XDRError('value=%s not in enum msg_type' % data)
     if hasattr(self, 'filter_msg_type'):
         data = getattr(self, 'filter_msg_type')(data)
     return data
Пример #9
0
 def pack_Device_AddrFamily(self, data: int) -> None:
     if hasattr(self, 'filter_Device_AddrFamily'):
         data = getattr(self, 'filter_Device_AddrFamily')(data)
     if self.check_enum and data not in [
             const.DEVICE_TCP, const.DEVICE_UDP
     ]:
         raise XDRError('value=%s not in enum Device_AddrFamily' % data)
     self.pack_int(data)
Пример #10
0
 def unpack_accept_stat(self):
     data = self.unpack_int()
     if data not in [
             const.SUCCESS, const.PROG_UNAVAIL, const.PROG_MISMATCH,
             const.PROC_UNAVAIL, const.GARBAGE_ARGS, const.SYSTEM_ERR
     ]:
         raise XDRError('value=%s not in enum accept_stat' % data)
     return data
Пример #11
0
 def unpack_auth_flavor(self):
     data = self.unpack_int()
     if data not in [
             const.AUTH_NONE, const.AUTH_SYS, const.AUTH_SHORT,
             const.AUTH_DH, const.RPCSEC_GSS
     ]:
         raise XDRError('value=%s not in enum auth_flavor' % data)
     return data
Пример #12
0
 def pack_reply_stat(self, data: int) -> None:
     if hasattr(self, 'filter_reply_stat'):
         data = getattr(self, 'filter_reply_stat')(data)
     if self.check_enum and data not in [
             const.MSG_ACCEPTED, const.MSG_DENIED
     ]:
         raise XDRError('value=%s not in enum reply_stat' % data)
     self.pack_int(data)
Пример #13
0
 def pack_reject_stat(self, data: int) -> None:
     if hasattr(self, 'filter_reject_stat'):
         data = getattr(self, 'filter_reject_stat')(data)
     if self.check_enum and data not in [
             const.RPC_MISMATCH, const.AUTH_ERROR
     ]:
         raise XDRError('value=%s not in enum reject_stat' % data)
     self.pack_int(data)
Пример #14
0
 def unpack_reject_stat(self) -> int:
     data = self.unpack_int()
     if self.check_enum and data not in [
             const.RPC_MISMATCH, const.AUTH_ERROR
     ]:
         raise XDRError('value=%s not in enum reject_stat' % data)
     if hasattr(self, 'filter_reject_stat'):
         data = getattr(self, 'filter_reject_stat')(data)
     return data
Пример #15
0
 def unpack_reply_stat(self) -> int:
     data = self.unpack_int()
     if self.check_enum and data not in [
             const.MSG_ACCEPTED, const.MSG_DENIED
     ]:
         raise XDRError('value=%s not in enum reply_stat' % data)
     if hasattr(self, 'filter_reply_stat'):
         data = getattr(self, 'filter_reply_stat')(data)
     return data
Пример #16
0
 def unpack_Device_AddrFamily(self) -> int:
     data = self.unpack_int()
     if self.check_enum and data not in [
             const.DEVICE_TCP, const.DEVICE_UDP
     ]:
         raise XDRError('value=%s not in enum Device_AddrFamily' % data)
     if hasattr(self, 'filter_Device_AddrFamily'):
         data = getattr(self, 'filter_Device_AddrFamily')(data)
     return data
Пример #17
0
 def pack_auth_flavor(self, data: int) -> None:
     if hasattr(self, 'filter_auth_flavor'):
         data = getattr(self, 'filter_auth_flavor')(data)
     if self.check_enum and data not in [
             const.AUTH_NONE, const.AUTH_SYS, const.AUTH_SHORT,
             const.AUTH_DH, const.RPCSEC_GSS
     ]:
         raise XDRError('value=%s not in enum auth_flavor' % data)
     self.pack_int(data)
Пример #18
0
 def pack_MemoType(self, data):
     if hasattr(self, 'filter_MemoType'):
         data = getattr(self, 'filter_MemoType')(data)
     if self.check_enum and data not in [
             const.MEMO_NONE, const.MEMO_TEXT, const.MEMO_ID,
             const.MEMO_HASH, const.MEMO_RETURN
     ]:
         raise XDRError('value=%s not in enum MemoType' % data)
     self.pack_int(data)
Пример #19
0
 def unpack_opaque_auth(self) -> types.opaque_auth:
     data = types.opaque_auth()
     data.flavor = self.unpack_auth_flavor()
     data.body = self.unpack_opaque()
     if len(data.body) > 400 and self.check_array:
         raise XDRError('array length too long for data.body')
     if hasattr(self, 'filter_opaque_auth'):
         data = getattr(self, 'filter_opaque_auth')(data)
     return data
Пример #20
0
 def pack_CryptoKeyType(self, data):
     if hasattr(self, 'filter_CryptoKeyType'):
         data = getattr(self, 'filter_CryptoKeyType')(data)
     if self.check_enum and data not in [
             const.KEY_TYPE_ED25519, const.KEY_TYPE_HASH_TX,
             const.KEY_TYPE_HASH_X
     ]:
         raise XDRError('value=%s not in enum CryptoKeyType' % data)
     self.pack_int(data)
Пример #21
0
 def pack_opaque_auth(self, data):
     if data.flavor is None:
         raise TypeError('data.flavor == None')
     self.pack_auth_flavor(data.flavor)
     if data.body is None:
         raise TypeError('data.body == None')
     if len(data.body) > 400:
         raise XDRError('array length too long for data.body')
     self.pack_opaque(data.body.encode('latin1'))
Пример #22
0
 def pack_accept_stat(self, data: int) -> None:
     if hasattr(self, 'filter_accept_stat'):
         data = getattr(self, 'filter_accept_stat')(data)
     if self.check_enum and data not in [
             const.SUCCESS, const.PROG_UNAVAIL, const.PROG_MISMATCH,
             const.PROC_UNAVAIL, const.GARBAGE_ARGS, const.SYSTEM_ERR
     ]:
         raise XDRError('value=%s not in enum accept_stat' % data)
     self.pack_int(data)
Пример #23
0
 def unpack_PublicKey(self):
     data = types.PublicKey()
     data.type = self.unpack_PublicKeyType()
     if data.type == const.PUBLIC_KEY_TYPE_ED25519:
         data.ed25519 = self.unpack_uint256()
     else:
         raise XDRError('bad switch=%s' % data.type)
     if hasattr(self, 'filter_PublicKey'):
         data = getattr(self, 'filter_PublicKey')(data)
     return data
Пример #24
0
 def unpack_auth_flavor(self) -> int:
     data = self.unpack_int()
     if self.check_enum and data not in [
             const.AUTH_NONE, const.AUTH_SYS, const.AUTH_SHORT,
             const.AUTH_DH, const.RPCSEC_GSS
     ]:
         raise XDRError('value=%s not in enum auth_flavor' % data)
     if hasattr(self, 'filter_auth_flavor'):
         data = getattr(self, 'filter_auth_flavor')(data)
     return data
Пример #25
0
 def unpack_Device_EnableSrqParms(self) -> types.Device_EnableSrqParms:
     data = types.Device_EnableSrqParms()
     data.lid = self.unpack_Device_Link()
     data.enable = self.unpack_bool()
     data.handle = self.unpack_opaque()
     if len(data.handle) > 40 and self.check_array:
         raise XDRError('array length too long for data.handle')
     if hasattr(self, 'filter_Device_EnableSrqParms'):
         data = getattr(self, 'filter_Device_EnableSrqParms')(data)
     return data
Пример #26
0
 def unpack_Memo(self):
     data = types.Memo()
     data.type = self.unpack_MemoType()
     if data.type == const.MEMO_NONE:
         pass
     elif data.type == const.MEMO_TEXT:
         data.text = self.unpack_string()
         if len(data.text) > 28 and self.check_array:
             raise XDRError('array length too long for data.text')
     elif data.type == const.MEMO_ID:
         data.id = self.unpack_uint64()
     elif data.type == const.MEMO_HASH:
         data.hash = self.unpack_Hash()
     elif data.type == const.MEMO_RETURN:
         data.retHash = self.unpack_Hash()
     else:
         raise XDRError('bad switch=%s' % data.type)
     if hasattr(self, 'filter_Memo'):
         data = getattr(self, 'filter_Memo')(data)
     return data
Пример #27
0
 def pack_auth_stat(self, data):
     if data not in [
             const.AUTH_OK, const.AUTH_BADCRED, const.AUTH_REJECTEDCRED,
             const.AUTH_BADVERF, const.AUTH_REJECTEDVERF,
             const.AUTH_TOOWEAK, const.AUTH_INVALIDRESP, const.AUTH_FAILED,
             const.AUTH_KERB_GENERIC, const.AUTH_TIMEEXPIRE,
             const.AUTH_TKT_FILE, const.AUTH_DECODE, const.AUTH_NET_ADDR,
             const.RPCSEC_GSS_CREDPROBLEM, const.RPCSEC_GSS_CTXPROBLEM
     ]:
         raise XDRError('value=%s not in enum auth_stat' % data)
     self.pack_int(data)
Пример #28
0
 def pack_opaque_auth(self, data: types.opaque_auth) -> None:
     if hasattr(self, 'filter_opaque_auth'):
         data = getattr(self, 'filter_opaque_auth')(data)
     if data.flavor is None:
         raise TypeError('data.flavor == None')
     self.pack_auth_flavor(data.flavor)
     if data.body is None:
         raise TypeError('data.body == None')
     if len(data.body) > 400 and self.check_array:
         raise XDRError('array length too long for data.body')
     self.pack_opaque(data.body)
Пример #29
0
 def pack_PublicKey(self, data):
     if hasattr(self, 'filter_PublicKey'):
         data = getattr(self, 'filter_PublicKey')(data)
     if data.type is None:
         raise TypeError('data.type == None')
     self.pack_PublicKeyType(data.type)
     if data.type == const.PUBLIC_KEY_TYPE_ED25519:
         if data.ed25519 is None:
             raise TypeError('data.ed25519 == None')
         self.pack_uint256(data.ed25519)
     else:
         raise XDRError('bad switch=%s' % data.type)
Пример #30
0
 def null(self):
     """Make NULL procedure call"""
     res = self.call(NFSPROC4_NULL, '')
     self.nfs4unpacker.reset(res)
     if not getattr(self.opts, "paddednull", False):
         # Disallows extra bytes at end of nulls
         try:
             self.nfs4unpacker.done()
         except XDRError:
             raise XDRError("Unexpected bytes in NULL response:\n%s\n"
                            "\nConsider using --paddednull option" %
                            repr(self.nfs4unpacker.get_buffer()))