Fix reading rest of user/global known hosts files when the first one is not readable.
https://bugzilla.redhat.com/show_bug.cgi?id=541423#c2 As a side effect, this simplifies things somewhat and grabs user and global known hosts filenames from config files with one command instead of doing one for each.
This commit is contained in:
parent
a9717be57b
commit
6f921d563b
2
CHANGES
2
CHANGES
@ -24,7 +24,7 @@ bash-completion (2.x)
|
||||
* Apply pine completion to alpine too.
|
||||
* Remove many unnecessary short option completions where long ones exist.
|
||||
* Improve configure, cvs, gkrellm, lftp, mdadm, modprobe, mplayer,
|
||||
mysqladmin, service, and ssh completions.
|
||||
mysqladmin, service, ssh, and general hostname completions.
|
||||
* Add abook and wtf completion, based on work by Raphaël Droz.
|
||||
* Add k3b and lftpget completion.
|
||||
* Don't overwrite other host completions when completing from multiple
|
||||
|
@ -1223,7 +1223,7 @@ _known_hosts()
|
||||
_known_hosts_real()
|
||||
{
|
||||
local configfile flag prefix
|
||||
local cur curd awkcur user suffix aliases global_kh user_kh hosts i host
|
||||
local cur curd awkcur user suffix aliases hosts i host
|
||||
local -a kh khd config
|
||||
|
||||
local OPTIND=1
|
||||
@ -1258,22 +1258,17 @@ _known_hosts_real()
|
||||
|
||||
if [ ${#config[@]} -gt 0 ]; then
|
||||
local OIFS=$IFS IFS=$'\n'
|
||||
# expand path (if present) to global known hosts file
|
||||
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' "${config[@]}" ))
|
||||
for (( i=0; i < ${#global_kh[@]}; i++ )); do
|
||||
global_kh[i]=$(echo "${global_kh[i]//\"/}")
|
||||
done
|
||||
# expand path (if present) to user known hosts file
|
||||
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' "${config[@]}" ))
|
||||
for (( i=0; i < ${#user_kh[@]}; i++ )); do
|
||||
user_kh[i]=$(echo "${user_kh[i]//\"/}")
|
||||
local -a tmpkh
|
||||
# expand paths (if present) to global and user known hosts files
|
||||
tmpkh=( $( sed -ne 's/^[ \t]*\([Gg][Ll][Oo][Bb][Aa][Ll]\|[Uu][Ss][Ee][Rr]\)[Kk][Nn][Oo][Ww][Nn][Hh][Oo][Ss][Tt][Ss][Ff][Ii][Ll][Ee]['"$'\t '"']*\(.*\)$/"\2"/p' "${config[@]}" ) )
|
||||
for i in "${tmpkh[@]}"; do
|
||||
i=$( echo "${i//\"/}" )
|
||||
[ -r "$i" ] && kh=( "${kh[@]}" "$i" )
|
||||
done
|
||||
IFS=$OIFS
|
||||
fi
|
||||
|
||||
# Global known_hosts files
|
||||
[ -r "$global_kh" ] &&
|
||||
kh=( "${kh[@]}" "${global_kh[@]}" )
|
||||
if [ -z "$configfile" ]; then
|
||||
[ -r /etc/ssh/ssh_known_hosts ] &&
|
||||
kh=( "${kh[@]}" /etc/ssh/ssh_known_hosts )
|
||||
@ -1288,8 +1283,6 @@ _known_hosts_real()
|
||||
fi
|
||||
|
||||
# User known_hosts files
|
||||
[ -r "$user_kh" ] &&
|
||||
kh=( "${kh[@]}" "${user_kh[@]}" )
|
||||
if [ -z "$configfile" ]; then
|
||||
[ -r ~/.ssh/known_hosts ] &&
|
||||
kh=( "${kh[@]}" ~/.ssh/known_hosts )
|
||||
|
Loading…
x
Reference in New Issue
Block a user