commit c40d50313588cc472b426f9b6d4450dbe9d49084 Author: Damian Johnson atagar@torproject.org Date: Wed Dec 7 09:56:23 2011 -0800
fix: buggy path handling when saving snapshots
The log snapshot method both didn't expect relative paths and threw unexpected exceptions (OSError rather than IOError) when the mkdir call for our parent directory failed.
Caught by Jeff Bonner in... http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=646080 --- src/cli/logPanel.py | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/src/cli/logPanel.py b/src/cli/logPanel.py index f39617d..179db9f 100644 --- a/src/cli/logPanel.py +++ b/src/cli/logPanel.py @@ -911,9 +911,15 @@ class LogPanel(panel.Panel, threading.Thread): path - path where to save the log snapshot """
+ path = os.path.abspath(path) + # make dir if the path doesn't already exist baseDir = os.path.dirname(path) - if not os.path.exists(baseDir): os.makedirs(baseDir) + + try: + if not os.path.exists(baseDir): os.makedirs(baseDir) + except OSError, exc: + raise IOError("unable to make directory '%s'" % baseDir)
snapshotFile = open(path, "w") self.valsLock.acquire()
tor-commits@lists.torproject.org