ocehb: (Default)
ocehb ([personal profile] ocehb) wrote2013-11-27 10:45 am
Entry tags:

Восстановление слетевшей gpg-agent сессии



Ищет pid запущеного агента (если их несколько, то последнего в списке
процессов), угадывает его сокет, и устанавливает переменные окружения.
Можно оформить как скрипт, но не нравится eval.


#! zsh -f
#
# function gpg-agent-env () {

local pid socket

ps -C gpg-agent -o pid,user --no-headers | tail -1 | \
    awk "/$LOGNAME\$/ { print \$1 }" | read pid

if [[ -z $pid ]]; then
    print -u2 "no gpg-agent process for current user"
    return 1
fi

netstat -A unix -pl 2>/dev/null | \
    grep -F "$pid/gpg-agent" | \
    sed -e "s#^.\\+$pid/gpg-agent \\+##" | read socket
export GPG_AGENT_INFO="$socket:$pid:1" GPG_TTY=$( tty )

# }




Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org