Re: reporting omission in man 3 resolver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Wladimir,

On 3/7/19 1:32 PM, Wladimir Mutel wrote:
> My Linux is Ubuntu 18.04.2 with all latest updates, and its glibc is
> 2.27-3ubuntu1
> manpages are 4.15-1 , also I looked into man7.org after you announced 5.0
> I studied sources of zdkimfilter and found a place where they consult
> h_errno value after res_query
> returns -1.
> I turned to man res_query and did not find anything about h_errno
> surprised, I contacted zdkimfilter author and he told me this has
> always be this way as per BSD specification.
> also checked glibc sources and found that h_errno is really filled
> when underlying calls fail

Your original tweeted comment was:

"man 3 resolver still fails to mention whether these functions
should update h_errno or not. had to refer to FreeBSD man pages
to actually learn this"

resolver(3) documents 15 functions. I asked you about *which*
functions set h_errno, but you've told me about only one.
For the rest, you seem to guess rather than look more deeply.

>From a bit of a reading of the glibc code... The following appear 
*not* to set h_errno:

res_init, resninit
res_nclose
res_mkquery, res_nmkquery (differs from FreeBSD man page)
res_send, res_nsend (but do set 'errno')
dn_comp, dn_expand

And the following appear to set h_errno:

res_query, res_nquery
res_search, res_nsearch
res_querydomain, res_nquerydomain

> what is left, is to specify this behavior in Linux man pages as
> explicitly as it is done in BSD

You have much more faith in the FreeBSD documentation than me. The
FreeBSD manual page [1] does not even document several functions
that the implementation appears to provide (res_nquery, res_nsearch,
res_nquerydomain, etc.) and says:

     The res_mkquery(),	res_search(), and res_query() functions	return the
     size of the response on success, or -1 if an error	occurs.	 The integer
     h_errno may be checked to determine the reason for	error.	See
     gethostbyname(3) for more information.

But in my reading of the FreeBSD code, res_mkquery() does not 
set h_errno (which is consistent with what I find in glibc).

I'm sure the there is more detail that could be added, but
by way of improving things, I've applied this patch:

diff --git a/man3/resolver.3 b/man3/resolver.3
index b50aa3611..54c5d2f7e 100644
--- a/man3/resolver.3
+++ b/man3/resolver.3
@@ -461,6 +461,20 @@ and
 .BR dn_expand ()
 functions return the length
 of the compressed name, or \-1 if an error occurs.
+.PP
+In the case of an error return from
+.BR res_nquery (),
+.BR res_query (),
+.BR res_nsearch (),
+.BR res_search (),
+.BR res_nquerydomain (),
+or
+.BR res_querydomain (),
+the global variable
+.I h_errno
+(see
+.BR gethostbyname (3))
+can be consulted to determine the cause of the error.
 .SH FILES
 .TP
 .I /etc/resolv.conf

Have a good weekend,

Michael

[1] https://www.freebsd.org/cgi/man.cgi?query=resolver&apropos=0&sektion=0&manpath=FreeBSD+12.0-RELEASE+and+Ports&arch=default&format=html

> 
> чт, 7 мар. 2019 г. в 12:52, Michael Kerrisk (man-pages)
> <mtk.manpages@xxxxxxxxx>:
>>
>> Hello Wladimir,
>>
>> On Thu, 7 Mar 2019 at 10:57, Wladimir Mutel <muwlgr@xxxxxxxxx> wrote:
>>>
>>> in https://www.freebsd.org/cgi/man.cgi?query=resolver we read :
>>>
>>>      The res_mkquery(), res_search(), and res_query() functions return the
>>>      size of the response on success, or -1 if an error occurs. The integer
>>>      h_errno may be checked to determine the reason for error. See
>>>      gethostbyname(3) for more information.
>>>
>>> in http://man7.org/linux/man-pages/man3/resolver.3.html , h_errno is
>>> not mentioned
>>> but in the end of this page we read
>>>
>>> CONFORMING TO
>>>        4.3BSD.
>>>
>>> the fact that h_errno is really modified as specified by BSD, could be
>>> confirmed experimentally, but would not it be more convenient if this
>>> was mentioned documentally ?
>>
>> Have you verified it experimentally on Linux/glibc (and for which of
>> the functions)?
>>
>> Thanks,
>>
>> Michael
>>
>>
>>
>>
>> --
>> Michael Kerrisk
>> Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
>> Linux/UNIX System Programming Training: http://man7.org/training/
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux