Merge pull request #30168 from abednarik/2015.8

Fix incorrect file permissions in file.line
This commit is contained in:
Colton Myers 2016-01-06 09:25:08 -07:00
commit e5d87a02b9
2 changed files with 4 additions and 2 deletions

View file

@ -1459,9 +1459,9 @@ def line(path, content, match=None, mode=None, location=None,
salt '*' file.line /etc/nsswitch.conf "networks:\tfiles dns", after="hosts:.*?", mode='ensure'
'''
path = os.path.realpath(os.path.expanduser(path))
if not os.path.exists(path):
if not os.path.isfile(path):
if not quiet:
raise CommandExecutionError('File "{0}" does not exists.'.format(path))
raise CommandExecutionError('File "{0}" does not exists or is not a file.'.format(path))
return False # No changes had happened
mode = mode and mode.lower() or mode

View file

@ -12,6 +12,7 @@ import sys
import errno
import time
import random
import shutil
import salt.ext.six as six
@ -117,6 +118,7 @@ class _AtomicWFile(object):
if self._fh.closed:
return
self._fh.close()
shutil.copymode(self._filename, self._tmp_filename)
atomic_rename(self._tmp_filename, self._filename)
def __exit__(self, exc_type, exc_value, traceback):