mirror of
https://opendev.org/x/pyghmi
synced 2025-08-27 21:40:36 +00:00
Fix BMC compatibility with Python 2.6
BMC would try to push a bytearray at unpack. In python 2.6, this does not work. Explicitly denote changing to bytes to be compatible with python 2.6 Change-Id: I1c919a0050cae9f90c50d89abb6a77774db81381
This commit is contained in:
@@ -114,7 +114,7 @@ class ServerSession(ipmisession.Session):
|
||||
if self.kg is None:
|
||||
self.kg = self.kuid
|
||||
authcode = hmac.new(
|
||||
self.kuid, hmacdata, hashlib.sha1).digest()
|
||||
self.kuid, bytes(hmacdata), hashlib.sha1).digest()
|
||||
# regretably, ipmi mandates the server send out an hmac first
|
||||
# akin to a leak of /etc/shadow, not too worrisome if the secret
|
||||
# is complex, but terrible for most likely passwords selected by
|
||||
@@ -135,7 +135,7 @@ class ServerSession(ipmisession.Session):
|
||||
# even if rakp2 was good
|
||||
RmRc = self.Rm + self.Rc
|
||||
self.sik = hmac.new(self.kg,
|
||||
RmRc +
|
||||
bytes(RmRc) +
|
||||
struct.pack("2B", self.rolem,
|
||||
len(self.username)) +
|
||||
self.username, hashlib.sha1).digest()
|
||||
@@ -147,7 +147,8 @@ class ServerSession(ipmisession.Session):
|
||||
struct.pack("2B", self.rolem,
|
||||
len(self.username)) +\
|
||||
self.username
|
||||
expectedauthcode = hmac.new(self.kuid, hmacdata, hashlib.sha1).digest()
|
||||
expectedauthcode = hmac.new(self.kuid, bytes(hmacdata), hashlib.sha1
|
||||
).digest()
|
||||
authcode = struct.pack("%dB" % len(data[8:]), *data[8:])
|
||||
if expectedauthcode != authcode:
|
||||
#TODO(jjohnson2): RMCP error back at invalid rakp3
|
||||
@@ -274,7 +275,7 @@ class IpmiServer(object):
|
||||
headersum = ipmisession._checksum(*headerdata)
|
||||
header += bytearray(headerdata + [headersum, myaddr, mylun, 0x38])
|
||||
header += self.authcap
|
||||
bodydata = struct.unpack('B' * len(header[17:]), header[17:])
|
||||
bodydata = struct.unpack('B' * len(header[17:]), bytes(header[17:]))
|
||||
header.append(ipmisession._checksum(*bodydata))
|
||||
ipmisession._io_sendto(self.serversocket, header, sockaddr)
|
||||
|
||||
@@ -307,19 +308,20 @@ class IpmiServer(object):
|
||||
bmc=self)
|
||||
return
|
||||
data = data[13:] # ditch 13 bytes so the payload works out
|
||||
myaddr, netfnlun = struct.unpack('2B', data[14:16])
|
||||
myaddr, netfnlun = struct.unpack('2B', bytes(data[14:16]))
|
||||
netfn = (netfnlun & 0b11111100) >> 2
|
||||
mylun = netfnlun & 0b11
|
||||
if netfn == 6: # application request
|
||||
if data[19] == 0x38: # cmd = get channel auth capabilities
|
||||
verchannel, level = struct.unpack('2B', data[20:22])
|
||||
verchannel, level = struct.unpack('2B', bytes(data[20:22]))
|
||||
version = verchannel & 0b10000000
|
||||
if version != 0b10000000:
|
||||
return
|
||||
channel = verchannel & 0b1111
|
||||
if channel != 0xe:
|
||||
return
|
||||
(clientaddr, clientlun) = struct.unpack('BB', data[17:19])
|
||||
(clientaddr, clientlun) = struct.unpack(
|
||||
'BB', bytes(data[17:19]))
|
||||
level &= 0b1111
|
||||
self.send_auth_cap(myaddr, mylun, clientaddr, clientlun,
|
||||
sockaddr)
|
||||
|
Reference in New Issue
Block a user