Bug 176093 - [libc] [patch] Fix resolver support for '_' character in hostnames
Summary: [libc] [patch] Fix resolver support for '_' character in hostnames
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 9.1-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: Hajimu UMEMOTO
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-13 03:50 UTC by Landon Fuller
Modified: 2015-06-18 16:49 UTC (History)
1 user (show)

See Also:


Attachments
file.diff (724 bytes, patch)
2013-02-13 03:50 UTC, Landon Fuller
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Landon Fuller 2013-02-13 03:50:01 UTC
Back in 2008, the libc resolver was modified to accept Microsoft's non-standard use of '_' in host names:

http://svnweb.freebsd.org/base?view=revision&revision=176325

The fix appears to be incomplete, as it only covered the case where an underscore occurs within a domain component (eg, 'example_name', rather than at the beginning or end.

The attached patch adds support for '_' occurring at the beginning, middle, or end of a name component. This style of name is required by AD, and by extension, by Samba4; this patch fixes issues with samba4 replication on FreeBSD.

Fix: See attached patch

Patch attached with submission follows:
How-To-Repeat: Try resolving a name containing a leading '_', such as 'gc._msdcs.example.org'
Comment 1 Landon Fuller 2013-02-15 13:39:04 UTC
A simpler test case:

#include <netinet/in.h>
#include <resolv.h>

int main (int argc, char *argv[]) {
    if (argc < 2) return 1;
    int ret = res_hnok(argv[1]);
    printf("%d\n", ret);
}

Usage:

landonf:~> ./test-res_hnok gc._msdcs.example.org
0

landonf:~> ./test-res_hnok gc.msdcs.example.org 
1
Comment 2 Pedro F. Giffuni freebsd_committer freebsd_triage 2014-08-23 05:43:41 UTC
Assign to committer of the original feature.
Comment 3 commit-hook freebsd_committer freebsd_triage 2015-06-10 16:15:31 UTC
A commit references this bug:

Author: ume
Date: Wed Jun 10 16:15:23 UTC 2015
New revision: 284229
URL: https://svnweb.freebsd.org/changeset/base/284229

Log:
  Add support for '_' occurring at the beginning or end of a name
  component.

  PR:		176093
  Submitted by:	landonf__at__bikemonkey.org
  MFC after:	1 week

Changes:
  head/lib/libc/resolv/res_comp.c
Comment 4 Hajimu UMEMOTO freebsd_committer freebsd_triage 2015-06-10 16:19:02 UTC
Thank you.  Committed.
Comment 5 commit-hook freebsd_committer freebsd_triage 2015-06-18 16:39:11 UTC
A commit references this bug:

Author: ume
Date: Thu Jun 18 16:39:06 UTC 2015
New revision: 284559
URL: https://svnweb.freebsd.org/changeset/base/284559

Log:
  MFC r284229: Add support for '_' occurring at the beginning or
  end of a name component.

  PR:		176093
  Submitted by:	landonf__at__bikemonkey.org

Changes:
_U  stable/10/
  stable/10/lib/libc/resolv/res_comp.c
Comment 6 commit-hook freebsd_committer freebsd_triage 2015-06-18 16:44:13 UTC
A commit references this bug:

Author: ume
Date: Thu Jun 18 16:43:38 UTC 2015
New revision: 284560
URL: https://svnweb.freebsd.org/changeset/base/284560

Log:
  MFC r284229: Add support for '_' occurring at the beginning or
  end of a name component.

  PR:		176093
  Submitted by:	landonf__at__bikemonkey.org

Changes:
_U  stable/9/lib/libc/
  stable/9/lib/libc/resolv/res_comp.c
Comment 7 commit-hook freebsd_committer freebsd_triage 2015-06-18 16:47:15 UTC
A commit references this bug:

Author: ume
Date: Thu Jun 18 16:46:41 UTC 2015
New revision: 284561
URL: https://svnweb.freebsd.org/changeset/base/284561

Log:
  MFC r284229: Add support for '_' occurring at the beginning or
  end of a name component.

  PR:		176093
  Submitted by:	landonf__at__bikemonkey.org

Changes:
_U  stable/8/lib/libc/
  stable/8/lib/libc/resolv/res_comp.c