-
Notifications
You must be signed in to change notification settings - Fork 594
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
tests: add spread test for passphrase support #14867
base: fde-manager-features
Are you sure you want to change the base?
Changes from 8 commits
0b131a3
df1a7b4
d897ea6
a4cae1c
522f767
0f3c300
1d1a2df
685389a
6678a7f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"type": "model", | ||
"authority-id": "developer1", | ||
"series": "16", | ||
"brand-id": "developer1", | ||
"model": "developer1-2410-classic-dangerous", | ||
"architecture": "amd64", | ||
"timestamp": "2024-04-09T22:00:00+00:00", | ||
"grade": "dangerous", | ||
"base": "core22", | ||
"classic": "true", | ||
"distribution": "ubuntu", | ||
"serial-authority": [ | ||
"generic" | ||
], | ||
"snaps": [ | ||
{ | ||
"default-channel": "classic-24.10/edge", | ||
"id": "UqFziVZDHLSyO3TqSWgNBoAdHbLI4dAH", | ||
"name": "pc", | ||
"type": "gadget" | ||
}, | ||
{ | ||
"default-channel": "24.10/edge", | ||
"id": "pYVQrBcKmBa0mZ4CCN7ExT6jH8rY1hza", | ||
"name": "pc-kernel", | ||
"type": "kernel" | ||
}, | ||
{ | ||
"default-channel": "latest/edge", | ||
"id": "amcUKQILKXHHTlmSa7NMdnXSx02dNeeT", | ||
"name": "core22", | ||
"type": "base" | ||
}, | ||
{ | ||
"default-channel": "latest/stable", | ||
"id": "PMrrV4ml8uWuEUDBT8dSGnKUYbevVhc4", | ||
"name": "snapd", | ||
"type": "snapd" | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1204,13 +1204,20 @@ nested_start_core_vm_unit() { | |
PARAM_RTC="${NESTED_PARAM_RTC:-}" | ||
PARAM_EXTRA="${NESTED_PARAM_EXTRA:-}" | ||
|
||
local EXPECT_PASSPHRASE | ||
EXPECT_PASSPHRASE=${NESTED_EXPECT_PASSPHRASE:-} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems that the practice is insted to have a statement like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice catch, Thanks! updated |
||
|
||
# Open port 7777 on the host so that failures in the nested VM (e.g. to | ||
# create users) can be debugged interactively via | ||
# "telnet localhost 7777". Also keeps the logs | ||
# | ||
# XXX: should serial just be logged to stdout so that we just need | ||
# to "journalctl -u $NESTED_VM" to see what is going on ? | ||
if "$QEMU" -version | grep '2\.5'; then | ||
if [ -z "$EXPECT_PASSPHRASE" ]; then | ||
echo "internal error: NESTED_EXPECT_PASSPHRASE is set and qemu doesn't support chardev over socket" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you remember which systems this old version appears on? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apparently it is xenial https://launchpad.net/ubuntu/xenial/+source/qemu.
bboozzoo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
exit 1 | ||
fi | ||
# XXX: remove once we no longer support xenial hosts | ||
PARAM_SERIAL="-serial file:${NESTED_LOGS_DIR}/serial.log" | ||
else | ||
|
@@ -1371,6 +1378,13 @@ nested_start_core_vm_unit() { | |
${PARAM_CD} \ | ||
${PARAM_EXTRA} " "${PARAM_REEXEC_ON_FAILURE}" | ||
|
||
if [ -n "$EXPECT_PASSPHRASE" ]; then | ||
# Wait for passphrase prompt from serial log file. | ||
retry -n 120 --wait 1 sh -c "MATCH \"Please enter the passphrase\" < ${NESTED_LOGS_DIR}/serial.log" | ||
# Enter passphrase to continue boot. | ||
echo "$EXPECT_PASSPHRASE" | netcat -N localhost 7777 | ||
fi | ||
|
||
local EXPECT_SHUTDOWN | ||
EXPECT_SHUTDOWN=${NESTED_EXPECT_SHUTDOWN:-} | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -20,6 +20,9 @@ run_muinstaller() { | |||||
local label="${7}" | ||||||
local disk="${8}" | ||||||
local kern_mods_comp="${9:-}" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. otherwise the parameter indices and the shifting, combined with set -u make no sense. 9th parameter cannot be optional and have a default value expansion if 10th is expected to be present and if it's missing the code fails due to errors on unset variables
Suggested change
|
||||||
local passphrase="${10}" | ||||||
shift 10 | ||||||
local extra_muinstaller_args=("${@}") | ||||||
|
||||||
# ack the needed assertions | ||||||
snap ack "${kernel_assertion}" | ||||||
|
@@ -164,10 +167,15 @@ fi | |||||
EOF | ||||||
remote.exec "chmod +x /home/user1/mk-classic-rootfs-wrapper.sh" | ||||||
|
||||||
remote.exec "sudo muinstaller \ | ||||||
-label ${label} \ | ||||||
-device ${install_disk} \ | ||||||
-rootfs-creator /home/user1/mk-classic-rootfs-wrapper.sh" | ||||||
muinstaller_args=() | ||||||
muinstaller_args+=("-label $label") | ||||||
muinstaller_args+=("-device $install_disk") | ||||||
muinstaller_args+=("-rootfs-creator /home/user1/mk-classic-rootfs-wrapper.sh") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't each argument be separate? Like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for catching this, updated |
||||||
if [ -n "$passphrase" ]; then | ||||||
muinstaller_args+=("-passphrase \"$passphrase\"") | ||||||
fi | ||||||
muinstaller_args+=("${extra_muinstaller_args[@]}") | ||||||
remote.exec sudo muinstaller "${muinstaller_args[@]}" | ||||||
|
||||||
remote.exec "sudo sync" | ||||||
|
||||||
|
@@ -196,7 +204,11 @@ EOF | |||||
fi | ||||||
|
||||||
# Start installed image | ||||||
tests.nested create-vm core --keep-firmware-state | ||||||
if [ -n "$passphrase" ]; then | ||||||
tests.nested create-vm core --keep-firmware-state --expect-passphrase "$passphrase" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick: maybe better just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, updated |
||||||
else | ||||||
tests.nested create-vm core --keep-firmware-state | ||||||
fi | ||||||
} | ||||||
|
||||||
main() { | ||||||
|
@@ -209,6 +221,8 @@ main() { | |||||
local label="classic" | ||||||
local disk="" | ||||||
local kern_mods_comp="" | ||||||
local passphrase="" | ||||||
local extra_muinstaller_args=() | ||||||
while [ $# -gt 0 ]; do | ||||||
case "$1" in | ||||||
--model) | ||||||
|
@@ -248,6 +262,14 @@ main() { | |||||
kern_mods_comp="${2}" | ||||||
shift 2 | ||||||
;; | ||||||
--passphrase) | ||||||
passphrase="${2}" | ||||||
shift 2 | ||||||
;; | ||||||
--extra-muinstaller-arg) | ||||||
extra_muinstaller_args+=("${2}") | ||||||
shift 2 | ||||||
;; | ||||||
--*|-*) | ||||||
echo "Unknown option ${1}" | ||||||
exit 1 | ||||||
|
@@ -338,7 +360,7 @@ main() { | |||||
|
||||||
run_muinstaller "${model_assertion}" "${store_dir}" "${gadget_snap}" \ | ||||||
"${gadget_assertion}" "${kernel_snap}" "${kernel_assertion}" "${label}" \ | ||||||
"${disk}" "${kern_mods_comp}" | ||||||
"${disk}" "${kern_mods_comp}" "${passphrase}" "${extra_muinstaller_args[@]}" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The way it is initialized, you get only one argument here, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure I fully understand. I created a sample script to try and understand better but it seems to behave as expected. #!/bin/bash
run_muinstaller() {
local arg1="$1"
shift 1
local extra_muinstaller_args=("${@}")
echo "arg1: $arg1"
for arg in "${extra_muinstaller_args[@]}"
do
echo "extra_muinstaller_arg: $arg"
done
}
main() {
local extra_muinstaller_args=()
while [ $# -gt 0 ]; do
case "$1" in
--extra-muinstaller-arg)
extra_muinstaller_args+=("${2}")
shift 2
;;
--*|-*)
echo "Unknown option ${1}"
exit 1
;;
*)
shift
;;
esac
done
run_muinstaller "test-arg1" "${extra_muinstaller_args[@]}"
}
main "$@" Running arg1: test-arg1
extra_muinstaller_arg: -kdf-type=pbkdf2
extra_muinstaller_arg: -passphrase=PASS There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought |
||||||
) | ||||||
} | ||||||
|
||||||
|
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.
We probably want core24 here. Or is it maybe necessary because the kernel in
classic-24.10/edge
uses core24 incorrectly?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.
AFAIK, FDE passphrase support is aimed for classic-25.04, which seems to use core22 as its base https://github.com/canonical/models/blob/master/ubuntu-classic-2504-amd64.json. I was mostly trying to mimic the target system. I don't mind switching to core24 though.
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.
Maybe worth asking in the next sync, the target should be core24 eventually.