diff options
author | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2004-06-20 05:18:08 +0000 |
---|---|---|
committer | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2004-06-20 05:18:08 +0000 |
commit | f3d96fbe9f8d685796905fd77130026d831158f7 (patch) | |
tree | ec40caa774d6ea5a8ef17c945ab42f261cddd747 | |
parent | 8f7d467acaabccac369fa81f4ed9b008e31206b6 (diff) |
make popa3d (inetd mode) address family neutral (= IPv6 support).
from popa3d patch by kame
-rw-r--r-- | usr.sbin/popa3d/virtual.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/usr.sbin/popa3d/virtual.c b/usr.sbin/popa3d/virtual.c index 3ec70d7d535..1153fd474bd 100644 --- a/usr.sbin/popa3d/virtual.c +++ b/usr.sbin/popa3d/virtual.c @@ -1,4 +1,4 @@ -/* $OpenBSD: virtual.c,v 1.5 2003/06/19 07:21:20 pvalchev Exp $ */ +/* $OpenBSD: virtual.c,v 1.6 2004/06/20 05:18:07 itojun Exp $ */ /* * Virtual domain support. @@ -42,18 +42,26 @@ int virtual_startup(void) static char *lookup(void) { - struct sockaddr_in sin; + struct sockaddr_storage ss; int length; + int error; + static char hbuf[NI_MAXHOST]; - length = sizeof(sin); - if (getsockname(0, (struct sockaddr *)&sin, &length)) { + length = sizeof(ss); + if (getsockname(0, (struct sockaddr *)&ss, &length)) { if (errno == ENOTSOCK) return ""; log_error("getsockname"); return NULL; } - if (length != sizeof(sin) || sin.sin_family != AF_INET) return NULL; - return inet_ntoa(sin.sin_addr); + error = getnameinfo((struct sockaddr *)&ss, length, hbuf, sizeof(hbuf), + NULL, 0, NI_NUMERICHOST); + if (error) { + /* logging? */ + return NULL; + } + + return hbuf; } static int is_valid_user(char *user) |