-Re: Python C binding or C API has password byte mishandling bug
Henry Robinson 2012-08-23, 10:58
Hi Ben -
Possibly you're running in to https://issues.apache.org/jira/browse/ZOOKEEPER-1398, which is to do with zkpython prematurely truncating a password due to it containing a null byte. Unfortunately that's not yet resolved, but it's worth checking to see if your problem is the same.
Sent from my iPad
On Aug 23, 2012, at 1:58 AM, Ben Bangert <[EMAIL PROTECTED]> wrote:
> On Aug 22, 2012, at 4:38 PM, Ben Bangert <[EMAIL PROTECTED]> wrote:
>> I tweaked the C layer to output this after connection:
>> LOG_INFO(("Password is: %02x", zh->client_id.passwd));
>> Granted, I should probably use a better print modifier, I'm a C newb unfortunately. This is what I see in my logs during the problem:
>> ZooKeeper: INFO: check_events@1747: session establishment complete on server [127.0.0.1:20000], sessionId=0x139507b99fe00c6, negotiated timeout=10000
>> ZooKeeper: INFO: check_events@1748: Password is: 2502978
>> kazoo.testing: DEBUG: Password is:
> For a possibly more helpful message, I changed it to:
> LOG_INFO(("Password is: %#llx", zh->client_id.passwd));
> Here's a failure with that:
> ZooKeeper: INFO: check_events@1749: Password is: 0x101883698
> kazoo.testing: DEBUG: Password is: c46b53ec5b9290, length: 7
> Here we can see that the C layer got a password (not sure on C encoding if thats 16 bytes or not), and the Python one was 7 characters (prolly 6 chars, it seems to count one extra). So something is quite wrong here, and of course supplying the wrong password gets a session expired issue.
> If someone that knows C better can translate that password back to the raw bytes, perhaps it'd be a good test case somewhere to see that the bytes aren't mucked up someone on the way to Python.