If the path does not exist. Let us know.

This commit is contained in:
Pedro Algarvio 2013-12-14 12:24:24 +00:00
parent 91e254d2a6
commit f46d8c5d6c

View File

@ -353,13 +353,17 @@ def check_path_traversal(path, user='root'):
for tpath in list_path_traversal(path): for tpath in list_path_traversal(path):
if not os.access(tpath, os.R_OK): if not os.access(tpath, os.R_OK):
msg = 'Could not access {0}.'.format(tpath) msg = 'Could not access {0}.'.format(tpath)
if not os.path.exists(tpath):
msg += ' Path does not exist.'
else:
current_user = getpass.getuser() current_user = getpass.getuser()
# Make the error message more intelligent based on how # Make the error message more intelligent based on how
# the user invokes salt-call or whatever other script. # the user invokes salt-call or whatever other script.
if user != current_user: if user != current_user:
msg += ' Try running as user {0}.'.format(user) msg += ' Try running as user {0}.'.format(user)
else: else:
msg += ' Please give {0} read permissions.'.format(user, tpath) msg += ' Please give {0} read permissions.'.format(user,
tpath)
# Propagate this exception up so there isn't a sys.exit() # Propagate this exception up so there isn't a sys.exit()
# in the middle of code that could be imported elsewhere. # in the middle of code that could be imported elsewhere.
raise SaltClientError(msg) raise SaltClientError(msg)