summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2017-06-06 19:23:42 +0200
committerRuben Pollan <meskio@sindominio.net>2017-06-12 20:34:11 +0200
commit1fd9bd8f5284ed1b61da2d5cc81e3347c61a761d (patch)
treebbfb76ece9cdbe137e1e92b7327b7e64adc62add
parent60600a52b7ef6ac83e95d62acc96ebf46c2b0f63 (diff)
[feat] search first for gpg1 binary
On debian stretch (and recent ubuntu) the gpg binary is version 2. If installed gpg version 1 is found in /usr/bin/gpg1. Let's search for this first. I use the oportunity to clean up the code. I'm happy using symlinks, if the user set them up let's use them. - Resolves: #8901
-rw-r--r--src/leap/bitmask/util.py45
1 files changed, 8 insertions, 37 deletions
diff --git a/src/leap/bitmask/util.py b/src/leap/bitmask/util.py
index c5154cd..b070d9a 100644
--- a/src/leap/bitmask/util.py
+++ b/src/leap/bitmask/util.py
@@ -80,8 +80,6 @@ def get_gpg_bin_path():
:rtype: str
"""
global STANDALONE
- gpgbin = None
-
if STANDALONE:
if platform.system() == "Windows":
gpgbin = os.path.abspath(
@@ -92,40 +90,13 @@ def get_gpg_bin_path():
else:
gpgbin = os.path.abspath(
os.path.join(here(), "..", "apps", "mail", "gpg"))
- else:
- try:
- path_ext = '/usr/bin/:/usr/local/opt/gnupg/bin/'
- gpgbin_options = which("gpg", path_extension=path_ext)
- # 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:
- # dereference a symlink, but will fail because
- # no complete gpg2 support at the moment
- # path = os.readlink(opt)
- path = opt
- if os.path.exists(path) and not os.path.islink(path):
- gpgbin = path
- break
- except IndexError as e:
- log.debug("Couldn't find the gpg binary!: %s" % (e,))
-
- if gpgbin is not None:
return gpgbin
- # During the transition towards gpg2, we can look for /usr/bin/gpg1
- # binary, in case it was renamed using dpkg-divert or manually.
- # We could just pick gpg2, but we need to solve #7564 first.
- try:
- path_ext = '/usr/bin/:/usr/local/opt/gnupg/bin/'
- gpgbin_options = which("gpg1", path_extension=path_ext)
- for opt in gpgbin_options:
- if not os.path.islink(opt):
- gpgbin = opt
- break
- except IndexError as e:
- log.debug("Couldn't find the gpg1 binary!: %s" % (e,))
-
- if gpgbin is None:
- log.debug("Could not find gpg1 binary")
- return gpgbin
+ path_ext = '/bin:/usr/bin/:/usr/local/bin:/usr/local/opt/gnupg/bin/'
+ for gpgbin_name in ["gpg1", "gpg"]:
+ gpgbin_options = which(gpgbin_name, path_extension=path_ext)
+ if len(gpgbin_options) >= 1:
+ return gpgbin_options[0]
+
+ log.debug("Could not find gpg binary")
+ return None