summaryrefslogtreecommitdiff
path: root/canohost.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2010-01-13 22:43:33 +1100
committerDarren Tucker <dtucker@zip.com.au>2010-01-13 22:43:33 +1100
commitdaaa4500519627abee7c6d1969bc33df6572c1e8 (patch)
tree147e27dfb2199cc90f4f20625d0091fb90698ec1 /canohost.c
parent561724f38dd8b4e56ec918a70f9314f41c34b46a (diff)
- dtucker@cvs.openbsd.org 2010/01/13 01:20:20
[canohost.c ssh-keysign.c sshconnect2.c] Make HostBased authentication work with a ProxyCommand. bz #1569, patch from imorgan at nas nasa gov, ok djm@
Diffstat (limited to 'canohost.c')
-rw-r--r--canohost.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/canohost.c b/canohost.c
index 22b19bb9..ef94d915 100644
--- a/canohost.c
+++ b/canohost.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: canohost.c,v 1.65 2009/05/27 06:31:25 andreas Exp $ */
+/* $OpenBSD: canohost.c,v 1.66 2010/01/13 01:20:20 dtucker Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -27,6 +27,7 @@
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
+#include <unistd.h>
#include "xmalloc.h"
#include "packet.h"
@@ -301,9 +302,22 @@ get_local_ipaddr(int sock)
}
char *
-get_local_name(int sock)
+get_local_name(int fd)
{
- return get_socket_address(sock, 0, NI_NAMEREQD);
+ char *host, myname[NI_MAXHOST];
+
+ /* Assume we were passed a socket */
+ if ((host = get_socket_address(fd, 0, NI_NAMEREQD)) != NULL)
+ return host;
+
+ /* Handle the case where we were passed a pipe */
+ if (gethostname(myname, sizeof(myname)) == -1) {
+ verbose("get_local_name: gethostname: %s", strerror(errno));
+ } else {
+ host = xstrdup(myname);
+ }
+
+ return host;
}
void