/usr/share/backintime/common/sshMaxArg.py is in backintime-common 1.1.12-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2015 Germar Reitze
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import random
import string
import subprocess
import socket
import argparse
def random_id(size=6, chars=string.ascii_uppercase + string.digits):
return ''.join(random.choice(chars) for x in range(size))
def test_ssh_max_arg(host, mid = 1048320):
r = round(mid / 2)
while r > 0:
ssh = ['ssh', host]
ssh.extend(['printf', random_id(mid)])
try:
proc = subprocess.Popen(ssh,
stdout = subprocess.PIPE,
stderr = subprocess.PIPE,
universal_newlines = True)
out, err = proc.communicate()
except OSError as e:
if e.errno == 7:
reportTest(mid, 'python exception: %s' % e.strerror)
mid -= r
else:
raise
else:
l = len(out)
if l == mid:
reportTest(mid, 'can be longer')
mid += r
else:
reportTest(mid, 'is to long')
mid -= r
r = round(r / 2)
return mid + 6
def reportTest(mid, msg):
print('Check length %s:\t%s' % (mid, msg))
def reportResult(host, mid):
print('Maximum SSH argument length between %s and %s is %s'
% (socket.gethostname(), host, mid))
if __name__ == '__main__':
parser = argparse.ArgumentParser(description = 'Check maximal argument length on SSH connection',
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('HOST',
type = str,
nargs = '?',
default = 'localhost',
help = 'Remote host or user@host')
parser.add_argument('MID',
type = int,
nargs = '?',
default = 1048320,
help = 'Start checking with MID arg length')
args = parser.parse_args()
mid = test_ssh_max_arg(args.HOST, args.MID)
reportResult(args.HOST, mid)
|