From 231fe19bbb7c2101db97eef60c28232b0e4e4875 Mon Sep 17 00:00:00 2001 From: owsla Date: Sun, 23 Dec 2007 02:59:34 +0000 Subject: restore_set_root should check if it can read a directory before trying to list the contents. Closes Savannah bug #21106 git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@854 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109 --- rdiff-backup/CHANGELOG | 4 ++++ rdiff-backup/rdiff_backup/Main.py | 2 +- rdiff-backup/rdiff_backup/rpath.py | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/rdiff-backup/CHANGELOG b/rdiff-backup/CHANGELOG index 8d2a808..6c8513b 100644 --- a/rdiff-backup/CHANGELOG +++ b/rdiff-backup/CHANGELOG @@ -1,6 +1,10 @@ New in v1.1.15 (????/??/??) --------------------------- +restore_set_root should check if it can read a particular directory +before checking if "rdiff-backup-data" is contained in it. Closes +Savannah bug #21106. (Patch from Alex Chapman) + Regress.restore_orig_regfile should check if directories can be fsync'd before doing so. Fixes Savannah bug #21546. (Patch from Marc Horowitz) diff --git a/rdiff-backup/rdiff_backup/Main.py b/rdiff-backup/rdiff_backup/Main.py index 70adcfc..d9b57e3 100644 --- a/rdiff-backup/rdiff_backup/Main.py +++ b/rdiff-backup/rdiff_backup/Main.py @@ -598,7 +598,7 @@ def restore_set_root(rpin): i = len(pathcomps) while i >= min_len_pathcomps: parent_dir = rpath.RPath(rpin.conn, "/".join(pathcomps[:i])) - if (parent_dir.isdir() and + if (parent_dir.isdir() and parent_dir.is_readable() and "rdiff-backup-data" in parent_dir.listdir()): break if parent_dir.path == rpin.conn.Globals.get('restrict_path'): return None diff --git a/rdiff-backup/rdiff_backup/rpath.py b/rdiff-backup/rdiff_backup/rpath.py index d6f3655..03562e3 100644 --- a/rdiff-backup/rdiff_backup/rpath.py +++ b/rdiff-backup/rdiff_backup/rpath.py @@ -599,6 +599,10 @@ class RORPath: """Signal that rorp is a signature/diff for a hardlink file""" self.data['linked'] = index + def is_readable(self): + """Check whether user can read the file or directory""" + return self.conn.os.access(self.path, self.conn.os.R_OK) + def open(self, mode): """Return file type object if any was given using self.setfile""" if mode != "rb": raise RPathException("Bad mode %s" % mode) -- cgit v1.2.1