Commit 8a116d48 authored by bescoto's avatar bescoto

Fix for unreadable directories


git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup@410 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
parent 68aefb63
...@@ -149,7 +149,7 @@ class DestinationStruct: ...@@ -149,7 +149,7 @@ class DestinationStruct:
dest_iter = cls.get_dest_select(baserp, for_increment) dest_iter = cls.get_dest_select(baserp, for_increment)
collated = rorpiter.Collate2Iters(source_iter, dest_iter) collated = rorpiter.Collate2Iters(source_iter, dest_iter)
cls.CCPP = CacheCollatedPostProcess( cls.CCPP = CacheCollatedPostProcess(
collated, Globals.pipeline_max_length*4) collated, Globals.pipeline_max_length*4, baserp)
# pipeline len adds some leeway over just*3 (to and from and back) # pipeline len adds some leeway over just*3 (to and from and back)
def get_sigs(cls, dest_base_rpath): def get_sigs(cls, dest_base_rpath):
...@@ -232,7 +232,7 @@ static.MakeClass(DestinationStruct) ...@@ -232,7 +232,7 @@ static.MakeClass(DestinationStruct)
class CacheCollatedPostProcess: class CacheCollatedPostProcess:
"""Cache a collated iter of (source_rorp, dest_rp) pairs """Cache a collated iter of (source_rorp, dest_rorp) pairs
This is necessary for two reasons: This is necessary for two reasons:
...@@ -254,10 +254,12 @@ class CacheCollatedPostProcess: ...@@ -254,10 +254,12 @@ class CacheCollatedPostProcess:
metadata for it. metadata for it.
""" """
def __init__(self, collated_iter, cache_size): def __init__(self, collated_iter, cache_size, dest_root_rp):
"""Initialize new CCWP.""" """Initialize new CCWP."""
self.iter = collated_iter # generates (source_rorp, dest_rorp) pairs self.iter = collated_iter # generates (source_rorp, dest_rorp) pairs
self.cache_size = cache_size self.cache_size = cache_size
self.dest_root_rp = dest_root_rp
self.statfileobj = statistics.init_statfileobj() self.statfileobj = statistics.init_statfileobj()
if Globals.file_statistics: statistics.FileStats.init() if Globals.file_statistics: statistics.FileStats.init()
metadata.MetadataFile.open_file() metadata.MetadataFile.open_file()
...@@ -302,6 +304,10 @@ class CacheCollatedPostProcess: ...@@ -302,6 +304,10 @@ class CacheCollatedPostProcess:
""" """
if source_rorp: Hardlink.add_rorp(source_rorp, source = 1) if source_rorp: Hardlink.add_rorp(source_rorp, source = 1)
if dest_rorp: Hardlink.add_rorp(dest_rorp, source = 0) if dest_rorp: Hardlink.add_rorp(dest_rorp, source = 0)
if (dest_rorp and dest_rorp.isdir() and Globals.process_uid != 0 and
dest_rorp.getperms() % 01000 < 0700):
dest_rp = self.dest_root_rp.new_index(dest_rorp.index)
dest_rp.chmod(0700 | dest_rorp.getperms())
def shorten_cache(self): def shorten_cache(self):
"""Remove one element from cache, possibly adding it to metadata""" """Remove one element from cache, possibly adding it to metadata"""
...@@ -346,6 +352,13 @@ class CacheCollatedPostProcess: ...@@ -346,6 +352,13 @@ class CacheCollatedPostProcess:
if Globals.file_statistics: if Globals.file_statistics:
statistics.FileStats.update(source_rorp, dest_rorp, changed, inc) statistics.FileStats.update(source_rorp, dest_rorp, changed, inc)
# Update permissions of unreadable directory
if (source_rorp and source_rorp.isdir() and Globals.process_uid != 0
and success and source_rorp.getperms() % 01000 < 0700):
dest_rp = self.dest_root_rp.new_index(source_rorp.index)
assert dest_rp.isdir(), dest_rp
dest_rp.chmod(source_rorp.getperms())
def in_cache(self, index): def in_cache(self, index):
"""Return true if given index is cached""" """Return true if given index is cached"""
return self.cache_dict.has_key(index) return self.cache_dict.has_key(index)
...@@ -596,3 +609,4 @@ class IncrementITRB(PatchITRB): ...@@ -596,3 +609,4 @@ class IncrementITRB(PatchITRB):
self.CCPP.set_inc(index, inc) self.CCPP.set_inc(index, inc)
self.CCPP.flag_success(index) self.CCPP.flag_success(index)
...@@ -11,7 +11,7 @@ if you aren't me, check out the 'user' global variable. ...@@ -11,7 +11,7 @@ if you aren't me, check out the 'user' global variable.
Globals.set('change_source_perms', None) Globals.set('change_source_perms', None)
Globals.counter = 0 Globals.counter = 0
verbosity = 3 verbosity = 6
log.Log.setverbosity(verbosity) log.Log.setverbosity(verbosity)
user = 'ben' # Non-root user to su to user = 'ben' # Non-root user to su to
assert os.getuid() == 0, "Run this test as root!" assert os.getuid() == 0, "Run this test as root!"
...@@ -46,6 +46,11 @@ class HalfRoot(unittest.TestCase): ...@@ -46,6 +46,11 @@ class HalfRoot(unittest.TestCase):
rp1_2 = rp1.append('to be deleted') rp1_2 = rp1.append('to be deleted')
rp1_2.write_string('aosetuhaosetnuhontu') rp1_2.write_string('aosetuhaosetnuhontu')
rp1_2.chmod(0) rp1_2.chmod(0)
rp1_3 = rp1.append('unreadable_dir')
rp1_3.mkdir()
rp1_3_1 = rp1_3.append('file inside')
rp1_3_1.write_string('blah')
rp1_3.chmod(0)
rp2 = rpath.RPath(Globals.local_connection, "testfiles/root_half2") rp2 = rpath.RPath(Globals.local_connection, "testfiles/root_half2")
if rp2.lstat(): Myrm(rp2.path) if rp2.lstat(): Myrm(rp2.path)
...@@ -53,6 +58,9 @@ class HalfRoot(unittest.TestCase): ...@@ -53,6 +58,9 @@ class HalfRoot(unittest.TestCase):
rp2_1 = rp2.append('foo') rp2_1 = rp2.append('foo')
rp2_1.write_string('goodbye') rp2_1.write_string('goodbye')
rp2_1.chmod(0) rp2_1.chmod(0)
rp2_3 = rp2.append('unreadable_dir')
rp2_3.mkdir()
rp2_3.chmod(0)
return rp1, rp2 return rp1, rp2
def test_backup(self): def test_backup(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment