2020-09-16 21:42:56 +02:00
|
|
|
# --- BEGIN X2Go SSH forwarding workaround ---
|
|
|
|
|
|
|
|
|
|
|
|
# Part that runs in regular SSH session
|
|
|
|
|
|
|
|
# check we have an agent socket and
|
|
|
|
# check we have an ~/.x2go directory
|
|
|
|
if [ -n "$SSH_AUTH_SOCK" ] && \
|
|
|
|
[ -d ~/.x2go ] && \
|
|
|
|
[ -z "$X2GO_AGENT_PID" ] ; then
|
|
|
|
# touch the output file and set permissions
|
|
|
|
# (as tight as possible)
|
|
|
|
touch ~/.x2go/agentsocket
|
|
|
|
chmod 600 ~/.x2go/agentsocket
|
|
|
|
chown $USER ~/.x2go/agentsocket
|
|
|
|
# write file name of agent socket into file
|
2020-09-21 22:11:06 +02:00
|
|
|
loginfo "old agentsock $( cat ~/.x2go/agentsocket)"
|
2020-09-20 20:22:38 +02:00
|
|
|
echo $SSH_AUTH_SOCK > ~/.x2go/agentsocket
|
2020-09-21 22:11:06 +02:00
|
|
|
loginfo "write SSH_AUTH_SOCK (${SSH_AUTH_SOCK}) to ~/.x2go/agentsocket"
|
2020-09-16 21:42:56 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Part that runs in X2Go session
|
|
|
|
|
|
|
|
# check we're on an X2GoServer (x2golistsessions is in path),
|
|
|
|
# check we have a DISPLAY set, and
|
|
|
|
# check our client DISPLAY and SSH client IP correspond to
|
|
|
|
# a running X2Go session and
|
|
|
|
# check ~/.x2go/agentsocket is a regular file
|
|
|
|
if which x2golistsessions >/dev/null && \
|
|
|
|
[ -n "$DISPLAY" ] && \
|
|
|
|
[ -n "$(x2golistsessions | \
|
|
|
|
awk -F '|' '":"$3 == "'$DISPLAY'" && \
|
|
|
|
$5 == "R" && \
|
|
|
|
$8 == "'$(echo $SSH_CLIENT | \
|
|
|
|
awk '{print $1}')'" { print $3 }')" ] && \
|
|
|
|
[ -f ~/.x2go/agentsocket ] ; then
|
|
|
|
# all checks passed, read content of file
|
|
|
|
# (might still contain stale agent socket or garbage
|
|
|
|
MIGHTBEOURAGENT=$(cat ~/.x2go/agentsocket)
|
|
|
|
# check if it corresponds to an existing socket
|
2020-09-21 21:24:47 +02:00
|
|
|
logdebug "MIGHTBEOURAGENT: $MIGHTBEOURAGENT"
|
2020-09-16 21:42:56 +02:00
|
|
|
if [ -S "$MIGHTBEOURAGENT" ]; then
|
|
|
|
# export path to agent socket
|
|
|
|
export SSH_AUTH_SOCK=$MIGHTBEOURAGENT
|
2020-09-21 22:11:06 +02:00
|
|
|
logdebug "export it"
|
2020-09-16 21:42:56 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# ---- END X2Go SSH forwarding workaround ----
|
2020-09-23 08:10:20 +02:00
|
|
|
|
|
|
|
https://www.johntobin.ie/blog/updating_environment_variables_from_tmux/
|
|
|
|
function prompt_command() {
|
|
|
|
if [ -n "${TMUX}" ]; then
|
|
|
|
eval "$(tmux show-environment -s)"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
PROMPT_COMMAND=prompt_command
|