|
@@ -4,18 +4,23 @@ import logging
|
|
|
import os
|
|
|
import select
|
|
|
import shlex
|
|
|
-from subprocess import Popen, PIPE
|
|
|
import sys
|
|
|
import tempfile
|
|
|
+import textwrap
|
|
|
+from subprocess import Popen, PIPE
|
|
|
|
|
|
from . import __version__
|
|
|
|
|
|
from .helpers import Error, IntegrityError, sysinfo
|
|
|
from .helpers import replace_placeholders
|
|
|
+from .helpers import bin_to_hex
|
|
|
from .repository import Repository
|
|
|
+from .logger import create_logger
|
|
|
|
|
|
import msgpack
|
|
|
|
|
|
+logger = create_logger(__name__)
|
|
|
+
|
|
|
RPC_PROTOCOL_VERSION = 2
|
|
|
|
|
|
BUFSIZE = 10 * 1024 * 1024
|
|
@@ -44,7 +49,16 @@ class UnexpectedRPCDataFormatFromClient(Error):
|
|
|
|
|
|
|
|
|
class UnexpectedRPCDataFormatFromServer(Error):
|
|
|
- """Got unexpected RPC data format from server."""
|
|
|
+ """Got unexpected RPC data format from server:\n{}"""
|
|
|
+
|
|
|
+ def __init__(self, data):
|
|
|
+ try:
|
|
|
+ data = data.decode()[:128]
|
|
|
+ except UnicodeDecodeError:
|
|
|
+ data = data[:128]
|
|
|
+ data = ['%02X' % byte for byte in data]
|
|
|
+ data = textwrap.fill(' '.join(data), 16 * 3)
|
|
|
+ super().__init__(data)
|
|
|
|
|
|
|
|
|
class RepositoryServer: # pragma: no cover
|
|
@@ -185,6 +199,7 @@ class RemoteRepository:
|
|
|
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()
|
|
|
self.stdout_fd = self.p.stdout.fileno()
|
|
@@ -346,7 +361,7 @@ This problem will go away as soon as the server has been upgraded to 1.0.7+.
|
|
|
self.unpacker.feed(data)
|
|
|
for unpacked in self.unpacker:
|
|
|
if not (isinstance(unpacked, tuple) and len(unpacked) == 4):
|
|
|
- raise UnexpectedRPCDataFormatFromServer()
|
|
|
+ raise UnexpectedRPCDataFormatFromServer(data)
|
|
|
type, msgid, error, res = unpacked
|
|
|
if msgid in self.ignore_responses:
|
|
|
self.ignore_responses.remove(msgid)
|