diff options
author | Darren Tucker <dtucker@zip.com.au> | 2006-07-10 23:04:19 +1000 |
---|---|---|
committer | Darren Tucker <dtucker@zip.com.au> | 2006-07-10 23:04:19 +1000 |
commit | da3455356100dbcb5d1ff9f0556386ca5f788795 (patch) | |
tree | 013d0f5e5bca486e4e72387d94980fc81d402a50 /misc.c | |
parent | 0f07707267fd3911bcf95b48125b522f9e222c64 (diff) | |
download | openssh-git-da3455356100dbcb5d1ff9f0556386ca5f788795.tar.gz |
- dtucker@cvs.openbsd.org 2006/07/10 12:46:51
[misc.c misc.h sshd.8 sshconnect.c]
Add port identifier to known_hosts for non-default ports, based originally
on a patch from Devin Nate in bz#910.
For any connection using the default port or using a HostKeyAlias the
format is unchanged, otherwise the host name or address is enclosed
within square brackets in the same format as sshd's ListenAddress.
Tested by many, ok markus@.
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.55 2006/07/09 15:15:10 stevesk Exp $ */ +/* $OpenBSD: misc.c,v 1.56 2006/07/10 12:46:51 dtucker Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2005,2006 Damien Miller. All rights reserved. @@ -45,6 +45,7 @@ #include "misc.h" #include "log.h" #include "xmalloc.h" +#include "ssh.h" /* remove newline at end of string */ char * @@ -337,6 +338,23 @@ convtime(const char *s) } /* + * Returns a standardized host+port identifier string. + * Caller must free returned string. + */ +char * +put_host_port(const char *host, u_short port) +{ + char *hoststr; + + if (port == 0 || port == SSH_DEFAULT_PORT) + return(xstrdup(host)); + if (asprintf(&hoststr, "[%s]:%d", host, (int)port) < 0) + fatal("put_host_port: asprintf: %s", strerror(errno)); + debug3("put_host_port: %s", hoststr); + return hoststr; +} + +/* * Search for next delimiter between hostnames/addresses and ports. * Argument may be modified (for termination). * Returns *cp if parsing succeeds. |