aboutsummaryrefslogtreecommitdiffstats
path: root/libbe/ui
diff options
context:
space:
mode:
Diffstat (limited to 'libbe/ui')
-rwxr-xr-xlibbe/ui/command_line.py23
-rw-r--r--libbe/ui/util/cmdutil.py14
2 files changed, 6 insertions, 31 deletions
diff --git a/libbe/ui/command_line.py b/libbe/ui/command_line.py
index 84f9450..0aa34f7 100755
--- a/libbe/ui/command_line.py
+++ b/libbe/ui/command_line.py
@@ -264,29 +264,18 @@ def main():
print e
return 1
Class = getattr(module, command_name.capitalize())
- command = Class()
- command.ui = self
+ def gucs():
+ return libbe.storage.get_storage(options['repo'])
+ command = Class(get_unconnected_storage=gucs, ui=ui)
parser = CmdOptionParser(command)
- storage = None
- bugdir = None
- if command.requires_bugdir == True:
- assert command.requires_unconnected_storage == False
- storage = libbe.storage.get_storage(options['repo'])
- storage.connect()
- bugdir = libbe.bugdir.BugDir(storage, from_storage=True)
- elif command.requires_storage == True \
- or command.requires_unconnected_storage == True:
- storage = libbe.storage.get_storage(options['repo'])
- if command.requires_unconnected_storage == False:
- storage.connect()
try:
options,args = parser.parse_args(args[1:])
- command.run(storage, bugdir, options, args)
+ command.run(options, args)
except CallbackExit:
- if storage != None: storage.disconnect()
+ command.cleanup()
return 0
except libbe.command.UserError, e:
- if storage != None: storage.disconnect()
+ command.cleanup()
print 'ERROR:\n', e
return 1
if storage != None: storage.disconnect()
diff --git a/libbe/ui/util/cmdutil.py b/libbe/ui/util/cmdutil.py
index 86ff9fc..f2eb5b9 100644
--- a/libbe/ui/util/cmdutil.py
+++ b/libbe/ui/util/cmdutil.py
@@ -59,20 +59,6 @@ def execute(cmd, args,
def restrict_file_access(bugdir, path):
- """
- Check that the file at path is inside bugdir.root. This is
- important if you allow other users to execute becommands with your
- username (e.g. if you're running be-handle-mail through your
- ~/.procmailrc). If this check wasn't made, a user could e.g.
- run
- be commit -b ~/.ssh/id_rsa "Hack to expose ssh key"
- which would expose your ssh key to anyone who could read the VCS
- log.
- """
- in_root = bugdir.vcs.path_in_root(path, bugdir.root)
- if in_root == False:
- raise UserError('file access restricted!\n %s not in %s'
- % (path, bugdir.root))
def parse_id(id):
"""