mirror of
https://github.com/moparisthebest/sslh
synced 2024-12-22 07:18:57 -05:00
Fix access rights checking to work with IPv6.
This commit is contained in:
parent
4cbaf447b5
commit
717c285b31
13
common.c
13
common.c
@ -471,16 +471,19 @@ void log_connection(struct connection *cnx)
|
|||||||
int check_access_rights(int in_socket, const char* service)
|
int check_access_rights(int in_socket, const char* service)
|
||||||
{
|
{
|
||||||
#ifdef LIBWRAP
|
#ifdef LIBWRAP
|
||||||
struct sockaddr peeraddr;
|
union {
|
||||||
socklen_t size = sizeof(peeraddr);
|
struct sockaddr saddr;
|
||||||
|
struct sockaddr_storage ss;
|
||||||
|
} peer;
|
||||||
|
socklen_t size = sizeof(peer);
|
||||||
char addr_str[NI_MAXHOST], host[NI_MAXHOST];
|
char addr_str[NI_MAXHOST], host[NI_MAXHOST];
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
res = getpeername(in_socket, &peeraddr, &size);
|
res = getpeername(in_socket, &peer.saddr, &size);
|
||||||
CHECK_RES_RETURN(res, "getpeername");
|
CHECK_RES_RETURN(res, "getpeername");
|
||||||
|
|
||||||
/* extract peer address */
|
/* extract peer address */
|
||||||
res = getnameinfo(&peeraddr, size, addr_str, sizeof(addr_str), NULL, 0, NI_NUMERICHOST);
|
res = getnameinfo(&peer.saddr, size, addr_str, sizeof(addr_str), NULL, 0, NI_NUMERICHOST);
|
||||||
if (res) {
|
if (res) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
fprintf(stderr, "getnameinfo(NI_NUMERICHOST):%s\n", gai_strerror(res));
|
fprintf(stderr, "getnameinfo(NI_NUMERICHOST):%s\n", gai_strerror(res));
|
||||||
@ -489,7 +492,7 @@ int check_access_rights(int in_socket, const char* service)
|
|||||||
/* extract peer name */
|
/* extract peer name */
|
||||||
strcpy(host, STRING_UNKNOWN);
|
strcpy(host, STRING_UNKNOWN);
|
||||||
if (!numeric) {
|
if (!numeric) {
|
||||||
res = getnameinfo(&peeraddr, size, host, sizeof(host), NULL, 0, NI_NAMEREQD);
|
res = getnameinfo(&peer.saddr, size, host, sizeof(host), NULL, 0, NI_NAMEREQD);
|
||||||
if (res) {
|
if (res) {
|
||||||
if (verbose)
|
if (verbose)
|
||||||
fprintf(stderr, "getnameinfo(NI_NAMEREQD):%s\n", gai_strerror(res));
|
fprintf(stderr, "getnameinfo(NI_NAMEREQD):%s\n", gai_strerror(res));
|
||||||
|
Loading…
Reference in New Issue
Block a user