mirror of
https://github.com/valitydev/salt.git
synced 2024-11-09 01:36:48 +00:00
Fix #12484 by running restorecon on .ssh and authorized_keys file if they are created by ssh_auth.present state
This commit is contained in:
parent
8fec19b07f
commit
add29d8c2a
@ -13,6 +13,7 @@ import re
|
||||
import hashlib
|
||||
import binascii
|
||||
import logging
|
||||
import subprocess
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
@ -516,6 +517,11 @@ def set_auth_key(
|
||||
if os.geteuid() == 0:
|
||||
os.chown(dpath, uinfo['uid'], uinfo['gid'])
|
||||
os.chmod(dpath, 448)
|
||||
# If SELINUX is available run a restorecon on the file
|
||||
rcon = salt.utils.which('restorecon')
|
||||
if rcon:
|
||||
cmd = [rcon, dpath]
|
||||
subprocess.call(cmd)
|
||||
|
||||
if not os.path.isfile(fconfig):
|
||||
new_file = True
|
||||
@ -539,6 +545,11 @@ def set_auth_key(
|
||||
if os.geteuid() == 0:
|
||||
os.chown(fconfig, uinfo['uid'], uinfo['gid'])
|
||||
os.chmod(fconfig, 384)
|
||||
# If SELINUX is available run a restorecon on the file
|
||||
rcon = salt.utils.which('restorecon')
|
||||
if rcon:
|
||||
cmd = [rcon, fconfig]
|
||||
subprocess.call(cmd)
|
||||
return 'new'
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user