Bugzilla – Attachment 1051 Details for
Bug 910
known_hosts port numbers
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Support ip:port for know_hosts file
openssh-4.2p1_support_know_host_port.patch (text/plain), 9.24 KB, created by
Martial Rioux
on 2006-01-18 11:23:29 AEDT
(
hide
)
Description:
Support ip:port for know_hosts file
Filename:
MIME Type:
Creator:
Martial Rioux
Created:
2006-01-18 11:23:29 AEDT
Size:
9.24 KB
patch
obsolete
>diff -uprN openssh-4.2p1-orig/hostfile.c openssh-4.2p1/hostfile.c >--- openssh-4.2p1-orig/hostfile.c 2005-08-02 03:07:08.000000000 -0400 >+++ openssh-4.2p1/hostfile.c 2006-01-17 18:18:12.000000000 -0500 >@@ -187,7 +187,7 @@ hostfile_check_key(int bits, const Key * > > static HostStatus > check_host_in_hostfile_by_key_or_type(const char *filename, >- const char *host, const Key *key, int keytype, Key *found, int *numret) >+ const char *host, u_short port, const Key *key, int keytype, Key *found, int *numret) > { > FILE *f; > char line[8192]; >@@ -195,6 +195,9 @@ check_host_in_hostfile_by_key_or_type(co > u_int kbits; > char *cp, *cp2, *hashed_host; > HostStatus end_return; >+ char host_port[1024]; >+ >+ snprintf(host_port, sizeof host_port, "%.200s:%hu", host, port); > > debug3("check_host_in_hostfile: filename %s", filename); > >@@ -226,10 +229,10 @@ check_host_in_hostfile_by_key_or_type(co > ; > > /* Check if the host name matches. */ >- if (match_hostname(host, cp, (u_int) (cp2 - cp)) != 1) { >+ if (match_hostname(host_port, cp, (u_int) (cp2 - cp)) != 1) { > if (*cp != HASH_DELIM) > continue; >- hashed_host = host_hash(host, cp, (u_int) (cp2 - cp)); >+ hashed_host = host_hash(host_port, cp, (u_int) (cp2 - cp)); > if (hashed_host == NULL) { > debug("Invalid hashed host line %d of %s", > linenum, filename); >@@ -259,7 +262,7 @@ check_host_in_hostfile_by_key_or_type(co > continue; > } > >- if (!hostfile_check_key(kbits, found, host, filename, linenum)) >+ if (!hostfile_check_key(kbits, found, host_port, filename, linenum)) > continue; > > /* Check if the current key is the same as the given key. */ >@@ -287,20 +290,20 @@ check_host_in_hostfile_by_key_or_type(co > } > > HostStatus >-check_host_in_hostfile(const char *filename, const char *host, const Key *key, >+check_host_in_hostfile(const char *filename, const char *host, u_short port, const Key *key, > Key *found, int *numret) > { > if (key == NULL) > fatal("no key to look up"); >- return (check_host_in_hostfile_by_key_or_type(filename, host, key, 0, >+ return (check_host_in_hostfile_by_key_or_type(filename, host, port, key, 0, > found, numret)); > } > > int >-lookup_key_in_hostfile_by_type(const char *filename, const char *host, >+lookup_key_in_hostfile_by_type(const char *filename, const char *host, u_short port, > int keytype, Key *found, int *numret) > { >- return (check_host_in_hostfile_by_key_or_type(filename, host, NULL, >+ return (check_host_in_hostfile_by_key_or_type(filename, host, port, NULL, > keytype, found, numret) == HOST_FOUND); > } > >@@ -310,13 +313,16 @@ lookup_key_in_hostfile_by_type(const cha > */ > > int >-add_host_to_hostfile(const char *filename, const char *host, const Key *key, >+add_host_to_hostfile(const char *filename, const char *host, u_short port, const Key *key, > int store_hash) > { > FILE *f; > int success = 0; > char *hashed_host = NULL; >+ char host_port[1024]; > >+ snprintf(host_port, sizeof host_port, "%.200s:%hu", host, port); >+ > if (key == NULL) > return 1; /* XXX ? */ > f = fopen(filename, "a"); >@@ -324,13 +330,13 @@ add_host_to_hostfile(const char *filenam > return 0; > > if (store_hash) { >- if ((hashed_host = host_hash(host, NULL, 0)) == NULL) { >+ if ((hashed_host = host_hash(host_port, NULL, 0)) == NULL) { > error("add_host_to_hostfile: host_hash failed"); > fclose(f); > return 0; > } > } >- fprintf(f, "%s ", store_hash ? hashed_host : host); >+ fprintf(f, "%s ", store_hash ? hashed_host : host_port); > > if (key_write(key, f)) { > success = 1; >diff -uprN openssh-4.2p1-orig/hostfile.h openssh-4.2p1/hostfile.h >--- openssh-4.2p1-orig/hostfile.h 2005-03-01 05:47:37.000000000 -0500 >+++ openssh-4.2p1/hostfile.h 2006-01-17 18:18:12.000000000 -0500 >@@ -19,10 +19,10 @@ typedef enum { > } HostStatus; > > int hostfile_read_key(char **, u_int *, Key *); >-HostStatus check_host_in_hostfile(const char *, const char *, >+HostStatus check_host_in_hostfile(const char *, const char *, u_short, > const Key *, Key *, int *); >-int add_host_to_hostfile(const char *, const char *, const Key *, int); >-int lookup_key_in_hostfile_by_type(const char *, const char *, >+int add_host_to_hostfile(const char *, const char *, u_short, const Key *, int); >+int lookup_key_in_hostfile_by_type(const char *, const char *, u_short, > int, Key *, int *); > > #define HASH_MAGIC "|1|" >diff -uprN openssh-4.2p1-orig/sshconnect.c openssh-4.2p1/sshconnect.c >--- openssh-4.2p1-orig/sshconnect.c 2005-07-17 03:22:46.000000000 -0400 >+++ openssh-4.2p1/sshconnect.c 2006-01-17 18:18:17.000000000 -0500 >@@ -608,11 +608,11 @@ check_host_key(char *host, struct sockad > * hosts or in the systemwide list. > */ > host_file = user_hostfile; >- host_status = check_host_in_hostfile(host_file, host, host_key, >+ host_status = check_host_in_hostfile(host_file, host, options.port, host_key, > file_key, &host_line); > if (host_status == HOST_NEW) { > host_file = system_hostfile; >- host_status = check_host_in_hostfile(host_file, host, host_key, >+ host_status = check_host_in_hostfile(host_file, host, options.port, host_key, > file_key, &host_line); > } > /* >@@ -623,11 +623,11 @@ check_host_key(char *host, struct sockad > Key *ip_key = key_new(host_key->type); > > ip_file = user_hostfile; >- ip_status = check_host_in_hostfile(ip_file, ip, host_key, >+ ip_status = check_host_in_hostfile(ip_file, ip, options.port, host_key, > ip_key, &ip_line); > if (ip_status == HOST_NEW) { > ip_file = system_hostfile; >- ip_status = check_host_in_hostfile(ip_file, ip, >+ ip_status = check_host_in_hostfile(ip_file, ip, options.port, > host_key, ip_key, &ip_line); > } > if (host_status == HOST_CHANGED && >@@ -651,15 +651,15 @@ check_host_key(char *host, struct sockad > logit("%s host key for IP address " > "'%.128s' not in list of known hosts.", > type, ip); >- else if (!add_host_to_hostfile(user_hostfile, ip, >+ else if (!add_host_to_hostfile(user_hostfile, ip, options.port, > host_key, options.hash_known_hosts)) > logit("Failed to add the %s host key for IP " >- "address '%.128s' to the list of known " >- "hosts (%.30s).", type, ip, user_hostfile); >+ "address '%.128s:%hu' to the list of known " >+ "hosts (%.30s).", type, ip, options.port, user_hostfile); > else > logit("Warning: Permanently added the %s host " >- "key for IP address '%.128s' to the list " >- "of known hosts.", type, ip); >+ "key for IP address '%.128s:%hu' to the list " >+ "of known hosts.", type, ip, options.port); > } > break; > case HOST_NEW: >@@ -718,18 +718,18 @@ check_host_key(char *host, struct sockad > hostp = hostline; > if (options.hash_known_hosts) { > /* Add hash of host and IP separately */ >- r = add_host_to_hostfile(user_hostfile, host, >+ r = add_host_to_hostfile(user_hostfile, host, options.port, > host_key, options.hash_known_hosts) && >- add_host_to_hostfile(user_hostfile, ip, >+ add_host_to_hostfile(user_hostfile, ip, options.port, > host_key, options.hash_known_hosts); > } else { > /* Add unhashed "host,ip" */ > r = add_host_to_hostfile(user_hostfile, >- hostline, host_key, >+ hostline, options.port, host_key, > options.hash_known_hosts); > } > } else { >- r = add_host_to_hostfile(user_hostfile, host, host_key, >+ r = add_host_to_hostfile(user_hostfile, host, options.port, host_key, > options.hash_known_hosts); > hostp = host; > } >@@ -738,8 +738,8 @@ check_host_key(char *host, struct sockad > logit("Failed to add the host to the list of known " > "hosts (%.500s).", user_hostfile); > else >- logit("Warning: Permanently added '%.200s' (%s) to the " >- "list of known hosts.", hostp, type); >+ logit("Warning: Permanently added '%.200s:%hu' (%s) to the " >+ "list of known hosts.", hostp, options.port, type); > break; > case HOST_CHANGED: > if (options.check_host_ip && host_ip_differ) { >@@ -961,14 +961,14 @@ ssh_put_password(char *password) > } > > static int >-show_key_from_file(const char *file, const char *host, int keytype) >+show_key_from_file(const char *file, const char *host, u_short port, int keytype) > { > Key *found; > char *fp; > int line, ret; > > found = key_new(keytype); >- if ((ret = lookup_key_in_hostfile_by_type(file, host, >+ if ((ret = lookup_key_in_hostfile_by_type(file, host, port, > keytype, found, &line))) { > fp = key_fingerprint(found, SSH_FP_MD5, SSH_FP_HEX); > logit("WARNING: %s key found for host %s\n" >@@ -993,20 +993,20 @@ show_other_keys(const char *host, Key *k > if (type[i] == key->type) > continue; > if (type[i] != KEY_RSA1 && >- show_key_from_file(options.user_hostfile2, host, type[i])) { >+ show_key_from_file(options.user_hostfile2, host, options.port, type[i])) { > found = 1; > continue; > } > if (type[i] != KEY_RSA1 && >- show_key_from_file(options.system_hostfile2, host, type[i])) { >+ show_key_from_file(options.system_hostfile2, host, options.port, type[i])) { > found = 1; > continue; > } >- if (show_key_from_file(options.user_hostfile, host, type[i])) { >+ if (show_key_from_file(options.user_hostfile, host, options.port, type[i])) { > found = 1; > continue; > } >- if (show_key_from_file(options.system_hostfile, host, type[i])) { >+ if (show_key_from_file(options.system_hostfile, host, options.port, type[i])) { > found = 1; > continue; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 910
:
716
|
717
|
719
|
912
|
913
|
914
|
920
|
946
|
954
|
980
|
1051
|
1052
|
1073
|
1131
|
1132