]> arthur.barton.de Git - bup.git/commitdiff
Add BUP_DIR to the subprocess environment during set-dir on the server.
authorGabriel Filion <lelutin@gmail.com>
Sat, 28 Jul 2012 03:02:10 +0000 (23:02 -0400)
committerRob Browning <rlb@defaultvalue.org>
Fri, 17 Aug 2012 18:42:59 +0000 (13:42 -0500)
In the normal flow of a remote backup, the client indicates to the
server end where it wants to save data (e.g. where the bup repository
is) by issuing a "set-dir path" command.

This command on the server end records the path in a global variable.
But it doesn't place it in the environment. This causes any subprocess
forked on the server end to be ignorant about the location of the
bup repository and causes errors such as this one:

Traceback (most recent call last):
  File "/usr/lib/bup/cmd/bup-midx", line 231, in <module>
    git.check_repo_or_die()
  File "/usr/lib/bup/bup/git.py", line 851, in check_repo_or_die
    init_repo()
  File "/usr/lib/bup/bup/git.py", line 828, in init_repo
    _git_wait('git init', p)
  File "/usr/lib/bup/bup/git.py", line 887, in _git_wait
    raise GitError('%s returned %d' % (cmd, rv))
bup.git.GitError: git init returned 1
['/usr/bin/bup', 'midx', '--auto', '--dir',
'/backup/test/objects/pack']: returned 1

Signed-off-by: Gabriel Filion <lelutin@gmail.com>
Reviewed-by: Rob Browning <rlb@defaultvalue.org>
cmd/server-cmd.py

index acd61191804db7f32ba4840cb05b6f12f5b3c263..a9d742ca7c6f6c81077f25f39a1fbcdb68bdeb54 100755 (executable)
@@ -28,6 +28,9 @@ def init_dir(conn, arg):
 
 def set_dir(conn, arg):
     git.check_repo_or_die(arg)
+    # OK. we now know the path is a proper repository. Record this path in the
+    # environment so that subprocesses inherit it and know where to operate.
+    os.environ['BUP_DIR'] = arg
     debug1('bup server: bupdir is %r\n' % git.repodir)
     _set_mode()
     conn.ok()