mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #30586 from abednarik/fix_comment_line_perms
Fix comment_line permissions.
This commit is contained in:
commit
643c9c9616
1 changed files with 9 additions and 1 deletions
|
@ -1097,7 +1097,7 @@ def comment_line(path,
|
|||
path = os.path.realpath(os.path.expanduser(path))
|
||||
|
||||
# Make sure the file exists
|
||||
if not os.path.exists(path):
|
||||
if not os.path.isfile(path):
|
||||
raise SaltInvocationError('File not found: {0}'.format(path))
|
||||
|
||||
# Make sure it is a text file
|
||||
|
@ -1139,6 +1139,11 @@ def comment_line(path,
|
|||
if not found:
|
||||
return False
|
||||
|
||||
if not salt.utils.is_windows():
|
||||
pre_user = get_user(path)
|
||||
pre_group = get_group(path)
|
||||
pre_mode = __salt__['config.manage_mode'](get_mode(path))
|
||||
|
||||
# Create a copy to read from and to use as a backup later
|
||||
try:
|
||||
temp_file = _mkstemp_copy(path=path, preserve_inode=False)
|
||||
|
@ -1191,6 +1196,9 @@ def comment_line(path,
|
|||
"Exception: {2}".format(path, temp_file, exc)
|
||||
)
|
||||
|
||||
if not salt.utils.is_windows():
|
||||
check_perms(path, None, pre_user, pre_group, pre_mode)
|
||||
|
||||
# Return a diff using the two dictionaries
|
||||
return ''.join(difflib.unified_diff(orig_file, new_file))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue