Compare commits

...

5 commits

Author SHA1 Message Date
Jakobus Schürz
a91118423a print error, when more than one token is plugged in 2022-10-21 17:14:40 +02:00
Jakobus Schürz
2ab30111e9 add submodule handling 2022-10-21 17:11:45 +02:00
Jakobus Schürz
9491f9f017 change function-names from xx-xx to xx_xx 2022-10-21 17:10:38 +02:00
Jakobus Schürz
e78a781638 change to vim-soa url codeberg.org 2022-10-21 17:10:38 +02:00
Jakobus Schürz
6dbd379916 change urls from submodules 2022-10-21 17:10:38 +02:00
3 changed files with 56 additions and 42 deletions

8
.gitmodules vendored
View file

@ -1,12 +1,12 @@
[submodule "tmux/plugins/tpm"]
path = tmux/plugins/tpm
url = git://git.schuerz.at/github.com/tmux-plugins/tpm.git
url = https://github.com/tmux-plugins/tpm.git
[submodule "tmux/plugins/tmux-sensible"]
path = tmux/plugins/tmux-sensible
url = git://git.schuerz.at/github.com/tmux-plugins/tmux-sensible.git
url = https://github.com/tmux-plugins/tmux-sensible.git
[submodule "tmux/plugins/tmux-themepack"]
path = tmux/plugins/tmux-themepack
url = git://git.schuerz.at/github.com/jimeh/tmux-themepack.git
url = https://github.com/jimeh/tmux-themepack.git
[submodule "vim/pack/color/start/Zenburn"]
path = vim/pack/color/start/Zenburn
url = https://github.com/vim-scripts/Zenburn.git
@ -60,4 +60,4 @@
url = https://github.com/jamessan/vim-gnupg
[submodule "vim/pack/plugins/start/vim-soa"]
path = vim/pack/plugins/start/vim-soa
url = https://git.schuerz.at/public/vim-soa.git
url = https://codeberg.org/xundeenergie/vim-soa.git

View file

@ -90,6 +90,8 @@ fi
#echo $MSC_GIT fetch ${MSC_GIT_REMOTE_NAME} -p 1>&2
if $dorepoupdate; then
loginfo "git submodule sync"
logdebug "$(git submodule sync 2>&1)"
loginfo "fetch repo${dosubmodupdate:+ and submodules}"
#$MSC_GIT fetch ${dosubmodupdate:+--recurse-submodules} ${MSC_GIT_REMOTE_NAME} -p 2>>"${MSC_LOGFILE}"|| { logwarning fetch failed; gitupdateend; exit 1; }
$MSC_GIT fetch ${dosubmodupdate:+--recurse-submodules} ${MSC_GIT_REMOTE_NAME} -p 2>>"${MSC_LOGFILE}"|| { logwarning fetch failed; gitupdateend; exit 1; }
@ -103,8 +105,11 @@ if $dorepoupdate; then
no changes in local repo
$MSC_GIT checkout ${PRE}${PRE:+/}${MSC_GIT_BRANCH}
EOF
$MSC_GIT checkout ${PRE}${PRE:+/}${MSC_GIT_BRANCH} 1>>"${MSC_LOGFILE}" 2>>"${MSC_LOGFILE}"|| { gitupdateend; exit 2; }
$MSC_GIT merge FETCH_HEAD 1>>"${MSC_LOGFILE}" 2>>"${MSC_LOGFILE}"|| { gitupdateend; exit 3; }
$SGIT checkout ${PRE}${PRE:+/}${MSC_GIT_BRANCH} 1>>"${MSC_LOGFILE}" 2>>"${MSC_LOGFILE}"|| { gitupdateend; exit 2; }
$SGIT merge FETCH_HEAD 1>>"${MSC_LOGFILE}" 2>>"${MSC_LOGFILE}"|| { gitupdateend; exit 3; }
if ${dosubmodupdate:+false}; then
$SGIT submodule update --init --recursive
fi
touch $MSC_GIT_UPD_REPO_STATFILE
else
logwarning -n " Lokale Änderungen festgestellt:"

View file

@ -1,13 +1,14 @@
#!/bin/bash
FILELOGLEVEL=DEBUG
. $(dirname $0)/../logging
# loggerfactory
LANG=C
usage(){
cat << EOF
Usage: ssh-agent-start-or-restart [[-c]|[--create-only]]|[[-t]|[--token-only]]|[[-k]|[--key-only]]|[[-r]|[-f]|[--readd]|[--force]] [<ssh-identity>]
Usage: $(basename $0) [[-c]|[--create-only]]|[[-t]|[--token-only]]|[[-k]|[--key-only]]|[[-r]|[-f]|[--readd]|[--force]] [<ssh-identity>]
If started only with <ssh-identity>, the script looks up in configured identity-path \$SSH_IDENTITIES_DIR (${SSH_IDENTITIES_DIR}) if it can find a directory named after <ssh-identity>.
If no <ssh_identity> is given, the identity is set to \$SSH_DEFAULT_IDENTITY ($SSH_DEFAULT_IDENTITY) configured via Environment.
@ -121,7 +122,7 @@ logtrace " SSH_IDENTITIES_DIR: $SSH_IDENTITIES_DIR"
[ -z "${SSH_IDENTITIES_DIR-x}" ] || mkdir -vp "$SSH_IDENTITIES_DIR"
agent-start-or-restart () {
agent_start_or_restart () {
# If DISPLAY is set, ssh-add calls ssh-askpass, and if its in remote-terminal, it wont work
# So remember and unset DISPLAY, and set it at the end again, if it was set before
@ -146,7 +147,7 @@ agent-start-or-restart () {
logtrace "agentsocket for ${ssh_identity}: $agentsocket"
if (! $keyonly && ! $tokenonly ) && $remove ; then
logdebug "delete keys and tokens in this ssh-agent"
logdebug "$(ssh-runinagent $agentfile ssh-add -D 2>&1)"
logdebug "$(ssh_runinagent $agentfile ssh-add -D 2>&1)"
createonly=true
else
@ -183,7 +184,7 @@ agent-start-or-restart () {
#logdebug "ssh-agent for identity »$ssh_identity«: $agentfile"
$createonly && logtrace "current loaded keys after action:
$(ssh-runinagent $agentfile ssh-add -l)"
$(ssh_runinagent $agentfile ssh-add -l)"
echo $agentfile
ret=0
else
@ -201,7 +202,7 @@ $(ssh-runinagent $agentfile ssh-add -l)"
logdebug "$(cat $agentfile)"
logdebug "ssh-agent for identity »$ssh_identity«: $agentfile"
# logdebug "currently loaded keys after action:
#$(ssh-runinagent $agentfile ssh-add -l)"
#$(ssh_runinagent $agentfile ssh-add -l)"
echo $agentfile
ret=0
else
@ -217,7 +218,7 @@ $(ssh-runinagent $agentfile ssh-add -l)"
}
agent-load-identity-keys () {
agent_load_identity_keys () {
# If DISPLAY is set, ssh-add calls ssh-askpass, and if its in remote-terminal, it wont work
# So remember and unset DISPLAY, and set it at the end again, if it was set before
@ -247,9 +248,9 @@ agent-load-identity-keys () {
logtrace "agentsocket: $agentsocket"
logtrace "identitydir: $identitydir"
fingerprints=( $(ssh-runinagent $agentfile "ssh-add -l|awk '{print \$2}'") )
fingerprints=( $(ssh_runinagent $agentfile "ssh-add -l|awk '{print \$2}'") )
logdebug "fingerprints from loaded keys before action:"
for f in ${fingerprints[*]};do
for f in ${fingerprints[@]};do
logdebug "$f"
done
if ! $tokenonly ; then
@ -261,13 +262,13 @@ agent-load-identity-keys () {
if $readd || $remove ; then
$readd && logdebug "re-add key $key"
$remove && logdebug "remove key $key"
logdebug "$(ssh-runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -d ${key} 2>&1)"
$remove || logdebug "$(ssh-runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} ${key} 2>&1)"
logdebug "$(ssh_runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -d ${key} 2>&1)"
$remove || logdebug "$(ssh_runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} ${key} 2>&1)"
fi
else
logdebug "key: $key is not loaded -> load it"
#logdebug "$(ssh-runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -d ${key} 2>&1)"
$remove || logdebug "$(ssh-runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} ${key} 2>&1)"
#logdebug "$(ssh_runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -d ${key} 2>&1)"
$remove || logdebug "$(ssh_runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} ${key} 2>&1)"
fi
done
fi
@ -302,30 +303,38 @@ agent-load-identity-keys () {
#[ "$(readlink - f $key)" == "$P11M" ] || key="$P11M"
[ "$(readlink -f $key)" != "$P11M" -a "${P11M:-x}" != "x" ] && key="$P11M"
logdebug "P11M2: ${P11M:-not set} - key: $key"
echo "P11M: ${P11M:-not set} - key: $key"
logdebug "P11M: ${P11M:-not set} - key: $key"
tokenfingerprint="$(ssh-keygen -l -D $key|tr -s ' '|awk '{print $2}')"
tokenfingerprints=($(ssh-keygen -l -D $key|tr -s ' '|awk '{print $2}'))
if [[ ${fingerprints[*]} =~ "$tokenfingerprint" ]]; then
logdebug "token: $key ($tokenfingerprint) is loaded"
check-pubkeysonly
if $readd || $remove ; then
$readd && logdebug "re-add token $key"
$remove && logdebug "remove token $key"
echo agentfile1 $agentfile \$SSH_ADD_OPTIONS $key >&2
logdebug "$(ssh-runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -e "${key}" 2>&1)"
ssh-runinagent $agentfile echo $SSH_AUTH_SOCK >&2
$remove || logdebug "$(ssh-runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -s "${key}" 2>&1)"
fi
logtrace "fingerprints: ${fingerprints[*]}"
logtrace "tokenfingerprints count: ${#tokenfingerprints[@]}"
if [ ${#tokenfingerprints[@]} -gt 1 ]; then
logerr "Found ${#tokenfingerprints[@]} in p11-kit-proxy! Check if only one token is plugged into your computer"
else
logdebug "token: $key is not loaded -> load it"
logdebug "$(ssh-runinagent $agentfile ssh-add -v ${SSH_ADD_OPTIONS} -e ${key} 2>&1)"
$remove || logdebug "$(ssh-runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -s ${key} 2>&1)"
tokenfingerprint=${tokenfingerprints[0]}
logtrace "tokenfingerprint: ${tokenfingerprint}"
if [[ "${fingerprints[@]}" =~ "$tokenfingerprint" ]]; then
logdebug "token: $key ($tokenfingerprint) is loaded"
check_pubkeysonly
if $readd || $remove ; then
$readd && logdebug "re-add token $key"
$remove && logdebug "remove token $key"
echo agentfile1 $agentfile \$SSH_ADD_OPTIONS $key >&2
logdebug "$(ssh_runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -e "${key}" 2>&1)"
ssh_runinagent $agentfile echo $SSH_AUTH_SOCK >&2
$remove || logdebug "$(ssh_runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -s "${key}" 2>&1)"
fi
else
logdebug "token: $key is not loaded -> load it"
logdebug "$(ssh_runinagent $agentfile ssh-add -v ${SSH_ADD_OPTIONS} -e ${key} 2>&1)"
$remove || logdebug "$(ssh_runinagent $agentfile ssh-add ${SSH_ADD_OPTIONS} -s ${key} 2>&1)"
fi
fi
done
fi
loginfo "currently loaded keys after action: $(ssh-runinagent $agentfile ssh-add -l|wc -l)"
logdebug "$(ssh-runinagent $agentfile ssh-add -l)"
loginfo "currently loaded keys after action: $(ssh_runinagent $agentfile ssh-add -l|wc -l)"
logdebug "$(ssh_runinagent $agentfile ssh-add -l)"
else
logwarning "ssh-identity $ssh_identity is not configured. Please create $identitydir and add keys"
fi
@ -336,10 +345,10 @@ agent-load-identity-keys () {
}
function check-pubkeysonly () {
function check_pubkeysonly () {
if [ ${#pubkeysonly[*]} -gt 0 ] ; then
for p in ${pubkeysonly[@]}; do
ssh-runinagent $agentfile ssh-add -T ${p} 2>&1 || { $remove || readd=true; break; }
ssh_runinagent $agentfile ssh-add -T ${p} 2>&1 || { $remove || readd=true; break; }
done
else
logwarning "obviously there is no pubkey for the token in ${SSH_IDENTITIES_DIR}/${ssh_identity}/"
@ -352,7 +361,7 @@ function check-pubkeysonly () {
logdebug "readd: $readd"
}
ssh-runinagent () {
ssh_runinagent () {
local agentfile
@ -375,13 +384,13 @@ ssh-runinagent () {
}
if [[ $SSH_TTY || $X2GO_SESSION ]] ; then
logdebug "run with forwarded ssh-agent"
logdebug "Shell running with forwarded ssh-agent. Please add local token manually"
check_token
res=1
else
logdebug "run with local ssh-agent"
agent-start-or-restart $ssh_identity
! $createonly && agent-load-identity-keys $ssh_identity
agent_start_or_restart $ssh_identity
! $createonly && agent_load_identity_keys $ssh_identity
res=0
fi
SCRIPTEXIT