summaryrefslogtreecommitdiff
path: root/contrib/bzr_ssh_path_limiter
blob: 8bf2121bae3030adc73ea4593511eb8d9100d501 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/python

# Inspired by Rusty and the hg_ssh script:
# http://www.selenic.com/repo/index.cgi/hg-stable/file/tip/contrib/hg-ssh
#
# Use in ~/.ssh/authorized_keys like:
#
# command="bzr_ssh_path_limiter /home/foo/code" ssh-rsa ...

import os, sys

orig_cmd = os.getenv('SSH_ORIGINAL_COMMAND', '?')
if orig_cmd == 'bzr serve --inet --directory=/ --allow-writes':
    os.execlp('bzr', 'bzr', '--no-plugins', 'serve', '--inet', '--directory=' + sys.argv[1], '--allow-writes')

sys.stderr.write('Illegal command: %s\n' % (orig_cmd,))
sys.exit(1)