Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 284563

Summary: [patch] bash-completion known_hosts should remove [] and :port
Product: Gentoo Linux Reporter: Xuefer <xuefer>
Component: Current packagesAssignee: Gentoo Shell Tools project <shell-tools>
Status: RESOLVED UPSTREAM    
Severity: normal    
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: patch for "base" that remove [] and :port
updated patch against bash completion 1.1

Description Xuefer 2009-09-11 08:27:09 UTC
$ ssh user@<TAB>
sometimes [1.2.3.4] or [1.2.3.4]:1234 is yield, i don't think []: is a known host
i'm not sure in which case will ssh add [] to ~/.ssh/known_hosts, but it did

diff -u /usr/share/bash-completion/base-old /usr/share/bash-completion/base
--- /usr/share/bash-completion/base-old 2009-09-11 15:54:09.000000000 +0800
+++ /usr/share/bash-completion/base 2009-09-11 15:54:13.000000000 +0800
@@ -2234,6 +2234,8 @@
        COMPREPLY=( $( awk 'BEGIN {FS=","}
                /^\s*[^|\#]/ {for (i=1; i<=2; ++i) { \
                       gsub(" .*$", "", $i); \
+                      gsub("[\\[\\]]", "", $i); \
+                      gsub(":[0-9]+$", "", $i); \
                       if ($i ~ /'$cur'/) {print $i} \
                }}' "${kh[@]}" 2>/dev/null ) )
        fi
Comment 1 Xuefer 2009-09-11 08:28:04 UTC
Created attachment 203767 [details, diff]
patch for "base" that remove [] and :port
Comment 2 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2009-09-15 16:55:19 UTC
This part of the code has changed substantially since 1.0 release in upstream trunk. Would you mind filing an upstream bug so it has a chance of getting included in the 1.1 release which is slated to be done in 2 weeks.

http://bash-completion.alioth.debian.org/#bugs
Comment 3 Xuefer 2009-09-16 02:28:46 UTC
yeah, it changed a lot. but lines around my fix hasn't changed
patch against latest trunk from git
diff --git a/bash_completion b/bash_completion
index 07fe78c..1b55a97 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1172,6 +1172,8 @@ _known_hosts_real()
                        COMPREPLY=( $( awk 'BEGIN {FS=","}
                                /^\s*[^|\#]/ {for (i=1; i<=2; ++i) { \
                                       gsub(" .*$", "", $i); \
+                                      gsub("[\\[\\]]", "", $i); \
+                                      gsub(":[0-9]+$", "", $i); \
                                       if ($i ~ /'"$awkcur"'/) {print $i} \
                                }}' "${kh[@]}" 2>/dev/null ) )
                fi


i have registered a new account in their bug report system, verifying with email, got:
""" Error

Could Not Get User"""
Comment 4 Xuefer 2009-09-16 02:29:58 UTC
Created attachment 204280 [details]
updated patch against bash completion 1.1

gentoo "/etc/bash-completion.d/base" is actually /etc/bash-completion from upstream package
Comment 5 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2009-09-17 18:09:14 UTC
Thanks, I still wonder under what conditions you get [foo] in your known_hosts file.
Comment 6 Jeremy Olexa (darkside) (RETIRED) archtester gentoo-dev Security 2009-09-17 21:11:20 UTC
(In reply to comment #5)
> Thanks, I still wonder under what conditions you get [foo] in your known_hosts
> file.
> 

Ah, found it. the brackets are needed for ipv6.. Your patch is applied. I'm going to close this bug because since 1.0 was released you are the first person to report it and you already fixed it locally :) I'm anxious for 1.1 so you can expect to see that almost immediately after release.

16:07 < CIA-2> d.paleino * rf061b21 bash-completion/ (CHANGES bash_completion):
               Clean [1.2.3.4]:port format in known_hosts, thanks to Xuefer
               (Gentoo: #284563)