mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 07:26:29 +00:00
admin_user: Properly validate SSH keys
This commit is contained in:
parent
9de36b9d99
commit
7fd7ba5aa1
1 changed files with 7 additions and 1 deletions
|
@ -18,10 +18,16 @@ class CheckPublicKeyFile(Task):
|
||||||
|
|
||||||
pubkey = info.manifest.plugins['admin_user'].get('pubkey', None)
|
pubkey = info.manifest.plugins['admin_user'].get('pubkey', None)
|
||||||
if pubkey is not 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
|
msg = 'Could not find public key at %s' % pubkey
|
||||||
info.manifest.validation_error(msg, ['plugins', 'admin_user', '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):
|
class AddSudoPackage(Task):
|
||||||
description = 'Adding `sudo\' to the image packages'
|
description = 'Adding `sudo\' to the image packages'
|
||||||
|
|
Loading…
Add table
Reference in a new issue