|  | @@ -16,6 +16,7 @@ from .helpers import Error, IntegrityError, sysinfo
 | 
	
		
			
				|  |  |  from .helpers import replace_placeholders
 | 
	
		
			
				|  |  |  from .helpers import BUFSIZE
 | 
	
		
			
				|  |  |  from .helpers import get_limited_unpacker
 | 
	
		
			
				|  |  | +from .helpers import prepare_subprocess_env
 | 
	
		
			
				|  |  |  from .repository import Repository
 | 
	
		
			
				|  |  |  from .logger import create_logger
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -209,15 +210,12 @@ class RemoteRepository:
 | 
	
		
			
				|  |  |          self.unpacker = get_limited_unpacker('client')
 | 
	
		
			
				|  |  |          self.p = None
 | 
	
		
			
				|  |  |          testing = location.host == '__testsuite__'
 | 
	
		
			
				|  |  | +        # when testing, we invoke and talk to a borg process directly (no ssh).
 | 
	
		
			
				|  |  | +        # when not testing, we invoke the system-installed ssh binary to talk to a remote borg.
 | 
	
		
			
				|  |  | +        env = prepare_subprocess_env(system=not testing)
 | 
	
		
			
				|  |  |          borg_cmd = self.borg_cmd(args, testing)
 | 
	
		
			
				|  |  | -        env = dict(os.environ)
 | 
	
		
			
				|  |  |          if not testing:
 | 
	
		
			
				|  |  |              borg_cmd = self.ssh_cmd(location) + borg_cmd
 | 
	
		
			
				|  |  | -            # pyinstaller binary adds LD_LIBRARY_PATH=/tmp/_ME... but we do not want
 | 
	
		
			
				|  |  | -            # that the system's ssh binary picks up (non-matching) libraries from there
 | 
	
		
			
				|  |  | -            env.pop('LD_LIBRARY_PATH', None)
 | 
	
		
			
				|  |  | -        env.pop('BORG_PASSPHRASE', None)  # security: do not give secrets to subprocess
 | 
	
		
			
				|  |  | -        env['BORG_VERSION'] = __version__
 | 
	
		
			
				|  |  |          logger.debug('SSH command line: %s', borg_cmd)
 | 
	
		
			
				|  |  |          self.p = Popen(borg_cmd, bufsize=0, stdin=PIPE, stdout=PIPE, stderr=PIPE, env=env)
 | 
	
		
			
				|  |  |          self.stdin_fd = self.p.stdin.fileno()
 |