From 147381a7e37c5f389713680f3657065cf1fd2d22 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 25 Jun 2013 13:11:14 -0400 Subject: [PATCH] More cleanup, correct some syntax errors encountered trying to meet line length --- ipmi_session.py | 54 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/ipmi_session.py b/ipmi_session.py index 2d6dcffb..83d32563 100644 --- a/ipmi_session.py +++ b/ipmi_session.py @@ -210,8 +210,8 @@ class ipmi_session: #we are always the requestor for now seqincrement=7 #IPMI spec forbids gaps bigger then 7 in seq number. #Risk the taboo rather than violate the rules - while (netfn,command,self.seqlun) in self.tabooseq and - self.tabooseq[(netfn,command,self.seqlun)] and seqincrement: + while ((netfn,command,self.seqlun) in self.tabooseq and + self.tabooseq[(netfn,command,self.seqlun)] and seqincrement): self.tabooseq[(self.expectednetfn,command,self.seqlun)]-=1 #Allow taboo to eventually expire after a few rounds self.seqlun += 4 #the last two bits are lun, so add 4 to add 1 @@ -359,7 +359,7 @@ class ipmi_session: #thought 'reserved' meant 'must be zero' self.ipmi15only=1 return self._get_channel_auth_cap() - mysuffix=" while trying to get channel authentication capabalities") + mysuffix=" while trying to get channel authentication capabalities" errstr = get_ipmi_error(response,suffix=mysuffix) if errstr: call_with_optional_args(self.onlogon, @@ -541,9 +541,10 @@ class ipmi_session: def _handle_ipmi2_packet(self,rawdata): - data = list(unpack("%dB"%len(rawdata),rawdata)) #we need mutable array of bytes + data = list(unpack("%dB"%len(rawdata),rawdata)) #now need mutable array ptype = data[5]&0b00111111 - #the first 16 bytes are header information as can be seen in 13-8 that we will toss out + #the first 16 bytes are header information as can be seen in 13-8 that + #we will toss out if ptype == 0x11: #rmcp+ response return self._got_rmcp_response(data[16:]) elif ptype == 0x13: @@ -551,8 +552,11 @@ class ipmi_session: elif ptype == 0x15: return self._got_rakp4(data[16:]) elif ptype == 0: #good old ipmi payload - #If I'm endorsing a shared secret scheme, then at the very least it needs to do mutual assurance - if not (data[5]&0b01000000): #This would be the line that might trip up some crappy, insecure BMC implementation + #If I'm endorsing a shared secret scheme, then at the very least it + #needs to do mutual assurance + if not (data[5]&0b01000000): #This would be the line that might + #trip up some insecure BMC + #implementation return encrypted=0 if data[5]&0b10000000: @@ -581,9 +585,9 @@ class ipmi_session: def _got_rmcp_response(self,data): #see RMCP+ open session response table if not (self.sessioncontext and self.sessioncontext != "Established"): - return -9; #ignore payload as we are not in a state for the response to make sense + return -9; #ignore payload as we are not in a state valid it if data[0] != self.rmcptag: - return -9 #use rmcp tag to track and reject stale responses so that the state doesn't go odd + return -9 #use rmcp tag to track and reject stale responses if data[1] !=0: #response code... if data[1] in rmcp_codes: errstr=rmcp_codes[data[1]] @@ -592,12 +596,13 @@ class ipmi_session: call_with_optional_args(self.onlogon,{'error': errstr},self.onlogonargs) return -9 self.allowedpriv=data[2] - #TODO(jbjohnso): check privelege level allowed? admin was xCAT requirement, but + #TODO(jbjohnso): enable lower priv access (e.g. operator/user) localsid=unpack("