-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to use a LUKS keys vault #65
Conversation
Hello contributor, thanks for submitting a PR for this project! I am the bot who triggers "standard-CI" builds for this project. In order to allow automated tests to run, please ask one of the project maintainers to review the code and then do one of the following:
|
wrapper/tests/test_v2v_args.py
Outdated
'device': '/dev/sda2', | ||
'filename': '/tmp/luks/sda2', | ||
} | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create a new dictionary with the LUKS specific lines. I.e. copy VDDK_RHV and extend it with the above lines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it still be the case, now that I moved it to wrapper/tests/test_v2v_args.py
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please pick this commit 745fe83. It will fix the tests.
wrapper/hosts.py
Outdated
v2v_args.extend([ | ||
'--key', | ||
'%s:file:%s' % (luks_key['device'], luks_key['filename']) | ||
]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes should go to prepare_command()
in virt_v2v_wrapper.py
instead of into every host class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
wrapper/tests/test_v2v_args.py
Outdated
@@ -62,6 +73,8 @@ def test_vddk_basic(self): | |||
'-io', 'vddk-libdir=/opt/vmware-vix-disklib-distrib', | |||
'-io', 'vddk-thumbprint=01:23:45:67:89:AB:CD:EA:DB:EE:F0:12:34:56:78:9A:BC:DE:F0:12', # NOQA E501 | |||
'--password-file', '/vmware/password', | |||
'--key', '/dev/sda1:file:/tmp/luks/sda1', | |||
'--key', '/dev/sda2:file:/tmp/luks/sda2', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create new test function for the LUKS related changes instead of reusing test_vddk_basic()
wrapper/virt_v2v_wrapper.py
Outdated
@@ -487,6 +487,21 @@ def main(): | |||
host.get_uid(), | |||
host.get_gid()) | |||
|
|||
if 'luks_keys_vault' not in data: | |||
data['luks_keys_vault'] = '/tmp/v2v_luks_keys_vault.json' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a default? If yes, it may be worth using some other directory then /tmp
, e.g. /etc
or user's home directory. What do you think? Also what do you think about adding a check and refusing to load file that is readable/writable by someone else than owner?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good points. Changed to use user's home directory and added checks on permissions.
@nyoxi the tests fail, but I don't know what's causing the errors. Could you look at it, please ? |
@@ -748,7 +748,6 @@ def prepare_command(self, data, v2v_args, v2v_env, v2v_caps): | |||
v2v_args.extend(['-oo', 'rhv-verifypeer=%s' % | |||
('false' if data['insecure_connection'] else | |||
'true')]) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some leftover here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure I understand. this line is already deleted.
wrapper/tests/test_v2v_args.py
Outdated
'device': '/dev/sda2', | ||
'filename': '/tmp/luks/sda2', | ||
} | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please pick this commit 745fe83. It will fix the tests.
wrapper/virt_v2v_wrapper.py
Outdated
if file_stat.st_uid != host.get_uid(): | ||
hard_error('LUKS keys vault does\'nt belong to' | ||
'user running virt-v2v-wrapper') | ||
if not bool(file_stat.st_mode & stat.S_IRWXO): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This cast is ugly. I would prefer if file_stat.st_mode & stat.S_IRWXO > 0:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
wrapper/virt_v2v_wrapper.py
Outdated
'user running virt-v2v-wrapper') | ||
if not bool(file_stat.st_mode & stat.S_IRWXO): | ||
hard_error('LUKS keys vault is accessible to others') | ||
if not bool(file_stat.st_mode & stat.S_IRWXG): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
CI failure is unrelated |
ci test please |
For customers that have LUKS encrypted devices, we need a way to pass the LUKS keys to virt-v2v. This PR implements it by allowing a
luks_keys_vault
key in the JSON input. Currently, the implementation is really basic and only accept a clear JSON file as vault. The expected JSON file structure is:With this format, we can have many virtual machines declared into a single file.
To reduce coupling with ManageIQ, there's a default path for the vault file, so that it only has to exist to be leveraged by virt-v2v-wrapper. In the future, ManageIQ may generate the vault file(s) and override that default value.