|
|
@ -118,14 +118,22 @@ class Connection(object):
|
|
|
|
|
|
|
|
|
|
|
|
def not_in_host_file(self, host):
|
|
|
|
def not_in_host_file(self, host):
|
|
|
|
if 'USER' in os.environ:
|
|
|
|
if 'USER' in os.environ:
|
|
|
|
host_file = os.path.expandvars("~${USER}/.ssh/known_hosts")
|
|
|
|
user_host_file = os.path.expandvars("~${USER}/.ssh/known_hosts")
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
host_file = "~/.ssh/known_hosts"
|
|
|
|
user_host_file = "~/.ssh/known_hosts"
|
|
|
|
host_file = os.path.expanduser(host_file)
|
|
|
|
user_host_file = os.path.expanduser(user_host_file)
|
|
|
|
if not os.path.exists(host_file):
|
|
|
|
|
|
|
|
print "previous known host file not found"
|
|
|
|
host_file_list = []
|
|
|
|
return True
|
|
|
|
host_file_list.append(user_host_file)
|
|
|
|
host_fh = open(host_file)
|
|
|
|
host_file_list.append("/etc/ssh/ssh_known_hosts")
|
|
|
|
|
|
|
|
host_file_list.append("/etc/ssh/ssh_known_hosts2")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hfiles_not_found = 0
|
|
|
|
|
|
|
|
for hf in host_file_list:
|
|
|
|
|
|
|
|
if not os.path.exists(hf):
|
|
|
|
|
|
|
|
hfiles_not_found += 1
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
host_fh = open(hf)
|
|
|
|
data = host_fh.read()
|
|
|
|
data = host_fh.read()
|
|
|
|
host_fh.close()
|
|
|
|
host_fh.close()
|
|
|
|
for line in data.split("\n"):
|
|
|
|
for line in data.split("\n"):
|
|
|
@ -147,6 +155,9 @@ class Connection(object):
|
|
|
|
# standard host file entry
|
|
|
|
# standard host file entry
|
|
|
|
if host in tokens[0]:
|
|
|
|
if host in tokens[0]:
|
|
|
|
return False
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (hfiles_not_found == len(host_file_list)):
|
|
|
|
|
|
|
|
print "previous known host file not found"
|
|
|
|
return True
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
def exec_command(self, cmd, tmp_path, sudo_user=None, sudoable=False, executable='/bin/sh', in_data=None, su_user=None, su=False):
|
|
|
|
def exec_command(self, cmd, tmp_path, sudo_user=None, sudoable=False, executable='/bin/sh', in_data=None, su_user=None, su=False):
|
|
|
|