From 331d12ed50aa265e2fc7a865a0d8872e9666e9b9 Mon Sep 17 00:00:00 2001 From: r5d Date: Thu, 13 Jul 2017 13:13:59 -0400 Subject: [PATCH] certbot: Update storage.get_link_target (#4750) (#4923) * certbot: Update storage.get_link_target (#4750) * The `get_link_target` function raises `errors.CertStorageError` when link does not exists. * certbot: Fix typo in storage.get_link_target. --- certbot/storage.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/certbot/storage.py b/certbot/storage.py index 4f167d4ea..d03052dae 100644 --- a/certbot/storage.py +++ b/certbot/storage.py @@ -186,8 +186,15 @@ def get_link_target(link): :returns: Absolute path to the target of link :rtype: str + :raises .CertStorageError: If link does not exists. + """ - target = os.readlink(link) + try: + target = os.readlink(link) + except OSError: + raise errors.CertStorageError( + "Expected {0} to be a symlink".format(link)) + if not os.path.isabs(target): target = os.path.join(os.path.dirname(link), target) return os.path.abspath(target)