Bug#524190: bash-completion: SSH completion of know hosts doesn't handle multiple host files

2009-04-15 Thread Thomas Nilsson
Package: bash-completion
Version: 1:1.0-2
Severity: normal
Tags: patch


I have a few IPs that has their OS replaced on a regular basis, for
these I have /dev/null set as their UserKnownHostsFile.

The eval line used to expand $HOME etc, is dangerous (probably only for
the users of a system if you have a BOFH). With multiple entries the
next entry will be tried to be executed;

kni...@traktor:~$ grep UserKnownHostsFile .ssh/config 
UserKnownHostsFile /tmp/lo l
#UserKnownHostsFile /dev/null
UserKnownHostsFile /dev/null
kni...@traktor:~$ ssh [TAB]bash: /dev/null: Permission denied

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.26-1-686 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=sv_SE.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages bash-completion depends on:
ii  bash  3.2-5  The GNU Bourne Again SHell

bash-completion recommends no packages.

bash-completion suggests no packages.

-- debconf-show failed
--- bash_completion 2009-04-02 22:01:39.0 +0200
+++ /etc/bash_completion.new2009-04-15 13:19:36.0 +0200
@@ -2635,6 +2635,7 @@
local configfile
local cur curd ocur user suffix aliases global_kh user_kh hosts i host
local -a kh khd config
+   local IFS=$'\n'
 
COMPREPLY=()
cur=`_get_cword`
@@ -2667,14 +2668,20 @@
 
if [ ${#conf...@]} -gt 0 ]; then
# expand path (if present) to global known hosts file
-   global_kh=$( eval echo $( sed -ne 's/^[ 
\t]*[Gg][Ll][Oo][Bb][Aa][Ll][Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee]['$'\t
 '']*\(.*\)$/\1/p' ${conf...@]} ) )
+   global_kh=($( sed -ne 's/^[ 
\t]*[Gg][Ll][Oo][Bb][Aa][Ll][Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee]['$'\t
 '']*\(.*\)$/\1/p' ${conf...@]} ))
+   for (( i=0; i  ${#global_...@]}; i++ )); do
+   global_kh[i]=$(eval echo ${global_kh[i]//\/})
+   done
# expand path (if present) to user known hosts file
-   user_kh=$( eval echo $( sed -ne 's/^[ 
\t]*[Uu][Ss][Ee][Rr][Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee]['$'\t
 '']*\(.*\)$/\1/p' ${conf...@]} ) )
+   user_kh=($( sed -ne 's/^[ 
\t]*[Uu][Ss][Ee][Rr][Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee]['$'\t
 '']*\(.*\)$/\1/p' ${conf...@]} ))
+   for (( i=0; i  ${#user_...@]}; i++ )); do
+   user_kh[i]=$(eval echo ${user_kh[i]//\/})
+   done
fi
 
# Global known_hosts files
[ -r $global_kh ] 
-   kh=( ${...@]} $global_kh )
+   kh=( ${...@]} ${global_...@]} )
if [ -z $configfile ]; then
[ -r /etc/ssh/ssh_known_hosts ] 
  kh=( ${...@]} /etc/ssh/ssh_known_hosts )
@@ -2690,7 +2697,7 @@
 
# User known_hosts files
[ -r $user_kh ] 
-   kh=( ${...@]} $user_kh )
+   kh=( ${...@]} ${user_...@]} )
if [ -z $configfile ]; then
[ -r ~/.ssh/known_hosts ] 
  kh=( ${...@]} ~/.ssh/known_hosts )


Bug#524190: [Bash-completion-devel] Bug#524190: bash-completion: SSH completion of know hosts doesn't handle multiple host files

2009-04-15 Thread David Paleino
forwarded 524190 https://alioth.debian.org/tracker/?func=detailaid=311595
tags 524190 upstream confirmed
thanks

Hello Thomas,

On Wed, 15 Apr 2009 13:41:55 +0200, Thomas Nilsson wrote:

 Package: bash-completion
 Version: 1:1.0-2
 Severity: normal
 Tags: patch

Thank you for the patch! From a quick look, I believe we'll merge it upstream.
I'll ask for comments to other team members though.

 [..]
 
 The eval line used to expand $HOME etc, is dangerous (probably only for
 the users of a system if you have a BOFH). With multiple entries the
 next entry will be tried to be executed;

This is a known issue, already reported in our upstream tracker (see the URL
above).

Thank you for reporting,
David

-- 
 . ''`.  Debian maintainer | http://wiki.debian.org/DavidPaleino
 : :'  : Linuxer #334216 --|-- http://www.hanskalabs.net/
 `. `'`  GPG: 1392B174 | http://snipr.com/qa_page
   `-   2BAB C625 4E66 E7B8 450A C3E1 E6AA 9017 1392 B174


signature.asc
Description: PGP signature


Bug#524190: [Bash-completion-devel] Bug#524190: bash-completion: SSH completion of know hosts doesn't handle multiple host files

2009-04-15 Thread bash-completion-devel

David Paleino wrote:


The eval line used to expand $HOME etc, is dangerous (probably only for
the users of a system if you have a BOFH). With multiple entries the
next entry will be tried to be executed;


This is a known issue, already reported in our upstream tracker (see the URL
above).


The patch solves half that problem (but won't help if the file is 
defined like $() `` etc)




--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org