Skip to content

Commit 9e6f4ff

Browse files
committed
added config more validation to cryptsetp
Signed-off-by: Zen <[email protected]>
1 parent 4051d3b commit 9e6f4ff

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

ugrd/crypto/cryptsetup.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
__author__ = 'desultory'
22

3-
__version__ = '0.4.9'
3+
__version__ = '0.5.0'
4+
5+
6+
CRYPTSETUP_PARAMETERS = ['key_type', 'partuuid', 'uuid', 'key_file', 'header_file']
47

58

69
def _process_cryptsetup(self, config_dict):
710
"""
811
Processes the cryptsetup configuration
912
"""
1013
self.logger.debug("Processing cryptsetup configuration: %s" % config_dict)
11-
for values in config_dict.values():
12-
if values.get('key_type') == 'gpg':
14+
for mapped_name, config in config_dict.items():
15+
if config.get('key_type') == 'gpg':
1316
self.logger.info("Key type is GPG, adding gpg to mod_depends")
1417
self['mod_depends'] = 'ugrd.crypto.gpg'
18+
if not config.get('partuuid') and not config.get('uuid'):
19+
raise ValueError("Unable to determine source device for: %s" % mapped_name)
20+
21+
for parameter in config:
22+
if parameter not in CRYPTSETUP_PARAMETERS:
23+
raise ValueError("Invalid parameter: %s" % parameter)
1524

1625
self['cryptsetup'].update(config_dict)
1726

0 commit comments

Comments
 (0)