From b9b7b244984111ec799675dc90073396481e6173 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= <chiiph@leap.se>
Date: Wed, 2 Oct 2013 21:36:37 -0300
Subject: Only pick one gnupg bin path which is not a symlink

---
 src/leap/bitmask/services/soledad/soledadbootstrapper.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

(limited to 'src')

diff --git a/src/leap/bitmask/services/soledad/soledadbootstrapper.py b/src/leap/bitmask/services/soledad/soledadbootstrapper.py
index 6731cc84..7968dd6a 100644
--- a/src/leap/bitmask/services/soledad/soledadbootstrapper.py
+++ b/src/leap/bitmask/services/soledad/soledadbootstrapper.py
@@ -321,7 +321,18 @@ class SoledadBootstrapper(AbstractBootstrapper):
             gpgbin = os.path.join(
                 get_path_prefix(), "..", "apps", "mail", "gpg")
         else:
-            gpgbin = which("gpg")
+            try:
+                gpgbin_options = which("gpg")
+                # gnupg checks that the path to the binary is not a
+                # symlink, so we need to filter those and come up with
+                # just one option.
+                for opt in gpgbin_options:
+                    if not os.path.islink(opt):
+                        gpgbin = opt
+                        break
+            except IndexError as e:
+                logger.debug("Couldn't find the gpg binary!")
+                logger.exception(e)
         leap_check(gpgbin is not None, "Could not find gpg binary")
         return gpgbin
 
-- 
cgit v1.2.3