Merge pull request #4320 from jdekoning/ssh-machine-creds-fix

Insert signed public key in artifact_dir, fix for issue #4139

Reviewed-by: Ryan Petrello
             https://github.com/ryanpetrello
This commit is contained in:
softwarefactory-project-zuul[bot] 2019-07-12 18:37:57 +00:00 committed by GitHub
commit a9bb1eba02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -828,8 +828,10 @@ class BaseTask(object):
os.chmod(path, stat.S_IRUSR | stat.S_IWUSR)
private_data_files['credentials'][credential] = path
for credential, data in private_data.get('certificates', {}).items():
name = 'credential_%d-cert.pub' % credential.pk
path = os.path.join(private_data_dir, name)
artifact_dir = os.path.join(private_data_dir, 'artifacts', str(self.instance.id))
if not os.path.exists(artifact_dir):
os.makedirs(artifact_dir, mode=0o700)
path = os.path.join(artifact_dir, 'ssh_key_data-cert.pub')
with open(path, 'w') as f:
f.write(data)
f.close()