#NEWLINE# def check_path_traversal( path , user = 'root' , skip_perm_errors = False ) : #NEWLINE# #INDENT# "\n    Walk from the root up to a directory and verify that the current\n    user has access to read each directory. This is used for  making\n    sure a user can read all parent directories of the minion's  key\n    before trying to go and generate a new key and raising an IOError\n    " #NEWLINE# for tpath in list_path_traversal ( path ) : #NEWLINE# #INDENT# if ( not os . access ( tpath , os . R_OK ) ) : #NEWLINE# #INDENT# msg = 'Could not access {0}.' . format ( tpath ) #NEWLINE# if ( not os . path . exists ( tpath ) ) : #NEWLINE# #INDENT# msg += ' Path does not exist.' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# current_user = salt . utils . get_user ( ) #NEWLINE# if ( user != current_user ) : #NEWLINE# #INDENT# msg += ' Try running as user {0}.' . format ( user ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# msg += ' Please give {0} read permissions.' . format ( user ) #NEWLINE# #UNINDENT# #UNINDENT# if skip_perm_errors : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# raise SaltClientError ( msg )