From 1fd9bd8f5284ed1b61da2d5cc81e3347c61a761d Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Tue, 6 Jun 2017 19:23:42 +0200 Subject: [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 --- src/leap/bitmask/util.py | 45 ++++++++------------------------------------- 1 file changed, 8 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/leap/bitmask/util.py b/src/leap/bitmask/util.py index c5154cd0..b070d9a8 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 -- cgit v1.2.3