move reading for pkcs11-module to funktions

This commit is contained in:
Jakobus Schürz 2023-02-23 09:59:46 +01:00
parent e39b7ce58c
commit 91f4bc89bd
2 changed files with 17 additions and 10 deletions

View file

@ -74,16 +74,6 @@ if [[ $- = *i* ]] ; then
# which dpkg >/dev/null 2>&1 && [ -z "${P11M+x}" ] && P11M="$(dpkg -L p11-kit-modules|grep \/p11-kit-proxy.so\$ | head -1)"
function find_pkcs11module() {
[ -z "${PKCS11_MODULE:+x}" ] && \
[ -n "$(whereis p11-kit-proxy.so|awk '{print $2}')" ] && \
export PKCS11_MODULE=$(whereis p11-kit-proxy.so|awk '{print $2}' || \
{ echo "p11-kit-proxy not installed, unset PKCS11_MODULE"; unset PKCS11_MODULE; })
[ -z "${P11M:+x}" ] && \
[ -n "$(whereis p11-kit-proxy.so|awk '{print $2}')" ] && \
export P11M=$(whereis p11-kit-proxy.so|awk '{print $2}' || \
{ echo "p11-kit-proxy not forwarded by ssh or installed, unset P11M"; unset P11M; })
}
# Basics
[ -z "${VISUAL+x}" ] && export VISUAL=${VISUAL_DEFAULT}
[ -z "${EDITOR+x}" ] && export EDITOR=${EDITOR_DEFAULT}
@ -206,8 +196,10 @@ EOF
_tmux_hook
_umask_hook
_pkcs11module
promptcommandmunge "_tmux_hook"
promptcommandmunge "_umask_hook"
promptcommandmunge "_pkcs11module"
which direnv >/dev/null && eval "$(direnv hook bash)"
cat << EOF >> "${MSC_LOGFILE}"

View file

@ -20,6 +20,20 @@ promptcommandmunge () {
esac
EXIT
}
function _pkcs11module() {
[ -z "${P11M:+x}" ] && \
[ -n "$(whereis ${pkcs11_module_default:-p11-kit-proxy.so}|awk '{print $2}')" ] && \
export P11M=$(whereis ${pkcs11_module_default:-p11-kit-proxy.so}|awk '{print $2}' || \
{ echo "${pkcs11_module_default:-p11-kit-proxy.so} not forwarded by ssh or installed, unset P11M"; unset P11M; })
[ -z "${PKCS11_MODULE:+x}" ] && PKCS11_MODULE=${P11M}
# [ -z "${PKCS11_MODULE:+x}" ] && \
# [ -n "$(whereis p11-kit-proxy.so|awk '{print $2}')" ] && \
# export PKCS11_MODULE=$(whereis p11-kit-proxy.so|awk '{print $2}' || \
# { echo "p11-kit-proxy not installed, unset PKCS11_MODULE"; unset PKCS11_MODULE; })
}
## this function updates in combination with PROMPT_COMMAND the shell-environment-variables in tmux-sessions,
# every time prompt is called. It does it only, when called from tmux (Environment TMUX is set)
function _tmux_hook() {
@ -1025,6 +1039,7 @@ loadagent() {
logdebug "SSH_AGENT_PID: ${SSH_AGENT_PID-not set}"
loginfo "currently loaded keys in agent:
$(ssh-add -l)"
export P11M=$PKCS11_MODULE
EXIT
}