Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop string decode errors on encrypted values by treating them as bytestrings #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jeamland
Copy link

No description provided.

@wichert
Copy link
Collaborator

wichert commented Apr 16, 2012

I'm not sure what the problem is that you are trying to fix; I have not seen any decode errors so far.

In order for me to understand the problem you are running into and to prove that this change fixes that please add one or more tests that demonstrate the bug and the fix.

@jeamland
Copy link
Author

So when running the example/server.py script (which required my commenting out the include directives since the files referenced weren't around), I then ran radtest from the freeradius package like so:

> radtest username password 127.0.0.1 0 Kah3choteereethiejeimaeziecumi

This results in the following:

Received an authentication request
Attributes: 
Message-Authenticator: ['.!5\x8fyd\xa9\xddNga\xb5\xdb\xfb\xff\xc7']
User-Name: [u'username']
Traceback (most recent call last):
  File "server.py", line 73, in <module>
    srv.Run()
  File "server.py", line 27, in Run
    self._ProcessInput(fdo)
  File "/private/tmp/pyrad/pyrad/server.py", line 221, in _ProcessInput
    self._HandleAuthPacket(pkt)
  File "server.py", line 48, in _HandleAuthPacket
    print "%s: %s" % (attr, pkt[attr])
  File "/private/tmp/pyrad/pyrad/packet.py", line 173, in __getitem__
    res.append(self._DecodeValue(attr, v))
  File "/private/tmp/pyrad/pyrad/packet.py", line 114, in _DecodeValue
    return tools.DecodeAttr(attr.type, value)
  File "/private/tmp/pyrad/pyrad/tools.py", line 79, in DecodeAttr
    return DecodeString(value)
  File "/private/tmp/pyrad/pyrad/tools.py", line 43, in DecodeString
    return str.decode('utf-8')
  File "/Users/benno/.virtualenvs/rad/lib/python2.7/encodings/utf_8.py", line 16, in decode
    return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xb4 in position 0: invalid start byte

When looking at the dictionaries used by freeradius (dictionary.rfc2865), I found that the User-Password attribute had an encrypt=1 setting, so I made the assumption that this should be treated as bytes rather than a unicode string.

@jamiesun
Copy link
Contributor

jamiesun commented Sep 5, 2012

ATTRIBUTE User-Password 2 string encrypt=1

I have get this problem,Can I delete “ encrypt=1”?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants