ssh-agent: solved multi-user and logout issue

master
Pierre Neidhardt 2013-12-21 20:02:24 +01:00
parent d7e44784ec
commit 941c595a5b
3 changed files with 18 additions and 19 deletions

View File

@ -178,6 +178,8 @@ repeat= .
entry_delete_active=Control d entry_delete_active=Control d
hints_selector=
[1] [1]
save_search_field=gs save_search_field=gs
tab_new=ga tab_new=ga

View File

@ -162,3 +162,4 @@ hint-offset-left=0
block-insecure-content=false block-insecure-content=false
enable-ipc=true enable-ipc=true
adblocker-element-hider=true

View File

@ -57,7 +57,7 @@ fi
unset TEXDIR unset TEXDIR
## Make 'less' more friendly for non-text input files, see lesspipe(1). ## Make 'less' more friendly for non-text input files, see lesspipe(1).
[ -n "$(command -v lesspipe)" ] && eval "$(lesspipe)" command -v lesspipe >/dev/null && eval "$(lesspipe)"
## Manpage. ## Manpage.
export MANPAGER="less -s" export MANPAGER="less -s"
@ -78,38 +78,34 @@ export TIME_STYLE=+"|%Y-%m-%d %H:%M:%S|"
## Default text editor ## Default text editor
EDITOR="nano" EDITOR="nano"
[ -n "$(command -v vim)" ] && EDITOR="vim" command -v vim >/dev/null && EDITOR="vim"
[ -n "$(command -v emacs)" ] && EDITOR="emacs" command -v emacs >/dev/null && EDITOR="emacs"
GIT_EDITOR="$EDITOR" GIT_EDITOR="$EDITOR"
## 'em' is a script for emacsclient. See 'homeinit'. ## 'em' is a script for emacsclient. See 'homeinit'.
if [ -n "$(command -v em)" ]; then if command -v em >/dev/null; then
EDITOR='em' EDITOR='em'
GIT_EDITOR='emc' GIT_EDITOR='emc'
fi fi
export EDITOR export EDITOR
export GIT_EDITOR export GIT_EDITOR
## Internet Browser ## Internet Browser
[ -n "$(command -v luakit)" ] && export BROWSER="luakit" command -v luakit >/dev/null && export BROWSER="luakit"
[ -n "$(command -v dwb)" ] && export BROWSER="dwb" command -v dwb >/dev/null && export BROWSER="dwb"
## SSH-Agent ## SSH-Agent
## WARNING: this is somewhat insecure. Avoid using it on a mutli-user machine. ## WARNING: this is somewhat insecure if someone else has root access to the machine.
if [ -n "$(command -v ssh-agent)" ]; then if command -v ssh-agent >/dev/null; then
SSH_ENV_FILE="/tmp/ssh-agent-env" readonly SSH_ENV_FILE="$HOME/.ssh/ssh-agent-env"
if [ $(ps ax -o command="" | grep -c "ssh-agent") -eq 1 ]; then if [ ! -f "$SSH_ENV_FILE" ]; then
SSH_AGENT_VARS=$(ssh-agent) ssh-agent > "$SSH_ENV_FILE"
eval $(echo "${SSH_AGENT_VARS}")
echo "${SSH_AGENT_VARS}" | sed '2q' | cut -d'=' -f2 | cut -d';' -f1 > "$SSH_ENV_FILE"
chmod 444 "$SSH_ENV_FILE"
unset $SSH_AGENT_VARS
elif [ -f "$SSH_ENV_FILE" ]; then
SSH_AUTH_SOCK=$(sed -n '1{p;q}' "$SSH_ENV_FILE") ; export SSH_AUTH_SOCK
SSH_AGENT_PID=$(sed -n '2{p;q}' "$SSH_ENV_FILE") 2>/dev/null ; export SSH_AGENT_PID
fi fi
unset SSH_ENV_FILE source "$SSH_ENV_FILE"
fi fi
## Kill ssh-agent if this is the only running session.
trap '[ $(w -hs $USER | wc -l) -eq 1 ] && test -n "$SSH_AGENT_PID" && eval $(ssh-agent -k) && rm "$SSH_ENV_FILE"' 0
## Set TEMP dir if you want to override /tmp for some applications that check ## Set TEMP dir if you want to override /tmp for some applications that check
## for this variable. Usually not a good idea. ## for this variable. Usually not a good idea.