-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
rlm_python3: attribute values that fail utf8 conversion will be returned as bytes, not str #5242
base: v3.2.x
Are you sure you want to change the base?
Conversation
…rn a byte string if it a string can't be interpreted as UTF8. Also improve exception handling so that no python exceptions remain after the do_python_single call. Otherwise the next request will immediately fail.
Maybe just do the conversion by default? Don't see the need for a magic knob. |
I'm fine with that. However, I added the knob because it's a potentially breaking change. Without the knob, suddenly, someone using the python3 module who is expecting every string in |
All RADIUS attributes should be UTF8, so it's unlikely they were getting binary data in string attributes anyway. |
The problematic attribute is "MS-CHAP-Error". It frequently has binary data embedded in it when an MS-CHAP error is encountered. |
https://datatracker.ietf.org/doc/html/rfc2548#section-2.1.5 says
So anything putting non-ASCII data in there is likely wrong. For FreeRADIUS, the |
I'll capture an example and post it in here; it's possible this has exposed another issue elsewhere. |
Here's the attribute:
No obvious non-ascii chars. This is formatted with the
Is there an easy way to dump the attribute in hex with just the |
@aren The key is:
The first So the
My take is to skip the flag, and automatically convert the attribute to bytes if it isn't UTF-8. The issue is that while the RFCs say things like Since the previous behavior was to fail conversion, I think it's safe to just convert the bad data to bytes. The only issue is that when it's converted back from Python to |
so that no python exceptions remain after the do_python_single call. Otherwise the next request will immediately fail. Patch from #5242, but separated out to keep commit history a little clearer.
Hi, I have something similar in the logs. Sometimes, I see this sometimes
I think if I understand it correctly I can't do anything about it, i.e. users need to send the password or other field in correct encoding to not have such errors in the logs. I saw this issue, and just want to confirm my understanding of it. Am I right or I am missing something? |
@vo-va If it's complaining about the |
so that no python exceptions remain after the do_python_single call. Otherwise the next request will immediately fail. Patch from #5242, but separated out to keep commit history a little clearer.
@alandekok circling back to this PR so I can get it closed out. Does another module (perl?) do this, so I can use it as an example? |
@aren You can just use the function |
… fr_pair_value_bstrncpy and/or fr_pair_value_from_str. Also silence some warnings.
@alandekok |
Why doesn't |
For example, this assignment: Should it handle this case? I can dive deeper if so. But it's a special case in |
The |
Ok great, that's what I figured. Then I think this PR does the right thing. |
Anything I can do to help get this PR over the finish line? |
which will return a byte string if it a string can't be interpreted as UTF8.
Also improve exception handling so that no python exceptions remain after the do_python_single call. Otherwise the next request will immediately fail.