diff options
author | bescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2003-08-23 23:42:57 +0000 |
---|---|---|
committer | bescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2003-08-23 23:42:57 +0000 |
commit | 94da66c4015094e2c5a71e945ef3562644543c0f (patch) | |
tree | 9c658f51d1259e0427f131a4b8001b5ebef97eab /rdiff-backup/rdiff_backup/backup.py | |
parent | 9c8889d79e47e88564cd636efa050243be69ead5 (diff) | |
download | rdiff-backup-94da66c4015094e2c5a71e945ef3562644543c0f.tar.gz |
Added tests for and fixed problem with backing up unreadable regular
files as root on source and non-root on dest.
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@399 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/rdiff_backup/backup.py')
-rw-r--r-- | rdiff-backup/rdiff_backup/backup.py | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/rdiff-backup/rdiff_backup/backup.py b/rdiff-backup/rdiff_backup/backup.py index 33e97bf..0909722 100644 --- a/rdiff-backup/rdiff_backup/backup.py +++ b/rdiff-backup/rdiff_backup/backup.py @@ -184,15 +184,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]) |