-
Notifications
You must be signed in to change notification settings - Fork 3k
inet_res: Make host name lookups case-insensitive #763
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
Conversation
ca7de6b
to
0092a11
Compare
Patch has passed first testings and has been assigned to be reviewed I am a script, I am not human |
We will consider this patch for 18.1 |
Thanks! I guess this change is a bit of a PITA to review, but the issue affects e.g. server-to-server connections initiated by ejabberd, which just fail if the name capitalization in the DNS response differs from the request. It would be awesome if that could be fixed. |
Cn n f,k Loïc Hoguin -------- Original Message --------
|
Have you seen PR 821? It seems to be addressing the same problem. So far I think your solution is |
@weiss would the new version of PR 821 solve your problem? Or do you intend to change the returned domain name to always be lower case? |
I would certainly hope the tests will be happy with my solution as well :-) I'm afraid I didn't manage to run that part of the test suite (which is the reason I didn't provide tests myself). If someone else could try running those tests, that would be awesome.
No, and as I (now) mentioned in #821, I don't think I'm doing that. |
0092a11
to
7aeaa70
Compare
I had another look at my diff after @stolen mentioned performance in #821. Initially, I lower-cased all RRs twice: First (in I did this on purpose, because Therefore, I'll now force-push a version of my patch which lower-cases the RRs just once. While at it, I'll also make sure the domain name specified in the lookup is only lower-cased once. |
7aeaa70
to
c038351
Compare
I suspect that there is an irregularity in that returned aliases become lowercased (in the recursion of res_hostent_by_domain/4). You probably need to have both lowercased aliases and the original ones in the loop to create the correct(tm) hostent record at the end. I also suspect that you need to fix the hostent_by_domain/3 function too since it looks up a CNAME, gets a lowercased from the cache and the compares it agains non-lowercased [Domain | Aliases]. If I remember this right the caching used for /etc/hosts lookup retains the case from the file so when you read an entry from the cache it will return the original casing from the /etc/hosts file. I understand your code stores lowercase in the cache but you return the original casing from the query. Correct? Which is the better behaviour? |
That's true, but is there any value in having any upper-casing of the aliases retained from the original DNS response? I would've thought that's not worth any trouble, but I may well be overlooking something.
Good point, thanks! I guess not only the CNAME lookup but also the
Yes, that's right.
I guess it might sometimes be convenient for the caller to have the casing retained from the query (when matching the result against the query, for example). Of course, the caller cannot safely assume either behaviour unless it's documented, so both ways should work. In short: I don't know. |
It just feels less obtrusive, and would not be that hard to fix. It would be consistent with what would happen if you yourself looked up the CNAME, got an uppercased answer and then looked it up.
That might already be fixed since you changed do_lookup_rr/3.
Neither do I. Retaining the original case feels logical. But keeping that original response would cost time when comparing or memory when storing, and returning what the caller entered feels more functional. The in the future we should strive for making both caches behave the same... |
Patch has passed first testings and has been assigned to be reviewed I am a script, I am not human |
Okay, I'll update the patch accordingly (later today).
You're completely right, of course. |
This partly reverts commit 8152505.
c038351
to
68aac2e
Compare
I've now force-pushed an update that addresses the mentioned issues. The patch no longer lower-cases returned aliases, and the CNAME comparison within the Thanks a lot for the review. |
Patch has passed first testings and has been assigned to be reviewed I am a script, I am not human |
Don't let
inet_res:getbyname
andinet_res:gethostbyname
calls return{error, nxdomain}
if the host name capitalization in the DNS response differs from the request, like in this example:This PR partly reverts commit 8152505. Up to that commit, only the initial lookup of a given host name was case-sensitive. Once the result was cached, subsequent lookups were case-insensitive. That commit changed the cache access to be case-sensitive as well. This PR makes sure all lookups are performed in a case-insensitive manner.