/usr/lib/python3/dist-packages/certbot/plugins
NameSizeModeActions
__pycache__/-0755rm
common.py191290644editdlrm
common_test.py152490644editdlrm
disco.py102000644editdlrm
disco_test.py116120644editdlrm
dns_common.py119690644editdlrm
dns_common_lexicon.py55380644editdlrm
dns_common_lexicon_test.py6510644editdlrm
dns_common_test.py83780644editdlrm
dns_test_common.py16850644editdlrm
dns_test_common_lexicon.py56150644editdlrm
enhancements.py57180644editdlrm
enhancements_test.py24160644editdlrm
manual.py80650644editdlrm
manual_test.py57300644editdlrm
null.py12990644editdlrm
null_test.py6240644editdlrm
selection.py138730644editdlrm
selection_test.py79710644editdlrm
standalone.py79090644editdlrm
standalone_test.py68030644editdlrm
storage.py42420644editdlrm
storage_test.py56030644editdlrm
util.py17350644editdlrm
util_test.py18500644editdlrm
webroot.py123690644editdlrm
webroot_test.py134240644editdlrm
__init__.py300644editdlrm
Edit: /usr/lib/python3/dist-packages/certbot/plugins/util.py (1735B)
"""Plugin utilities.""" import logging from certbot import util from certbot.compat import os from certbot.compat.misc import STANDARD_BINARY_DIRS logger = logging.getLogger(__name__) def get_prefixes(path): """Retrieves all possible path prefixes of a path, in descending order of length. For instance, (linux) /a/b/c returns ['/a/b/c', '/a/b', '/a', '/'] (windows) C:\\a\\b\\c returns ['C:\\a\\b\\c', 'C:\\a\\b', 'C:\\a', 'C:'] :param str path: the path to break into prefixes :returns: all possible path prefixes of given path in descending order :rtype: `list` of `str` """ prefix = os.path.normpath(path) prefixes = [] while prefix: prefixes.append(prefix) prefix, _ = os.path.split(prefix) # break once we hit the root path if prefix == prefixes[-1]: break return prefixes def path_surgery(cmd): """Attempt to perform PATH surgery to find cmd Mitigates https://github.com/certbot/certbot/issues/1833 :param str cmd: the command that is being searched for in the PATH :returns: True if the operation succeeded, False otherwise """ path = os.environ["PATH"] added = [] for d in STANDARD_BINARY_DIRS: if d not in path: path += os.pathsep + d added.append(d) if any(added): logger.debug("Can't find %s, attempting PATH mitigation by adding %s", cmd, os.pathsep.join(added)) os.environ["PATH"] = path if util.exe_exists(cmd): return True expanded = " expanded" if any(added) else "" logger.debug("Failed to find executable %s in%s PATH: %s", cmd, expanded, path) return False