From 00dad4c41bd562aaeda5e6adb11e58277f8157d5 Mon Sep 17 00:00:00 2001 From: Yuval Greenfield Date: Thu, 12 Nov 2015 17:39:02 -0800 Subject: [PATCH] Avoid breaking with local relative paths A fix for https://github.com/harlowja/fasteners/issues/12 --- fasteners/process_lock.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fasteners/process_lock.py b/fasteners/process_lock.py index 898056a..74ca97d 100644 --- a/fasteners/process_lock.py +++ b/fasteners/process_lock.py @@ -111,10 +111,11 @@ class _InterProcessLock(object): def _do_open(self): basedir = os.path.dirname(self.path) - made_basedir = _ensure_tree(basedir) - if made_basedir: - self.logger.log(_utils.BLATHER, - 'Created lock base path `%s`', basedir) + if basedir: + made_basedir = _ensure_tree(basedir) + if made_basedir: + self.logger.log(_utils.BLATHER, + 'Created lock base path `%s`', basedir) # Open in append mode so we don't overwrite any potential contents of # the target file. This eliminates the possibility of an attacker # creating a symlink to an important file in our lock path.