X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=src%2Fnepi%2Futil%2Fsshfuncs.py;h=81bf5f9b5ddba91ca99e8f61dc740b34a9b2e0ef;hb=f4a5a9a345818610739e9e5841b9da5b1a062f5d;hp=458af49581af85a6b87969c3cf00f6bea0871742;hpb=4343255121c4a2e8f3fe0b6377ec9219de75eab1;p=nepi.git diff --git a/src/nepi/util/sshfuncs.py b/src/nepi/util/sshfuncs.py index 458af495..81bf5f9b 100644 --- a/src/nepi/util/sshfuncs.py +++ b/src/nepi/util/sshfuncs.py @@ -206,78 +206,6 @@ def eintr_retry(func): return func(*p, **kw) return rv -def socat(local_socket_name, remote_socket_name, - host, user, - port = None, - agent = True, - sudo = False, - identity = None, - server_key = None, - env = None, - tty = False, - connect_timeout = 30, - retry = 3, - strict_host_checking = True): - """ - Executes a remote command, returns ((stdout,stderr),process) - """ - - tmp_known_hosts = None - hostip = gethostbyname(host) - - - args = ["socat"] - args.append("UNIX-LISTEN:%s,unlink-early,fork" % local_socket_name) - - ssh_args = ['ssh', '-C', - # Don't bother with localhost. Makes test easier - '-o', 'NoHostAuthenticationForLocalhost=yes', - '-o', 'ConnectTimeout=%d' % (int(connect_timeout),), - '-o', 'ConnectionAttempts=3', - '-o', 'ServerAliveInterval=30', - '-o', 'TCPKeepAlive=yes', - '-l', user, hostip or host] - - if not strict_host_checking: - # Do not check for Host key. Unsafe. - ssh_args.extend(['-o', 'StrictHostKeyChecking=no']) - - if agent: - ssh_args.append('-A') - - if port: - ssh_args.append('-p%d' % port) - - if identity: - ssh_args.extend(('-i', identity)) - - if tty: - ssh_args.append('-t') - ssh_args.append('-t') - - if server_key: - # Create a temporary server key file - tmp_known_hosts = make_server_key_args(server_key, host, port) - ssh_args.extend(['-o', 'UserKnownHostsFile=%s' % (tmp_known_hosts.name,)]) - - ssh_cmd = " ".join(ssh_args) - - exec_cmd = "EXEC:'%s socat STDIO UNIX-CONNECT\:%s'" % (ssh_cmd, - remote_socket_name) - - args.append(exec_cmd) - - log_msg = " socat - host %s - command %s " % (host, " ".join(args)) - - return _retry_rexec(args, log_msg, - stdout = None, - stdin = None, - stderr = None, - env = env, - retry = retry, - tmp_known_hosts = tmp_known_hosts, - blocking = False) - def rexec(command, host, user, port = None, agent = True,