Commit b37601c3 authored by bescoto's avatar bescoto

Listing a read-only repository should work now


git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup@756 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
parent 4503486b
......@@ -6,6 +6,11 @@ Fix a traceback due to an off-by-1 error in "--remove-older-than nB".
Fix a security violation when restoring from a remote repository.
(Patch from Charles Duffy.)
--list-at-time, --list-increments, and --list-increment-sizes should
now work from a read-only repository. (Bug reported by Wolfgang
Dautermann.)
New in v1.0.4 (2006/01/15)
--------------------------
......
......@@ -683,7 +683,7 @@ def restore_set_root(rpin):
def ListIncrements(rp):
"""Print out a summary of the increments and their times"""
rp = require_root_set(rp)
rp = require_root_set(rp, readonly = 1)
restore_check_backup_dir(restore_root)
mirror_rp = restore_root.new_index(restore_index)
inc_rpath = Globals.rbdir.append_path('increments', restore_index)
......@@ -693,7 +693,7 @@ def ListIncrements(rp):
print manage.describe_incs_parsable(incs, mirror_time, mirror_rp)
else: print manage.describe_incs_human(incs, mirror_time, mirror_rp)
def require_root_set(rp):
def require_root_set(rp, readonly = None):
"""Make sure rp is or is in a valid rdiff-backup dest directory.
Also initializes fs_abilities and quoting and return quoted rp if
......@@ -703,11 +703,11 @@ def require_root_set(rp):
if not restore_set_root(rp):
Log.FatalError(("Bad directory %s.\n" % (rp.path,)) +
"It doesn't appear to be an rdiff-backup destination dir")
single_set_fs_globals(Globals.rbdir)
single_set_fs_globals(Globals.rbdir, readonly)
if Globals.chars_to_quote: return restore_init_quoting(rp)
else: return rp
def single_set_fs_globals(rbdir):
def single_set_fs_globals(rbdir, readonly = None):
"""Use fs_abilities to set globals that depend on filesystem.
This is appropriate for listing increments, or any other operation
......@@ -724,8 +724,10 @@ def single_set_fs_globals(rbdir):
SetConnections.UpdateGlobal(write_attr, 1)
rbdir.conn.Globals.set_local(conn_attr, 1)
fsa = rbdir.conn.fs_abilities.get_fsabilities_readwrite('archive',
rbdir, 1, Globals.chars_to_quote)
if readonly: fsa = rbdir.conn.fs_abilities.get_fsabilities_readonly(
'archive', rbdir, Globals.chars_to_quote)
else: fsa = rbdir.conn.fs_abilities.get_fsabilities_readwrite(
'archive', rbdir, 1, Globals.chars_to_quote)
Log(str(fsa), 4)
update_triple(fsa.eas, ('eas_active', 'eas_write', 'eas_conn'))
......@@ -806,7 +808,7 @@ def rot_require_rbdir_base(rootrp):
def ListChangedSince(rp):
"""List all the files under rp that have changed since restoretime"""
rp = require_root_set(rp)
rp = require_root_set(rp, readonly = 1)
try: rest_time = Time.genstrtotime(restore_timestr)
except Time.TimeException, exc: Log.FatalError(str(exc))
mirror_rp = restore_root.new_index(restore_index)
......@@ -818,7 +820,7 @@ def ListChangedSince(rp):
def ListAtTime(rp):
"""List files in archive under rp that are present at restoretime"""
rp = require_root_set(rp)
rp = require_root_set(rp, readonly = 1)
try: rest_time = Time.genstrtotime(restore_timestr)
except Time.TimeException, exc: Log.FatalError(str(exc))
mirror_rp = restore_root.new_index(restore_index)
......
......@@ -100,14 +100,14 @@ class FSAbilities:
s.append(s[0])
return '\n'.join(s)
def init_readonly(self, rp):
def init_readonly(self, rp, override_chars_to_quote = None):
"""Set variables using fs tested at RPath rp. Run locally.
This method does not write to the file system at all, and
should be run on the file system when the file system will
only need to be read.
Only self.acls and self.eas are set.
Only self.acls, self.eas, and self.chars_to_quote are set.
"""
assert rp.conn is Globals.local_connection
......@@ -117,6 +117,13 @@ class FSAbilities:
self.set_acls(rp)
self.set_resource_fork_readonly(rp)
self.set_carbonfile()
if override_chars_to_quote is None:
ctq_rp = rp.append('chars_to_quote')
if ctq_rp.isreg(): self.chars_to_quote = ctq_rp.get_data()
else: self.chars_to_quote = "" # default is no quoting
else: self.chars_to_quote = override_chars_to_quote
return self
def init_readwrite(self, rbdir, use_ctq_file = 1,
......@@ -395,13 +402,13 @@ rdiff-backup-data/chars_to_quote.
else: self.high_perms = 1
tmp_rp.delete()
def get_fsabilities_readonly(desc_string, rp):
def get_fsabilities_readonly(desc_string, rb, ctq = None):
"""Return an FSAbilities object with given description_string
Will be initialized read_only with given RPath rp.
"""
return FSAbilities(desc_string).init_readonly(rp)
return FSAbilities(desc_string).init_readonly(rb, ctq)
def get_fsabilities_readwrite(desc_string, rb, use_ctq_file = 1, ctq = None):
"""Like above but initialize read/write and pass other arguments"""
......
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