summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-01-29 21:13:07 +0200
committerLars Wirzenius <liw@liw.fi>2017-01-29 21:13:07 +0200
commiteb91bebe5273deaa79df33777519aa2e0d3a2bf4 (patch)
tree447f78f5d989b1f0386e126ea94f3271a013d84a
parent6726acbbc065687a3a8d9d5c873cad8c9e3c072b (diff)
downloadobnam-eb91bebe5273deaa79df33777519aa2e0d3a2bf4.tar.gz
Forbid restoring without absolute paths
-rw-r--r--obnamlib/plugins/restore_plugin.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/obnamlib/plugins/restore_plugin.py b/obnamlib/plugins/restore_plugin.py
index b7944946..bf539b5f 100644
--- a/obnamlib/plugins/restore_plugin.py
+++ b/obnamlib/plugins/restore_plugin.py
@@ -33,6 +33,12 @@ class NoToError(obnamlib.ObnamError):
msg = 'The restore command wants a target set with --to'
+class RelativePathError(obnamlib.ObnamError):
+
+ msg = ("Restore of {filename} requested, but it is not an absolute path "
+ "(doesn't start with /)")
+
+
class RestoreErrors(obnamlib.ObnamError):
msg = '''There were errors when restoring
@@ -137,6 +143,10 @@ class RestorePlugin(obnamlib.ObnamPlugin):
logging.debug('restoring to %s', self.app.settings['to'])
logging.debug('restoring what: %s', repr(args))
+ if args:
+ for arg in args:
+ if not os.path.isabs(arg):
+ raise RelativePathError(filename=arg)
if not args:
logging.debug('no args given, so restoring everything')
args = ['/']