|
1 | 1 | __author__ = 'desultory' |
2 | | -__version__ = '2.5.8' |
| 2 | +__version__ = '2.6.0' |
3 | 3 |
|
4 | 4 | from zenlib.util import contains |
5 | 5 |
|
@@ -248,10 +248,8 @@ def get_crypt_dev(self) -> list[str]: |
248 | 248 | ' source_dev=$(blkid --match-token "$source_token" --output device)', |
249 | 249 | ' if [ -n "$source_dev" ]; then', |
250 | 250 | ' echo -n "$source_dev"', |
251 | | - ' return', |
252 | 251 | ' fi', |
253 | | - 'fi', |
254 | | - 'rd_fail "Failed to resolve device source for cryptsetup mount: $1"'] |
| 252 | + 'fi'] |
255 | 253 |
|
256 | 254 |
|
257 | 255 | def open_crypt_device(self, name: str, parameters: dict) -> list[str]: |
@@ -284,8 +282,14 @@ def open_crypt_device(self, name: str, parameters: dict) -> list[str]: |
284 | 282 | cryptsetup_command += ' --allow-discards' |
285 | 283 | self.logger.warning("Using --allow-discards can be a security risk.") |
286 | 284 |
|
| 285 | + # Resolve the device source using get_crypt_dev, if no source is returned, run rd_fail |
| 286 | + out += [f'crypt_dev="$(get_crypt_dev {name})"', |
| 287 | + 'if [ -z "$crypt_dev" ]; then', |
| 288 | + f' rd_fail "Failed to resolve device source for cryptsetup mount: {name}"', |
| 289 | + 'fi'] |
| 290 | + |
287 | 291 | # Add the variable for the source device and mapped name |
288 | | - cryptsetup_command += f' "$(get_crypt_dev {name})" {name}' |
| 292 | + cryptsetup_command += f' "$crypt_dev" {name}' |
289 | 293 |
|
290 | 294 | # Check if the device was successfully opened |
291 | 295 | out += [f' if {cryptsetup_command}; then', |
|
0 commit comments