Merge pull request #33933 from folti/develop

ssh: keep original permissions, when hashing known_hosts
This commit is contained in:
Mike Place 2016-06-13 09:56:29 -07:00 committed by GitHub
commit 94a78fe7d7

View File

@ -1175,8 +1175,10 @@ def hash_known_hosts(user=None, config=None):
if not os.path.isfile(full):
return {'status': 'error',
'error': 'Known hosts file {0} does not exist'.format(full)}
origmode = os.stat(full).st_mode
cmd = ['ssh-keygen', '-H', '-f', full]
cmd_result = __salt__['cmd.run'](cmd, python_shell=False)
os.stat(full, origmode)
# ssh-keygen creates a new file, thus a chown is required.
if os.geteuid() == 0 and user:
uinfo = __salt__['user.info'](user)