From 9dbb24236f4c1b1038e2e0a4a0e49a26679e089f Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 15 Jul 2015 14:18:09 -0400 Subject: [PATCH] Support 20 byte passwords The IPMI 2.0 spec allows 20 byte passwords. If a password is less than 16 bytes, then use the 1.5 scheme as before. If between 16 and 21, then attempt IPMI 2.0 scheme. Raise when over 20. Change-Id: I25016b8608d9dbf5d436afd75bd07f0d4eed6d81 --- pyghmi/ipmi/command.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pyghmi/ipmi/command.py b/pyghmi/ipmi/command.py index 93a6cd7a..6cbe4052 100644 --- a/pyghmi/ipmi/command.py +++ b/pyghmi/ipmi/command.py @@ -1211,9 +1211,13 @@ class Command(object): data = [uid, mode_mask[mode]] if password: password = str(password) - if len(password) > 16: - raise Exception('password has limit of 16 chars') - password = password.ljust(16, "\x00") + if 21 > len(password) > 16: + password = password.ljust(20, '\x00') + data[0] |= 0b10000000 + elif len(password) > 20: + raise Exception('password has limit of 20 chars') + else: + password = password.ljust(16, "\x00") data.extend([ord(x) for x in password]) response = self.raw_command(netfn=0x06, command=0x47, data=data) if 'error' in response: