Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.

Bug 453325

Summary: RFE: export useful resolver interfaces
Product: [Fedora] Fedora Reporter: Jeff Garzik <jgarzik>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: rawhideCC: drepper, fweimer, peterm
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Fixed In Version: 2.8.90-11 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2008-08-03 03:02:22 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Description Flags
Example code used in server to look up DNS SRV records
BIND DNS zone used for testing none

Description Jeff Garzik 2008-06-29 18:05:25 UTC
Description of problem:
ns_initparse(), ns_parserr() and friends have been in O'Reilly books and in
glibc for many years.

These functions make querying DNS (SRV records, in my case) very easy. 
Currently, I am forced to link directly with /usr/lib64/libresolv.a in
glibc-devel package, because the functions are not exported.

Request:  export these as fully supported interfaces.  They are highly useful,
already in glibc, publicly documented books for many years, and mentioned in

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. write application with ns_initparse()
2. attempt to link with "-lresolv", watch it fail
3. attempt to link with /usr/lib64/libresolv.a, watch it succeed
Actual results:
Link failure for functions in arpa/nameser.h. 

Expected results:
Success using functions in arpa/nameser.h.

Additional info:
My key need is querying SRV records.

Comment 1 Ulrich Drepper 2008-07-09 18:00:49 UTC
Provide (a pointer to) a complete example using those interfaces.

Comment 2 Jeff Garzik 2008-07-09 18:36:28 UTC
Created attachment 311401 [details]
Example code used in server to look up DNS SRV records

Here is the requested example code, which has been tested in its original form
as found in open source coarse lock daemon:

The attachment has been massaged slightly to compile on its own.  Linking
requires directly referencing /usr/lib[64]/libresolv.a as mentioned.

Comment 3 Jeff Garzik 2008-07-09 18:37:42 UTC
Created attachment 311402 [details]
BIND DNS zone used for testing

This is a BIND zone file used with bind-9.5.0-32.rc1.fc9.x86_64 to test
successful queries of DNS SRV records.	It includes a single example which
returns 3 SRV records in response.

Comment 4 Jeff Garzik 2008-07-09 18:39:55 UTC
Let me know if you need any more info.

The alternative to this API is hand-decoding DNS RRs, which is a royal pain. 
You still must know the RFC-specified layout of each RR being decoded, but the
ns* API makes client code more readable, and more maintainable.

Comment 5 Ulrich Drepper 2008-08-01 17:19:13 UTC
Upstream has now most of the functions declared in <arpa/nameser.h>.  Please
test it when Jakub builds the next rawhide glibc.

Comment 6 Ulrich Drepper 2008-08-03 03:02:22 UTC
Now in rawhide.