Merge pull request #30586 from abednarik/fix_comment_line_perms

Fix comment_line permissions.
This commit is contained in:
Colton Myers 2016-01-25 16:24:01 -07:00
commit 643c9c9616

View file

@ -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))