diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-10-21 23:20:59 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-10-23 00:26:35 -0400 |
commit | cb6518345fcc057ca6ed3d037253bb4eeab4d94e (patch) | |
tree | fe5e03d9fe4ac23b1728942c004b7bda63ca9402 /src | |
parent | a7736b14de340c01580dd4c09145c846d21211b9 (diff) |
socket-util: use IP address when hostname is not found
socknameinfo_pretty() would fail for addresses without reverse DNS,
but we do not want that to happen.
Diffstat (limited to 'src')
-rw-r--r-- | src/shared/socket-util.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c index e3e54e8e08..911dbfe55a 100644 --- a/src/shared/socket-util.c +++ b/src/shared/socket-util.c @@ -633,20 +633,20 @@ int socknameinfo_pretty(union sockaddr_union *sa, socklen_t salen, char **_ret) r = getnameinfo(&sa->sa, salen, host, sizeof(host), NULL, 0, NI_IDN|NI_IDN_USE_STD3_ASCII_RULES); if (r != 0) { - _cleanup_free_ char *sockname = NULL; int saved_errno = errno; - r = sockaddr_pretty(&sa->sa, salen, true, &sockname); - if (r < 0) + r = sockaddr_pretty(&sa->sa, salen, true, &ret); + if (r < 0) { log_error("sockadd_pretty() failed: %s", strerror(-r)); - else - log_error("getnameinfo(%s) failed: %s", sockname, strerror(-r)); - return -saved_errno; - } + return r; + } - ret = strdup(host); - if (!ret) - return log_oom(); + log_debug("getnameinfo(%s) failed: %s", ret, strerror(saved_errno)); + } else { + ret = strdup(host); + if (!ret) + return log_oom(); + } *_ret = ret; return 0; |