From 14379534ed5faa379914b480f11e2775de8bba98 Mon Sep 17 00:00:00 2001 From: Chitoku Date: Fri, 19 Jun 2020 19:29:48 +0900 Subject: [PATCH 1/2] Remove trailing spaces --- xxh_xxh/xxh.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xxh_xxh/xxh.py b/xxh_xxh/xxh.py index c381bf5..d075ae7 100644 --- a/xxh_xxh/xxh.py +++ b/xxh_xxh/xxh.py @@ -261,7 +261,7 @@ def get_host_info(self): echo scp=`command -v scp` echo shell=`command -v {short_shell_name}` echo kernel=`uname -s` - echo arch=`uname -m` + echo arch=`uname -m` """.format( host_xxh_home=self.host_xxh_home, shell=self.shell, @@ -708,7 +708,7 @@ def packages_operations(): opt.ssh_login = url.username if opt.ssh_login: username = opt.ssh_login - + self.ssh_command = opt.ssh_command self.ssh_arguments = ['-o', 'StrictHostKeyChecking=accept-new'] if not self.verbose: From 965bb9c67a46c3f70a964e8c3d6f8e21a389cff5 Mon Sep 17 00:00:00 2001 From: Chitoku Date: Fri, 19 Jun 2020 19:30:45 +0900 Subject: [PATCH 2/2] Quote SSH arguments --- xxh_xxh/shell.py | 11 +++++++++-- xxh_xxh/xxh.py | 12 ++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/xxh_xxh/shell.py b/xxh_xxh/shell.py index f4941d9..adc91d7 100644 --- a/xxh_xxh/shell.py +++ b/xxh_xxh/shell.py @@ -14,9 +14,16 @@ def SC(cmd): [out, err] = proc.communicate() return (out, err, proc) -def A(args, q=0): +def A(args, q=0, i=0): if type(args) == list: - args = ' '.join([str(a) for a in args]) + if i == 1: + args = ' '.join([f"'{a}'" for a in args]) + elif i == 2: + args = ' '.join([f'"{a}"' for a in args]) + elif i == 3: + args = ' '.join([f'\\"{a}\\"' for a in args]) + else: + args = ' '.join([str(a) for a in args]) if q == 1: return f"'{args}'" elif q == 2: diff --git a/xxh_xxh/xxh.py b/xxh_xxh/xxh.py index d075ae7..0c6dcd8 100644 --- a/xxh_xxh/xxh.py +++ b/xxh_xxh/xxh.py @@ -284,7 +284,7 @@ def get_host_info(self): host_info_s=host_info_s.strip().replace('\n','\\n').replace('"','\\"').replace('$','\\$').replace('`','\\`'), ssh=self.ssh_command, ssh_v=('' if not self.ssh_arg_v else '-v'), - ssh_arguments=A(self.ssh_arguments), + ssh_arguments=A(self.ssh_arguments, 0, 2), host=host ) @@ -318,7 +318,7 @@ def get_host_info(self): sshpass=A(self.sshpass), ssh=A(self.ssh_command), ssh_arg_v=A(self.ssh_arg_v), - ssh_arguments=A(self.ssh_arguments), + ssh_arguments=A(self.ssh_arguments, 0, 2), host=A(host) )) r = o.strip() @@ -809,7 +809,7 @@ def packages_operations(): sshpass=A(self.sshpass), ssh=A(self.ssh_command), ssh_arg_v=A(self.ssh_arg_v), - ssh_arguments=A(self.ssh_arguments), + ssh_arguments=A(self.ssh_arguments, 0, 2), host=A(host) ) @@ -951,7 +951,7 @@ def packages_operations(): sshpass=A(self.sshpass), ssh=A(self.ssh_command), ssh_arg_v=('' if self.ssh_arg_v == [] else '-v'), - ssh_arguments=A(self.ssh_arguments), + ssh_arguments=A(self.ssh_arguments, 0, 3), arg_q=A(arg_q), progress=('' if self.quiet or not self.verbose else '--progress') ) @@ -982,7 +982,7 @@ def packages_operations(): sshpass=A(self.sshpass), scp_command=A(self.scp_command), ssh_arg_v=A(self.ssh_arg_v), - ssh_arguments=A(self.ssh_arguments), + ssh_arguments=A(self.ssh_arguments, 0, 1), arg_q=A(arg_q) ) @@ -1079,7 +1079,7 @@ def packages_operations(): sshpass=A(self.sshpass), ssh=A(self.ssh_command), ssh_arg_v=A(self.ssh_arg_v), - ssh_arguments=A(self.ssh_arguments), + ssh_arguments=A(self.ssh_arguments, 0, 1), host=A(host), entrypoint_command=entrypoint_command ))