ShadowCat8 Apprentice
Joined: 07 Oct 2008 Posts: 173 Location: San Bernardino, CA, USA
|
Posted: Fri Nov 18, 2016 9:21 pm Post subject: [Solved] gpg-agent and the "missing" socket |
|
|
Greetings,
Recently, I have been getting a new error every time I open a new terminal:
Code: | Daemon gpg-agent already running.
find: '/tmp/gpg-*': No such file or directory
Updating socket file link.
cp: missing destination file operand after '/home/<user>/.gnupg/S.gpg-agent'
Try 'cp --help' for more information.
tech8 ~ $ |
Yes, I am running the following recommended script to make sure that gpg-agent is running and available for my environment:
Code: | #!/bin/bash
#
# gpg-agent-start.sh - A quick script to get the gpg-agent started at
# login.
#
# Decide wether to start gpg-agent daemon.
# Create necessary symbolic link in $HOME/.gnupg/S.gpg-agent
#
SOCKET=S.gpg-agent
PIDOF=`pidof gpg-agent`
RETVAL=$?
if [ "$RETVAL" -eq 1 ]; then
echo "Starting gpg-agent daemon."
eval `gpg-agent --daemon `
else
echo "Daemon gpg-agent already running."
fi
# Nasty way to find gpg-agent's socket file...
GPG_SOCKET_FILE=`find /tmp/gpg-* -name $SOCKET`
echo "Updating socket file link."
cp -fs $GPG_SOCKET_FILE $HOME/.gnupg/S.gpg-agent |
So, I check and sure enough there is no "gpg-*" directory under /tmp. Then, I try killing and restarting gpg-agent --daemon and still no directory under /tmp.
I look around here and around the web and find that a lot of people are having the issue, but no one gives a direct answer of what the core cause is or how to solve it. So, after I know that gpg-agent is running (on PID 4792 in this case), I run:
Code: | tech8 ~ $ lsof -n -p 4792
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
gpg-agent 4792 user8 cwd DIR 8,3 4096 2 /
gpg-agent 4792 user8 rtd DIR 8,3 4096 2 /
gpg-agent 4792 user8 txt REG 8,3 355504 4367566 /usr/bin/gpg-agent
gpg-agent 4792 user8 mem REG 8,3 1660288 10314288 /lib64/libc-2.22.so
gpg-agent 4792 user8 mem REG 8,3 133800 10314099 /lib64/libpthread-2.22.so
gpg-agent 4792 user8 mem REG 8,3 18664 8650879 /usr/lib64/libnpth.so.0.0.5
gpg-agent 4792 user8 mem REG 8,3 76624 11198573 /usr/lib64/libassuan.so.0.7.3
gpg-agent 4792 user8 mem REG 8,3 80248 11903141 /usr/lib64/libgpg-error.so.0.19.1
gpg-agent 4792 user8 mem REG 8,3 1105544 14001630 /usr/lib64/libgcrypt.so.20.1.3
gpg-agent 4792 user8 mem REG 8,3 140520 10314097 /lib64/ld-2.22.so
gpg-agent 4792 user8 0r CHR 1,3 0t0 2051 /dev/null
gpg-agent 4792 user8 1w CHR 1,3 0t0 2051 /dev/null
gpg-agent 4792 user8 2u CHR 4,4 0t0 3080 /dev/tty4
gpg-agent 4792 user8 3u unix 0xffff8800379a1680 0t0 8846 /run/user/<UID>/gnupg/S.gpg-agent type=STREAM
gpg-agent 4792 user8 5r CHR 1,9 0t0 1027 /dev/urandom
tech8 ~ $ ls -l /run/user/<UID>/gnupg/S.gpg-agent
srwx------ 1 user8 users 0 Nov 17 09:59 /run/user/<UID>/gnupg/S.gpg-agent
tech8 ~ $ |
Ah-HA!!! So, the socket moved from /tmp/gpg-[A-Za-z0-9]{5,7}/S.gpg-agent to /run/user/<UID>/gnupg/S.gpg-agent.
So, updating the script fixes that...
Code: | #!/bin/bash
#
# gpg-agent-start.sh - A quick script to get the gpg-agent started at
# login.
# (Updated 20161118 due to breakage.)
#
# Decide wether to start gpg-agent daemon.
# Create necessary symbolic link in $HOME/.gnupg/S.gpg-agent
#
SOCKET=S.gpg-agent
PIDOF=`pidof gpg-agent`
RETVAL=$?
if [ "$RETVAL" -eq 1 ]; then
echo "Starting gpg-agent daemon."
eval `gpg-agent --daemon `
else
echo "Daemon gpg-agent already running."
fi
# Nasty way to find gpg-agent's socket file...
# 20161118 - Now we're going to do it right!
GPG_SOCKET_FILE=`find /run/user/$UID/gnupg/ -name $SOCKET`
if [ -z "${GPG_SOCKET_FILE}" ]
then
echo -e "Couldn't find the socket... \nYou may have to reset gpg-agent.\nExiting"
else
echo "Updating socket file link."
cp -fs $GPG_SOCKET_FILE $HOME/.gnupg/S.gpg-agent
fi
#
## EOF |
But why was there nothing put out in news or in the Changelogs for gnupg regarding the move of the socket location? I know that there has been the big push to move things out of /var and /tmp to /run, but I would think that a move of this kind would be some important information that many people would need to know.
In any case, I hope this proves helpful to others. _________________ ________________________
"As far as the laws of mathematics refer to reality, they are not
certain, and as far as they are certain, they do not refer to reality."
-- Albert Einstein |
|