Skip to content
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

[21.05] fc-luks: fix external header autodetection for multiple commands #1110

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions pkgs/fc/ceph/src/fc/ceph/luks/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def _do_rekey(self, slot: str, device: str, header: Optional[str]):
add_input = self._KEYSTORE.admin_key_for_input()
slot_id = self._KEYSTORE.slots[slot]

header_arg = [f"--header={header}"] if header else []
header_arg = ["--header", header] if header else []

dump = run.cryptsetup("luksDump", *header_arg, device, encoding="ascii")
if f" {slot_id}: luks2" in dump:
Expand Down Expand Up @@ -211,11 +211,13 @@ def check_luks(name_glob: str, header: Optional[str]) -> int:
errors = 0
for dev in devices:
console.print(f"Checking {dev.name}:")
dump_lines = (
Cryptsetup.cryptsetup("luksDump", dev.base_blockdev)
.decode("utf-8")
.splitlines()
)
if dev.header:
luks_dump = Cryptsetup.cryptsetup(
"luksDump", "--header", dev.header, dev.base_blockdev
)
else:
luks_dump = Cryptsetup.cryptsetup("luksDump", dev.base_blockdev)
dump_lines = luks_dump.decode("utf-8").splitlines()
for check in all_checks:
check_ok = True
for error in check(dump_lines):
Expand Down Expand Up @@ -263,13 +265,14 @@ def test_open(self, name_glob: str, header: Optional[str]) -> int:
return 0

def _do_test_open(self, device: str, header: Optional[str]) -> bool:
header_arg = [f"--header={header}"] if header else []
header_arg = ["--header", header] if header else []
success = True

# test unlocking both with local key file as well as with admin key
try:
test_admin = Cryptsetup.cryptsetup(
"open",
*header_arg,
"--test-passphrase",
device,
input=self._KEYSTORE.admin_key_for_input(),
Expand All @@ -282,6 +285,7 @@ def _do_test_open(self, device: str, header: Optional[str]) -> bool:
try:
test_local = Cryptsetup.cryptsetup(
"open",
*header_arg,
"--test-passphrase",
f"--key-file={self._KEYSTORE.local_key_path()}",
device,
Expand Down
Loading