diff --git a/CHANGES b/CHANGES index d5327e53..f5db7872 100644 --- a/CHANGES +++ b/CHANGES @@ -27,6 +27,8 @@ bash-completion (1.x) * Add more mod-like audio file extensions for xine-based players and timidity. * Complete on plain alternatives like update-alternatives. * Rename installed_alternatives() to _installed_alternatives(). + * Add /etc/pki/tls/openssl.cnf to list of default openssl config files, + search for default ones only if -config is not given. [ Todd Zullinger ] * Make yum complete on filenames after install, deplist, update and upgrade diff --git a/bash_completion b/bash_completion index 5a47d2b8..dfcf5182 100644 --- a/bash_completion +++ b/bash_completion @@ -3548,17 +3548,21 @@ complete -F _bzip2 $filenames bzip2 have openssl && { _openssl_sections() { - local config + local config f - config=/etc/ssl/openssl.cnf - [ ! -f $config ] && config=/usr/share/ssl/openssl.cnf for (( i=2; i < COMP_CWORD; i++ )); do if [[ "${COMP_WORDS[i]}" == -config ]]; then config=${COMP_WORDS[i+1]} break fi done - [ ! -f $config ] && return 0 + if [ -z "$config" ]; then + for f in /etc/ssl/openssl.cnf /etc/pki/tls/openssl.cnf \ + /usr/share/ssl/openssl.cnf; do + [ -f $f ] && config=$f && break + done + fi + [ ! -f "$config" ] && return 0 COMPREPLY=( $( awk '/\[.*\]/ {print $2} ' $config | grep "^$cur" ) ) } diff --git a/to_review/openssl b/to_review/openssl index e5d721db..1a04d9b3 100644 --- a/to_review/openssl +++ b/to_review/openssl @@ -6,10 +6,7 @@ have openssl && { _openssl_sections() { - local config - - # start with default configuration - config=/etc/pki/tls/openssl.cnf + local config f # check if a specific configuration file is used for (( i=2; i < COMP_CWORD; i++ )); do @@ -19,7 +16,15 @@ _openssl_sections() fi done - [ ! -f $config ] && return 0 + # if no config given, check some usual default locations + if [ -z "$config" ]; then + for f in /etc/ssl/openssl.cnf /etc/pki/tls/openssl.cnf \ + /usr/share/ssl/openssl.cnf; do + [ -f $f ] && config=$f && break + done + fi + + [ ! -f "$config" ] && return 0 COMPREPLY=( $( awk '/\[.*\]/ {print $2} ' $config | grep "^$cur" ) ) }