diff options
author | Mads Jensen <mads.jensen@eficode.com> | 2020-02-05 14:20:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-05 08:20:39 -0500 |
commit | 3dd4b3c8a38794f13a31d396135c04fc555728ae (patch) | |
tree | 40d30dc4ade2515ceaf15d9026c83c60de51372f | |
parent | 52f2081e62a8d12dcd7be31aac84b3ab9d105c90 (diff) | |
download | ansible-3dd4b3c8a38794f13a31d396135c04fc555728ae.tar.gz |
Replaces a open/close to validate access with os.access in azure storageblob. (#65608)
-rw-r--r-- | changelogs/fragments/65608.yml | 2 | ||||
-rw-r--r-- | lib/ansible/modules/cloud/azure/azure_rm_storageblob.py | 11 |
2 files changed, 6 insertions, 7 deletions
diff --git a/changelogs/fragments/65608.yml b/changelogs/fragments/65608.yml new file mode 100644 index 0000000000..198c5ee3c2 --- /dev/null +++ b/changelogs/fragments/65608.yml @@ -0,0 +1,2 @@ +bugfixes: + - azure_storageblob - use os.access to check for read rights. diff --git a/lib/ansible/modules/cloud/azure/azure_rm_storageblob.py b/lib/ansible/modules/cloud/azure/azure_rm_storageblob.py index 0833640cf6..d77255d9cb 100644 --- a/lib/ansible/modules/cloud/azure/azure_rm_storageblob.py +++ b/lib/ansible/modules/cloud/azure/azure_rm_storageblob.py @@ -412,13 +412,10 @@ class AzureRMStorageBlob(AzureRMModuleBase): 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: |