Replaces a open/close to validate access with os.access in azure storageblob. (#65608)

pull/67109/head
Mads Jensen 6 years ago committed by GitHub
parent 52f2081e62
commit 3dd4b3c8a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- azure_storageblob - use os.access to check for read rights.

@ -412,13 +412,10 @@ class AzureRMStorageBlob(AzureRMModuleBase):
def src_is_valid(self): def src_is_valid(self):
if not os.path.isfile(self.src): if not os.path.isfile(self.src):
self.fail("The source path must be a file.") self.fail("The source path must be a file.")
try: if os.access(self.src, os.R_OK):
fp = open(self.src, 'r') return True
fp.close()
except IOError:
self.fail("Failed to access {0}. Make sure the file exists and that you have " self.fail("Failed to access {0}. Make sure the file exists and that you have "
"read access.".format(self.src)) "read access.".format(self.src))
return True
def dest_is_valid(self): def dest_is_valid(self):
if not self.check_mode: if not self.check_mode:

Loading…
Cancel
Save