Linux Manual Pages development
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx@kernel.org>
To: Jan Engelhardt <ej@inai.de>
Cc: linux-man@vger.kernel.org
Subject: Re: [PATCH] man/man3/getnameinfo.3: Mention behavior for AF_UNIX
Date: Wed, 21 Oct 2026 20:01:15 +0200	[thread overview]
Message-ID: <atj9pv8lxtunlOiM@debian> (raw)
In-Reply-To: <q790883o-osno-6n75-230r-485465rpq4r7@vanv.qr>

[-- Attachment #1: Type: text/plain, Size: 2950 bytes --]

Hi Jan,

> Date: 2026-10-20 18:01:02+0200
> From: Jan Engelhardt <ej@inai.de>
>
> 
> On Tuesday 2026-10-20 16:27, Alejandro Colomar wrote:
> >
> >I'd rewrite a little bit:
> >
> >	.SH VERSIONS
> >	POSIX only specifies the behavior for sockets of the
> >	.B AF_INET
> >	and
> >	.B AF_INET6
> >	address families.
> >	Other address families are non-portable;
> >	for example, for
> >	.BR AF_UNIX ,
> >	many libc implementations fail,
> >	some succeed but provide zero-length strings in
> >	.I host
> >	and
> >	.IR serv ,
> >	and some fill these buffers with pseudo-values.
> >
> >BTW, out of curiosity, what do those pseudo-values look like?
> 
> (Something must have gone wrong seeing zero-length output.
> So I redid the test program and runs.)

Thanks!  It'd be very useful to have this test program in the commit
message.  Would you mind sending v2 and incorporating it?  Please indent
the program with one tab, so the #include lines are not removed by
git(1).


Have a lovely night!
Alex

> 
> getnameinfo:
> 
> * FreeBSD 15: fills host="/path", serv="", returns success(0).
> 
> * glibc 2.44: fills host=<utsname> (flags=0) or host="localhost"
>   (flags=NI_NUMERICHOST), and serv="/path", returns success(0).
> 
> * OpenBSD 7.9: signals EAI_FAMILY. Upon seeing NI_NUMERICHOST,
>   signals EAI_SYSTEM instead (odd).
> 
> * OmniOS r151046 (Solaris): signals EAI_FAMILY.
> 
> * musl-libc 1.2.6 (Alpine Linux): signals EAI_FAMILY.
> 
> * cygwin 3.6.11: signals EAI_FAMILY.
> 
> getaddrinfo:
> 
> * FreeBSD: getaddrinfo("/the/socket/path", nullptr,
>   hints_with_AF_UNIX, ...) succeeds.
> 
> * the rest: signals EAI_FAMILY.
> 
> 
> ---
> #include <sys/un.h>
> #include <netdb.h>
> #include <sys/socket.h>
> #include <cstdio>
> #include <cstring>
> 
> int main()
> {
> 	struct sockaddr_un u{};
> 	u.sun_family = AF_UNIX;
> 	strcpy(u.sun_path, "/pa");
> 	char host[320] = "!", serv[320] = "!";
> 
> 	auto ret = getnameinfo(reinterpret_cast<struct sockaddr *>(&u),
> 	           sizeof(u), host, sizeof(host), serv, sizeof(serv), 0);
> 	printf("GNI %d %s\n", ret, gai_strerror(ret));
> 	if (ret == 0)
> 		printf("GNI <%s> <%s>\n", host, serv);
> 
> 	ret = getnameinfo(reinterpret_cast<struct sockaddr *>(&u),
> 	      sizeof(u), host, sizeof(host), serv, sizeof(serv), NI_NUMERICHOST | NI_NUMERICSERV);
> 	printf("GNI %d %s\n", ret, gai_strerror(ret));
> 	if (ret == 0)
> 		printf("GNI <%s> <%s>\n", host, serv);
> 
> 	struct addrinfo hints{};
> 	hints.ai_family = AF_UNIX;
> 	hints.ai_socktype = 0;
> 	struct addrinfo *res = nullptr;
> 	ret = getaddrinfo(host, serv, &hints, &res);
> 	printf("GAI %d %s\n", ret, gai_strerror(ret));
> 	if (ret == 0)
> 		for (; res != nullptr; res = res->ai_next)
> 			printf("GAI fam %u %u %u\n", res->ai_family,
> 				res->ai_socktype, res->ai_protocol);
> 	return 0;
> }

-- 
<https://www.alejandro-colomar.es>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

      reply	other threads:[~2026-10-21 18:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20 11:51 [PATCH] man/man3/getnameinfo.3: Mention behavior for AF_UNIX Jan Engelhardt
2026-10-20 14:27 ` Alejandro Colomar
2026-10-20 16:01   ` Jan Engelhardt
2026-10-21 18:01     ` Alejandro Colomar [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=atj9pv8lxtunlOiM@debian \
    --to=alx@kernel.org \
    --cc=ej@inai.de \
    --cc=linux-man@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox