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

several: add --no-enhanced-secureboot flag #1771

Merged
merged 1 commit into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions subiquity/cmd/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ def make_server_args_parser():
default=".subiquity",
help="in dryrun, control basedir of files",
)
parser.add_argument(
"--no-enhanced-secureboot",
dest="enhanced_secureboot",
action="store_false",
default=True,
)
dbungert marked this conversation as resolved.
Show resolved Hide resolved

parser.add_argument("--storage-version", action="store", type=int)
parser.add_argument("--use-os-prober", action="store_true", default=False)
parser.add_argument(
Expand Down
7 changes: 7 additions & 0 deletions subiquity/server/controllers/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@ async def _examine_systems(self):
system = await self._get_system(name, label)
log.debug("got system %s for variation %s", system, name)
if system is not None and len(system.volumes) > 0:
if not self.app.opts.enhanced_secureboot:
log.debug("Not offering enhanced_secureboot: commandline disabled")
continue
info = self.info_for_system(name, label, system)
if info is not None:
self._variation_info[name] = info
Expand Down Expand Up @@ -607,6 +610,10 @@ async def guided(
disk = self.model._one(id=choice.target.disk_id)

if self.is_core_boot_classic():
if not self.app.opts.enhanced_secureboot:
raise ValueError(
"Not using enhanced_secureboot: disabled on commandline"
)
assert isinstance(choice.target, GuidedStorageTargetReformat)
self.use_tpm = choice.capability == GuidedCapability.CORE_BOOT_ENCRYPTED
await self.guided_core_boot(disk)
Expand Down
28 changes: 28 additions & 0 deletions subiquity/tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,34 @@ async def test_basic_core_boot(self):
self.assertDictSubset(dict(mount=None), p3)
self.assertDictSubset(dict(mount="/"), p4)

@timeout()
async def test_basic_core_boot_cmdline_disable(self):
cfg = self.machineConfig("examples/machines/simple.json")
with cfg.edit() as data:
attrs = data["storage"]["blockdev"]["/dev/sda"]["attrs"]
attrs["size"] = str(25 << 30)
kw = dict(
bootloader="uefi",
extra_args=[
"--storage-version",
"2",
"--source-catalog",
"examples/sources/install-canary.yaml",
"--dry-run-config",
"examples/dry-run-configs/tpm.yaml",
"--no-enhanced-secureboot",
],
)
async with start_server(cfg, **kw) as inst:
await inst.post("/source", source_id="ubuntu-desktop")
resp = await inst.get("/storage/v2/guided", wait=True)
[reformat, manual] = resp["targets"]
for capability in reformat["allowed"]:
self.assertNotIn("CORE_BOOT", capability)
data = dict(target=reformat, capability="CORE_BOOT_ENCRYPTED")
with self.assertRaises(ClientResponseError):
await inst.post("/storage/v2/guided", data)


class TestAdd(TestAPI):
@timeout()
Expand Down