summaryrefslogtreecommitdiff
path: root/rdiff-backup/rdiff_backup
diff options
context:
space:
mode:
Diffstat (limited to 'rdiff-backup/rdiff_backup')
-rw-r--r--rdiff-backup/rdiff_backup/backup.py23
-rw-r--r--rdiff-backup/rdiff_backup/increment.py8
-rw-r--r--rdiff-backup/rdiff_backup/regress.py6
-rw-r--r--rdiff-backup/rdiff_backup/rpath.py8
4 files changed, 35 insertions, 10 deletions
diff --git a/rdiff-backup/rdiff_backup/backup.py b/rdiff-backup/rdiff_backup/backup.py
index 5040de6..e0a66a2 100644
--- a/rdiff-backup/rdiff_backup/backup.py
+++ b/rdiff-backup/rdiff_backup/backup.py
@@ -181,15 +181,26 @@ class DestinationStruct:
elif dest_rorp:
dest_sig = dest_rorp.getRORPath()
if dest_rorp.isreg():
- dest_rp = dest_base_rpath.new_index(index)
- if not dest_rp.isreg():
- log.ErrorLog.write_if_open("UpdateError", dest_rp,
- "File changed from regular file before signature")
- return None
- dest_sig.setfile(Rdiff.get_signature(dest_rp))
+ sig_fp = cls.get_one_sig_fp(dest_base_rpath.new_index(index))
+ if sig_fp is None: return None
+ dest_sig.setfile(sig_fp)
else: dest_sig = rpath.RORPath(index)
return dest_sig
+ def get_one_sig_fp(cls, dest_rp):
+ """Return a signature fp of given index, corresponding to reg file"""
+ if not dest_rp.isreg():
+ 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():
+ # 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)
+
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/increment.py b/rdiff-backup/rdiff_backup/increment.py
index ce6585c..d0341ef 100644
--- a/rdiff-backup/rdiff_backup/increment.py
+++ b/rdiff-backup/rdiff_backup/increment.py
@@ -79,7 +79,13 @@ def makediff(new, mirror, incpref):
if compress: diff = get_inc(incpref, "diff.gz")
else: diff = get_inc(incpref, "diff")
- Rdiff.write_delta(new, mirror, diff, compress)
+ if Globals.process_uid != 0 and not new.readable():
+ # Check for unreadable files
+ old_new_perms = new.getperms()
+ new.chmod(0400 | old_new_perms)
+ Rdiff.write_delta(new, mirror, diff, compress)
+ new.chmod(old_new_perms)
+ else: Rdiff.write_delta(new, mirror, diff, compress)
rpath.copy_attribs(mirror, diff)
return diff
diff --git a/rdiff-backup/rdiff_backup/regress.py b/rdiff-backup/rdiff_backup/regress.py
index 883c609..464314c 100644
--- a/rdiff-backup/rdiff_backup/regress.py
+++ b/rdiff-backup/rdiff_backup/regress.py
@@ -27,9 +27,9 @@ metadata file (which we assume is intact) and delete the extra
increments. For regular files we examine the mirror file and use the
increment file to get the old data if the mirror file is out of date.
-Currently this does recover hard links. This make make the regressed
-directory take up more disk space, but hard links can still be
-recovered.
+Currently this does not recover hard links. This may make the
+regressed directory take up more disk space, but hard links can still
+be recovered.
"""
diff --git a/rdiff-backup/rdiff_backup/rpath.py b/rdiff-backup/rdiff_backup/rpath.py
index ec513fd..0f3ddc1 100644
--- a/rdiff-backup/rdiff_backup/rpath.py
+++ b/rdiff-backup/rdiff_backup/rpath.py
@@ -828,6 +828,14 @@ class RPath(RORPath):
raise RPathException("Error closing file")
self.setdata()
+ def write_string(self, s, compress = None):
+ """Write string s into rpath"""
+ assert not self.lstat(), "File %s already exists" % (self.path,)
+ outfp = self.open("wb", compress = compress)
+ outfp.write(s)
+ assert not outfp.close()
+ self.setdata()
+
def isincfile(self):
"""Return true if path looks like an increment file