summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorowsla <owsla@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2007-12-24 22:39:47 +0000
committerowsla <owsla@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2007-12-24 22:39:47 +0000
commitc2df9f46b8a2c81aedceff403f0c49cab09d50b5 (patch)
tree945961d71c9c63a6560a2834fa7724bf73c34885
parent231fe19bbb7c2101db97eef60c28232b0e4e4875 (diff)
downloadrdiff-backup-c2df9f46b8a2c81aedceff403f0c49cab09d50b5.tar.gz
- Replace is_readable() function with pre-existing readable() function
- Close Savannah bug #21202 by not assuming that file cannot be opened even if read permissions don't indicate such. git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@855 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
-rw-r--r--rdiff-backup/CHANGELOG4
-rw-r--r--rdiff-backup/rdiff_backup/Main.py2
-rw-r--r--rdiff-backup/rdiff_backup/backup.py15
-rw-r--r--rdiff-backup/rdiff_backup/rpath.py4
4 files changed, 16 insertions, 9 deletions
diff --git a/rdiff-backup/CHANGELOG b/rdiff-backup/CHANGELOG
index 6c8513b..bf1b11a 100644
--- a/rdiff-backup/CHANGELOG
+++ b/rdiff-backup/CHANGELOG
@@ -1,6 +1,10 @@
New in v1.1.15 (????/??/??)
---------------------------
+Don't assume that a file cannot be read simply becasue of the access
+permissions -- eg, NFS with (rw,all_squash) options. Closes Savannah
+bug #21202. (Based on patch from Marc Horowitz)
+
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)
diff --git a/rdiff-backup/rdiff_backup/Main.py b/rdiff-backup/rdiff_backup/Main.py
index d9b57e3..155cd90 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 parent_dir.is_readable() and
+ if (parent_dir.isdir() and parent_dir.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/backup.py b/rdiff-backup/rdiff_backup/backup.py
index 7d24eb7..2b139f4 100644
--- a/rdiff-backup/rdiff_backup/backup.py
+++ b/rdiff-backup/rdiff_backup/backup.py
@@ -202,14 +202,21 @@ class DestinationStruct:
log.ErrorLog.write_if_open("UpdateError", dest_rp,
"File changed from regular file before signature")
return None
- if Globals.process_uid != 0 and not dest_rp.readable():
+ if (Globals.process_uid != 0 and not dest_rp.readable() and
+ dest_rp.isowner()):
# This branch can happen with root source and non-root
# destination. Permissions are changed permanently, which
# should propogate to the diffs
- assert dest_rp.isowner(), 'no ownership of %s' % (dest_rp.path,)
dest_rp.chmod(0400 | dest_rp.getperms())
- return Rdiff.get_signature(dest_rp)
-
+ try:
+ return Rdiff.get_signature(dest_rp)
+ except IOError, e:
+ if (e.errno == errno.EPERM):
+ log.Log.FatalError("Could not open %s for reading. Check "
+ "permissions on file." % (dest_rp.path,))
+ else:
+ raise
+
def patch(cls, dest_rpath, source_diffiter, start_index = ()):
"""Patch dest_rpath with an rorpiter of diffs"""
ITR = rorpiter.IterTreeReducer(PatchITRB, [dest_rpath, cls.CCPP])
diff --git a/rdiff-backup/rdiff_backup/rpath.py b/rdiff-backup/rdiff_backup/rpath.py
index 03562e3..d6f3655 100644
--- a/rdiff-backup/rdiff_backup/rpath.py
+++ b/rdiff-backup/rdiff_backup/rpath.py
@@ -599,10 +599,6 @@ 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)