Improve error reporting from verify_files

Make it similar to what verify_env already does, so that
we tell people exactly which path was a problem.  I hit this
while running salt-master in a non-standard configuration, and
the change makes it easier to hunt down which path is wrong
in a config.
This commit is contained in:
John Spray 2013-10-30 17:12:58 +00:00
parent 058eeec39d
commit e9f49a462f

View File

@ -161,11 +161,17 @@ def verify_files(files, user):
sys.exit(2)
for fn_ in files:
dirname = os.path.dirname(fn_)
try:
if not os.path.isdir(dirname):
os.makedirs(dirname)
if not os.path.isfile(fn_):
with salt.utils.fopen(fn_, 'w+') as fp_:
fp_.write('')
except OSError as err:
msg = 'Failed to create path "{0}" - {1}\n'
sys.stderr.write(msg.format(fn_, err))
sys.exit(err.errno)
stats = os.stat(fn_)
if uid != stats.st_uid:
try: