admin_user: Properly validate SSH keys

This commit is contained in:
Nicolas Braud-Santoni 2016-09-11 23:38:43 +02:00
parent 9de36b9d99
commit 7fd7ba5aa1
No known key found for this signature in database
GPG key ID: 9D4F88010CFE19E3

View file

@ -18,10 +18,16 @@ class CheckPublicKeyFile(Task):
pubkey = info.manifest.plugins['admin_user'].get('pubkey', None)
if pubkey is not None:
if not os.path.isfile(rel_path(info.manifest.path, pubkey)):
abs_pubkey = rel_path(info.manifest.path, pubkey)
if not os.path.isfile(abs_pubkey):
msg = 'Could not find public key at %s' % pubkey
info.manifest.validation_error(msg, ['plugins', 'admin_user', 'pubkey'])
ret, _, stderr = log_call('ssh-keygen -l -f ' + abs_pubkey)
if ret != 0:
msg = 'Invalid public key file at %s' % pubkey
info.manifest.validation_error(msg, ['plugins', 'admin_user', 'pubkey'])
class AddSudoPackage(Task):
description = 'Adding `sudo\' to the image packages'