From 58c38700ed37a7e69bd2cfcc1b5508f843b86cf1 Mon Sep 17 00:00:00 2001 From: bescoto Date: Wed, 16 Jul 2003 19:28:33 +0000 Subject: Mostly tweaks to get the test cases to work git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@337 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109 --- rdiff-backup/TODO | 6 ++-- rdiff-backup/rdiff_backup/Main.py | 4 +-- rdiff-backup/rdiff_backup/eas_acls.py | 46 ++++++++++++++++++++++++++++-- rdiff-backup/rdiff_backup/increment.py | 2 +- rdiff-backup/testing/commontest.py | 5 ++-- rdiff-backup/testing/test1/tmp/placeholder | 0 6 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 rdiff-backup/testing/test1/tmp/placeholder diff --git a/rdiff-backup/TODO b/rdiff-backup/TODO index 33191ee..bb65ff6 100644 --- a/rdiff-backup/TODO +++ b/rdiff-backup/TODO @@ -1,6 +1,8 @@ -Use ctime to check whether files have been changed +Use ctime to check whether files have been changed. See message: +http://mail.gnu.org/archive/html/rdiff-backup-users/2003-06/msg00050.html +by Andrew Bressen. -Include some option to summarize space taken up +Profile 0.13.0 ---------[ Medium term ]--------------------------------------- diff --git a/rdiff-backup/rdiff_backup/Main.py b/rdiff-backup/rdiff_backup/Main.py index f135219..eaa1559 100644 --- a/rdiff-backup/rdiff_backup/Main.py +++ b/rdiff-backup/rdiff_backup/Main.py @@ -377,7 +377,7 @@ def Restore(src_rp, dest_rp, restore_as_of = None): """ if not restore_root_set: assert restore_set_root(src_rp) restore_check_paths(src_rp, dest_rp, restore_as_of) - restore_set_fs_globals(Globals.rbdir) + restore_set_fs_globals(dest_rp) src_rp = restore_init_quoting(src_rp) restore_check_backup_dir(restore_root, src_rp, restore_as_of) if restore_as_of: @@ -412,7 +412,7 @@ def restore_set_fs_globals(target): SetConnections.UpdateGlobal('preserve_hardlinks', target_fsa.hardlinks) SetConnections.UpdateGlobal('change_ownership', target_fsa.ownership) - mirror_fsa = fs_abilities.FSAbilities().init_readwrite(Globals.rbdir) + mirror_fsa = fs_abilities.FSAbilities().init_readonly(Globals.rbdir) if Globals.chars_to_quote is None: # otherwise already overridden if mirror_fsa.chars_to_quote: SetConnections.UpdateGlobal('chars_to_quote', diff --git a/rdiff-backup/rdiff_backup/eas_acls.py b/rdiff-backup/rdiff_backup/eas_acls.py index 748d8bb..577a09c 100644 --- a/rdiff-backup/rdiff_backup/eas_acls.py +++ b/rdiff-backup/rdiff_backup/eas_acls.py @@ -43,7 +43,6 @@ class ExtendedAttributes: """Equal if all attributes and index are equal""" assert isinstance(ea, ExtendedAttributes) return ea.index == self.index and ea.attr_dict == self.attr_dict - def __ne__(self, ea): return not self.__eq__(ea) def get_indexpath(self): return self.index and '/'.join(self.index) or '.' @@ -89,7 +88,7 @@ class ExtendedAttributes: """Return true if no extended attributes are set""" return not self.attr_dict -def compare_rps(rp1, rp2): +def ea_compare_rps(rp1, rp2): """Return true if rp1 and rp2 have same extended attributes""" ea1 = ExtendedAttributes(rp1.index) ea1.read_from_rp(rp1) @@ -183,3 +182,46 @@ class ExtendedAttributesFile(metadata.FlatFile): return join_eas(basic_iter, ea_iter) static.MakeClass(ExtendedAttributesFile) + + +class AccessControlList: + """Hold a file's access control list information""" + def __init__(self, index, text_acl = None): + """Initialize object with index and possibly text_acl""" + self.index = index + # self.ACL is a posix1e ACL object + if text_acl is None: self.ACL = None + else: self.ACL = posix1e.ACL(text_acl) + + def __eq__(self, acl): + """Compare self and other access control list""" + return self.index == acl.index and str(self.ACL) == str(acl.ACL) + def __ne__(self, acl): return not self.__eq__(acl) + + def get_indexpath(self): return self.index and '/'.join(self.index) or '.' + + +def get_acl_from_rp(rp): + """Return text acl from an rpath, or None if not supported""" + try: acl = rp.conn.posix1e.ACL(file=rp.path) + except IOError, exc: + if exc[0] == errno.EOPNOTSUPP: return None + raise + return str(acl) + +def acl_compare_rps(rp1, rp2): + """Return true if rp1 and rp2 have same acls""" + return get_acl_from_rp(rp1) == get_acl_from_rp(rp2) + + +def ACL2Record(acl): + """Convert an AccessControlList object into a text record""" + return "# file: %s\n%s" % (acl.get_indexpath(), str(acl.ACL)) + +def Record2EA(acl): + """Convert text record to an AccessControlList object""" + XXXX + + + + diff --git a/rdiff-backup/rdiff_backup/increment.py b/rdiff-backup/rdiff_backup/increment.py index 40cb8d8..100ee36 100644 --- a/rdiff-backup/rdiff_backup/increment.py +++ b/rdiff-backup/rdiff_backup/increment.py @@ -87,7 +87,7 @@ def makedir(mirrordir, incpref): """Make file indicating directory mirrordir has changed""" dirsign = get_inc(incpref, "dir") dirsign.touch() - rpath.copy_attribs(mirrordir, dirsign) + rpath.copy_attribs(mirrordir, dirsign) return dirsign def get_inc(rp, typestr, time = None): diff --git a/rdiff-backup/testing/commontest.py b/rdiff-backup/testing/commontest.py index 4cda300..f80da59 100644 --- a/rdiff-backup/testing/commontest.py +++ b/rdiff-backup/testing/commontest.py @@ -128,6 +128,7 @@ def InternalRestore(mirror_local, dest_local, mirror_dir, dest_dir, time): """ Main.force = 1 + Main.restore_root_set = 0 remote_schema = '%s' #_reset_connections() if not mirror_local: @@ -221,7 +222,7 @@ def CompareRecursive(src_rp, dest_rp, compare_hardlinks = 1, Log("%s: %s" % (dest_rorp.index, Hardlink.get_indicies(dest_rorp, None)), 3) return None - if compare_eas and not eas_acls.compare_rps(src_rorp, dest_rorp): + if compare_eas and not eas_acls.ea_compare_rps(src_rorp, dest_rorp): Log("Different EAs in files %s and %s" % (src_rorp.get_indexpath(), dest_rorp.get_indexpath()), 3) return None @@ -240,7 +241,7 @@ def CompareRecursive(src_rp, dest_rp, compare_hardlinks = 1, if dest_rorp.index[-1].endswith('gz'): return 1 # Don't compare .missing increments because they don't matter if dest_rorp.index[-1].endswith('.missing'): return 1 - if compare_eas and not eas_acls.compare_rps(src_rorp, dest_rorp): + if compare_eas and not eas_acls.ea_compare_rps(src_rorp, dest_rorp): Log("Different EAs in files %s and %s" % (src_rorp.get_indexpath(), dest_rorp.get_indexpath())) return None diff --git a/rdiff-backup/testing/test1/tmp/placeholder b/rdiff-backup/testing/test1/tmp/placeholder new file mode 100644 index 0000000..e69de29 -- cgit v1.2.1