Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved] gpg-agent and the "missing" socket
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
ShadowCat8
Apprentice
Apprentice


Joined: 07 Oct 2008
Posts: 161
Location: San Bernardino, CA, USA

PostPosted: Fri Nov 18, 2016 9:21 pm    Post subject: [Solved] gpg-agent and the "missing" socket Reply with quote

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
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 7051
Location: almost Mile High in the USA

PostPosted: Sat Nov 19, 2016 2:52 am    Post subject: Reply with quote

Thanks for the warning.

One could say that gnu-screen also has a similar issue ... though it's a bit more dire.

I should go and block all new gnu-screens from installing just to make sure they don't get automatically pulled in and have to kill my detatched emerge the next time I get back to it...
_________________
Intel Core i7 2700K@ 4.1GHz/HD3000 graphics/8GB DDR3/180GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum