Skip to content

fix(_known_hosts_real): exclude directories from the config files #818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -1905,7 +1905,7 @@ _included_ssh_config_files()
_comp_expand_glob files '$i'
if ((${#files[@]})); then
for f in "${files[@]}"; do
if [[ -r $f ]]; then
if [[ -r $f && ! -d $f ]]; then
config+=("$f")
# The Included file is processed to look for Included files in itself
_included_ssh_config_files $f
Expand Down Expand Up @@ -1973,10 +1973,10 @@ _known_hosts_real()

# ssh config files
if [[ -v configfile ]]; then
[[ -r $configfile ]] && config+=("$configfile")
[[ -r $configfile && ! -d $configfile ]] && config+=("$configfile")
else
for i in /etc/ssh/ssh_config ~/.ssh/config ~/.ssh2/config; do
[[ -r $i ]] && config+=("$i")
[[ -r $i && ! -d $i ]] && config+=("$i")
done
fi

Expand Down Expand Up @@ -2023,7 +2023,7 @@ _known_hosts_real()
for i in /etc/ssh/ssh_known_hosts /etc/ssh/ssh_known_hosts2 \
/etc/known_hosts /etc/known_hosts2 ~/.ssh/known_hosts \
~/.ssh/known_hosts2; do
[[ -r $i ]] && kh+=("$i")
[[ -r $i && ! -d $i ]] && kh+=("$i")
done
for i in /etc/ssh2/knownhosts ~/.ssh2/hostkeys; do
[[ -d $i ]] && khd+=("$i"/*pub)
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/_known_hosts_real/config_include
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ Include ~/config_full_path
Include config_relative_path
# Include with wildcards, and more than one on same row
Include config_asterisk* config_?uestion_mark
# Include a directory name. This is a misconfiguration, but ssh ignores it without errors.
Include ../../_known_hosts_real