diff options
author | ben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2002-07-25 06:34:48 +0000 |
---|---|---|
committer | ben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2002-07-25 06:34:48 +0000 |
commit | c1251cdd510402ff24572e187f089c5b87cb7e98 (patch) | |
tree | f60a41f4858fe20d7e4a6b4adf122487c2f4c4cf | |
parent | 57eaef4da22acb89668e7cc2de724bbe3636c20c (diff) | |
download | rdiff-backup-c1251cdd510402ff24572e187f089c5b87cb7e98.tar.gz |
Added error checking to middle of file reading, security fix for resuming
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@174 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
-rw-r--r-- | rdiff-backup/rdiff_backup/Security.py | 2 | ||||
-rw-r--r-- | rdiff-backup/rdiff_backup/iterfile.py | 11 | ||||
-rw-r--r-- | rdiff-backup/rdiff_backup/robust.py | 6 | ||||
-rw-r--r-- | rdiff-backup/src/Security.py | 2 | ||||
-rw-r--r-- | rdiff-backup/src/iterfile.py | 11 | ||||
-rw-r--r-- | rdiff-backup/src/robust.py | 6 |
6 files changed, 32 insertions, 6 deletions
diff --git a/rdiff-backup/rdiff_backup/Security.py b/rdiff-backup/rdiff_backup/Security.py index 49857ab..7f193aa 100644 --- a/rdiff-backup/rdiff_backup/Security.py +++ b/rdiff-backup/rdiff_backup/Security.py @@ -108,6 +108,7 @@ def set_allowed_requests(sec_level): allowed_requests.extend(["C.make_file_dict", "os.getuid", "os.listdir", + "Time.setcurtime_local", "Resume.ResumeCheck", "HLSourceStruct.split_initial_dsiter", "HLSourceStruct.get_diffs_and_finalize"]) @@ -127,7 +128,6 @@ def set_allowed_requests(sec_level): allowed_requests.extend(["SetConnections.init_connection_remote", "Log.setverbosity", "Log.setterm_verbosity", - "Time.setcurtime_local", "Time.setprevtime_local", "FilenameMapping.set_init_quote_vals_local", "Globals.postset_regexp_local", diff --git a/rdiff-backup/rdiff_backup/iterfile.py b/rdiff-backup/rdiff_backup/iterfile.py index c90229e..5549ca8 100644 --- a/rdiff-backup/rdiff_backup/iterfile.py +++ b/rdiff-backup/rdiff_backup/iterfile.py @@ -190,12 +190,20 @@ class FileWrappingIter: def addfromfile(self): """Read a chunk from the current file and return it""" - buf = self.currently_in_file.read(Globals.blocksize) + # Check file read for errors, buf = "" if find one + buf = Robust.check_common_error(self.read_error_handler, + self.currently_in_file.read, + [Globals.blocksize]) if not buf: assert not self.currently_in_file.close() self.currently_in_file = None return C.long2str(long(len(buf))) + buf + def read_error_handler(self, exc, blocksize): + """Log error when reading from file""" + Log("Error '%s' reading from fileobj, truncating" % (str(exc),), 2) + return "" + def _l2s_old(self, l): """Convert long int to string of 7 characters""" s = "" @@ -237,3 +245,4 @@ class BufferedRead: def close(self): return self.file.close() from log import * +from robust import * diff --git a/rdiff-backup/rdiff_backup/robust.py b/rdiff-backup/rdiff_backup/robust.py index 5e2ee96..1973cc3 100644 --- a/rdiff-backup/rdiff_backup/robust.py +++ b/rdiff-backup/rdiff_backup/robust.py @@ -575,7 +575,10 @@ class Resume: mirror = None last_index = cls.sym_to_index(increment_sym) if checkpoint_rp: - ITR, finalizer = cls.unpickle_checkpoint(checkpoint_rp) + result = cls.unpickle_checkpoint(checkpoint_rp) + sys.stderr.write("#############" + str(result) + "\n") + #ITR, finalizer = cls.unpickle_checkpoint(checkpoint_rp) + ITR, finalizer = result elif mirror_sym: mirror = 1 last_index = cls.sym_to_index(mirror_sym) @@ -609,6 +612,7 @@ class Resume: try: result = cPickle.loads(data) except cPickle.UnpicklingError: raise ResumeException("Bad pickle at %s" % (checkpoint_rp.path,)) + return result def ResumeCheck(cls): """Return relevant ResumeSessionInfo if there's one we should resume diff --git a/rdiff-backup/src/Security.py b/rdiff-backup/src/Security.py index 49857ab..7f193aa 100644 --- a/rdiff-backup/src/Security.py +++ b/rdiff-backup/src/Security.py @@ -108,6 +108,7 @@ def set_allowed_requests(sec_level): allowed_requests.extend(["C.make_file_dict", "os.getuid", "os.listdir", + "Time.setcurtime_local", "Resume.ResumeCheck", "HLSourceStruct.split_initial_dsiter", "HLSourceStruct.get_diffs_and_finalize"]) @@ -127,7 +128,6 @@ def set_allowed_requests(sec_level): allowed_requests.extend(["SetConnections.init_connection_remote", "Log.setverbosity", "Log.setterm_verbosity", - "Time.setcurtime_local", "Time.setprevtime_local", "FilenameMapping.set_init_quote_vals_local", "Globals.postset_regexp_local", diff --git a/rdiff-backup/src/iterfile.py b/rdiff-backup/src/iterfile.py index c90229e..5549ca8 100644 --- a/rdiff-backup/src/iterfile.py +++ b/rdiff-backup/src/iterfile.py @@ -190,12 +190,20 @@ class FileWrappingIter: def addfromfile(self): """Read a chunk from the current file and return it""" - buf = self.currently_in_file.read(Globals.blocksize) + # Check file read for errors, buf = "" if find one + buf = Robust.check_common_error(self.read_error_handler, + self.currently_in_file.read, + [Globals.blocksize]) if not buf: assert not self.currently_in_file.close() self.currently_in_file = None return C.long2str(long(len(buf))) + buf + def read_error_handler(self, exc, blocksize): + """Log error when reading from file""" + Log("Error '%s' reading from fileobj, truncating" % (str(exc),), 2) + return "" + def _l2s_old(self, l): """Convert long int to string of 7 characters""" s = "" @@ -237,3 +245,4 @@ class BufferedRead: def close(self): return self.file.close() from log import * +from robust import * diff --git a/rdiff-backup/src/robust.py b/rdiff-backup/src/robust.py index 5e2ee96..1973cc3 100644 --- a/rdiff-backup/src/robust.py +++ b/rdiff-backup/src/robust.py @@ -575,7 +575,10 @@ class Resume: mirror = None last_index = cls.sym_to_index(increment_sym) if checkpoint_rp: - ITR, finalizer = cls.unpickle_checkpoint(checkpoint_rp) + result = cls.unpickle_checkpoint(checkpoint_rp) + sys.stderr.write("#############" + str(result) + "\n") + #ITR, finalizer = cls.unpickle_checkpoint(checkpoint_rp) + ITR, finalizer = result elif mirror_sym: mirror = 1 last_index = cls.sym_to_index(mirror_sym) @@ -609,6 +612,7 @@ class Resume: try: result = cPickle.loads(data) except cPickle.UnpicklingError: raise ResumeException("Bad pickle at %s" % (checkpoint_rp.path,)) + return result def ResumeCheck(cls): """Return relevant ResumeSessionInfo if there's one we should resume |