Skip to content

Commit

Permalink
Replaces a open/close to validate access with os.access in azure stor…
Browse files Browse the repository at this point in the history
…ageblob. (ansible#65608)
  • Loading branch information
atombrella authored Feb 5, 2020
1 parent 52f2081 commit 3dd4b3c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/65608.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- azure_storageblob - use os.access to check for read rights.
11 changes: 4 additions & 7 deletions lib/ansible/modules/cloud/azure/azure_rm_storageblob.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,10 @@ def download_blob(self):
def src_is_valid(self):
if not os.path.isfile(self.src):
self.fail("The source path must be a file.")
try:
fp = open(self.src, 'r')
fp.close()
except IOError:
self.fail("Failed to access {0}. Make sure the file exists and that you have "
"read access.".format(self.src))
return True
if os.access(self.src, os.R_OK):
return True
self.fail("Failed to access {0}. Make sure the file exists and that you have "
"read access.".format(self.src))

def dest_is_valid(self):
if not self.check_mode:
Expand Down

0 comments on commit 3dd4b3c

Please sign in to comment.