Merge pull request #2876 from pmelse/master

updated permission fix for sftp plugin if certificate is set read-only
This commit is contained in:
Hossein Shafagh 2020-01-03 13:14:38 -08:00 committed by GitHub
commit ebc48ae304
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 2 deletions

View File

@ -170,6 +170,15 @@ class SFTPDestinationPlugin(DestinationPlugin):
current_app.logger.debug( current_app.logger.debug(
"Uploading {0} to {1}".format(filename, dst_path_cn) "Uploading {0} to {1}".format(filename, dst_path_cn)
) )
try:
with sftp.open(dst_path_cn + "/" + filename, "w") as f:
f.write(data)
except (PermissionError) as permerror:
if permerror.errno == 13:
current_app.logger.debug(
"Uploading {0} to {1} returned Permission Denied Error, making file writable and retrying".format(filename, dst_path_cn)
)
sftp.chmod(dst_path_cn + "/" + filename, 0o600)
with sftp.open(dst_path_cn + "/" + filename, "w") as f: with sftp.open(dst_path_cn + "/" + filename, "w") as f:
f.write(data) f.write(data)
# read only for owner, -r-------- # read only for owner, -r--------