From 68e6e7e8e894312efb6d550d57fcafcd09b5fe4d Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Fri, 21 Jun 2013 18:33:56 +0200 Subject: lib: Remove unused "get_peer_name" Signed-off-by: Volker Lendecke Reviewed-by: Andrew Bartlett --- source3/lib/util_sock.c | 79 ------------------------------------------------- 1 file changed, 79 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index 509e7b7d3a..a35ae97eba 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -1022,85 +1022,6 @@ static void store_nc(const struct name_addr_pair *nc) data_blob_free(&tmp); } -/******************************************************************* - Return the DNS name of the remote end of a socket. -******************************************************************/ - -const char *get_peer_name(int fd, bool force_lookup) -{ - struct name_addr_pair nc; - char addr_buf[INET6_ADDRSTRLEN]; - struct sockaddr_storage ss; - socklen_t length = sizeof(ss); - const char *p; - int ret; - char name_buf[MAX_DNS_NAME_LENGTH]; - char tmp_name[MAX_DNS_NAME_LENGTH]; - - /* reverse lookups can be *very* expensive, and in many - situations won't work because many networks don't link dhcp - with dns. To avoid the delay we avoid the lookup if - possible */ - if (!lp_hostname_lookups() && (force_lookup == false)) { - length = sizeof(nc.ss); - nc.name = get_peer_addr_internal(fd, addr_buf, sizeof(addr_buf), - (struct sockaddr *)&nc.ss, &length); - store_nc(&nc); - lookup_nc(&nc); - return nc.name ? nc.name : "UNKNOWN"; - } - - lookup_nc(&nc); - - memset(&ss, '\0', sizeof(ss)); - p = get_peer_addr_internal(fd, addr_buf, sizeof(addr_buf), (struct sockaddr *)&ss, &length); - - /* it might be the same as the last one - save some DNS work */ - if (sockaddr_equal((struct sockaddr *)&ss, (struct sockaddr *)&nc.ss)) { - return nc.name ? nc.name : "UNKNOWN"; - } - - /* Not the same. We need to lookup. */ - if (fd == -1) { - return "UNKNOWN"; - } - - /* Look up the remote host name. */ - ret = sys_getnameinfo((struct sockaddr *)&ss, - length, - name_buf, - sizeof(name_buf), - NULL, - 0, - 0); - - if (ret) { - DEBUG(1,("get_peer_name: getnameinfo failed " - "for %s with error %s\n", - p, - gai_strerror(ret))); - strlcpy(name_buf, p, sizeof(name_buf)); - } else { - if (!matchname(name_buf, (struct sockaddr *)&ss, length)) { - DEBUG(0,("Matchname failed on %s %s\n",name_buf,p)); - strlcpy(name_buf,"UNKNOWN",sizeof(name_buf)); - } - } - - strlcpy(tmp_name, name_buf, sizeof(tmp_name)); - alpha_strcpy(name_buf, tmp_name, "_-.", sizeof(name_buf)); - if (strstr(name_buf,"..")) { - strlcpy(name_buf, "UNKNOWN", sizeof(name_buf)); - } - - nc.name = name_buf; - nc.ss = ss; - - store_nc(&nc); - lookup_nc(&nc); - return nc.name ? nc.name : "UNKNOWN"; -} - /******************************************************************* Return the IP addr of the remote end of a socket as a string. ******************************************************************/ -- cgit