[packages/gnupg2] Check if /proc/pid/exe is symlink to /usr/bin/gpg-agent. That way we are 100% sure that this is gpg-

Elan Ruusamäe glen at pld-linux.org
Tue Aug 2 15:37:41 CEST 2016


On 02.08.2016 15:34, Arkadiusz Miśkiewicz wrote:
> On Tuesday 02 of August 2016, Elan Ruusamäe wrote:
>
>> >
>> ># rm /usr/bin/gpg-agent
>> >rm: remove regular file '/usr/bin/gpg-agent'? y
>> >
>> ># l /proc/505/exe
>> >lrwxrwxrwx 1 glen glen 0 Jun  6 20:17 /proc/505/exe ->
>> >/usr/bin/gpg-agent (deleted)
>> >
>> >#
> Doh and resolvesymlink will return empty string in such case :-/
do not use such custom crap (resolvesymlink.c from rc-scripts), use 
readlink(1) from coreutils:

$ readlink /proc/505/exe
/usr/bin/gpg-agent (deleted)

full code (posix compliant):

$ exe=$(readlink /proc/505/exe)
$ echo ${exe% (deleted)}
/usr/bin/gpg-agent



-- 
glen



More information about the pld-devel-en mailing list