diff --git a/lib/idmgr_mod_pass.sh b/lib/idmgr_mod_pass.sh index 601a49c..9f2be02 100644 --- a/lib/idmgr_mod_pass.sh +++ b/lib/idmgr_mod_pass.sh @@ -6,6 +6,14 @@ IDM_MOD_DEPS="id gpg" ## Pass functions ########################################## +idm_pass_header () +{ + local id=$1 + + lib_require_bin pass || idm_exit 1 +} + + idm_pass () { #set -x @@ -21,6 +29,7 @@ idm_pass () fi # Interncal override case + idm_pass_header $id # Fallback to command lib_id_is_enabled $id @@ -32,6 +41,7 @@ idm_pass__ls () { local id=${1} lib_id_is_enabled $id || return 0 + idm_pass_header $id { PASSWORD_STORE_DIR=~/.config/pass/${id} \ diff --git a/lib/idmgr_mod_ssh.sh b/lib/idmgr_mod_ssh.sh index 05af257..adb598b 100644 --- a/lib/idmgr_mod_ssh.sh +++ b/lib/idmgr_mod_ssh.sh @@ -226,12 +226,22 @@ idm_ssh_add () lib_id_is_enabled $id - if [[ ! -z $key ]]; then - pub_keys=$(find ~/.ssh/id -maxdepth $maxdepth -name "${id}_*" -name '*pub' -name "*$1*" | sort) + if [[ ! -z "$key" ]]; then + pub_keys=$( + { + # Compat mode + find ~/.ssh/id -maxdepth $maxdepth -name "${id}_*" -name '*pub' -name "*$1*" | sort + + # New mode (test) + find ~/.ssh/$id -maxdepth $maxdepth -name "${id}_*" -name '*pub' -name "*$1*" | sort + } | sort | uniq + ) else - pub_keys=$(find ~/.ssh/id -maxdepth $maxdepth -name "${id}_*" -name '*pub' | sort) + pub_keys=$(find ~/.ssh/$id -maxdepth $maxdepth -name "${id}_*" -name '*pub' | sort) fi + echo "$pub_keys" + # Get list of key local key_list="" while read -r pub_key; do