Merge branch '2015.5' into 2015.8

This commit is contained in:
rallytime 2016-01-26 16:21:29 -07:00
commit 76ab6981a5

View file

@ -1099,7 +1099,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
@ -1141,6 +1141,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)
@ -1193,6 +1198,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))