Commit Graph

27 Commits

Author SHA1 Message Date
Ian Johnson
a53659e8fa tests/core/basic20: test that ubuntu-save has disk-mapping.json on it too
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2022-02-17 10:31:38 -06:00
Ian Johnson
1cd71e2ad6 tests/core/basic20: check that disk-mapping.json is created
Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2022-02-15 09:58:58 -06:00
Valentin David
2af8390b32 snap-bootstrap: Mount snaps read only
While squashfs is always read-only, when mount creates the required
loop device, it does not know that squashfs is a read-only
filesystem. This causes the loop devices for snaps mounted in the
initramfs to be be writable. Since the snaps are stored on
`/run/mnt/data`, it means the `/run/mnt/data` cannot be remounted
read-only.

There is a mount cycle now in Ubuntu Core where `/run/mnt/data` cannot
be unmounted because it contains the snap for the Core snap which is
mounted as root. After switching to the shutdown ramfs, then systemd
tries again to umount the remaining file systems as well as the root
file system. At this point, it still cannot umount `/run/mnt/data`, so
`systemd-shutdown` tries to remount read-only. But since the loop
device for the Core snap that cannot be unmounted is still writable,
then `/run/mnt/data` cannnot be remounted read-only.

This results in Ubuntu Core not properly unmounting `/run/mnt/data`.
This can be seen in the screen or serial console right before powering
off or rebooting:

```
Failed to remount '/oldroot/run/mnt/data' read-only: Device or resource busy
```

With this fix, this error disappears. While other errors about
unmounting are still here, it is safer because everything is
read-only.
2021-12-03 14:05:31 +01:00
Samuele Pedroni
c57cdb2991 boot,tests: move where we write boot-flags one level up
* boot,tests: move where we write boot-flags one level up

/run/snapd/snap-bootstrap is a scratch directory and user space
shouldn't care a lot about it

* cmd/snap-bootstrap/initramfs-mounts: fix boot-flags location from initramfs

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>

Co-authored-by: Ian Johnson <ian.johnson@canonical.com>
2021-04-12 09:17:57 +02:00
Sergio Cazzolato
c33fde18a1 tests: fix basic20 test on arm devices (#9651)
* Skip kernel checks on arm devices for basic20 test

* skip boot checks on arm devices

* Update checks for arm devices
2020-11-18 09:55:07 +01:00
Ian Johnson
a334756c92 many: put the model on ubuntu-boot inside the "device" dir
This matches where we now put the keys for unsealing on ubuntu-boot.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>
2020-11-05 12:09:59 -06:00
Sergio Cazzolato
3ced822412 Make a more generic check 2020-09-16 14:02:21 -03:00
Sergio Cazzolato
fa44e1fe61 Update the check for brand
It is because there is not match for the brand from recovery and model,
I'll need to add some code to manually update that on the test.

google:ubuntu-core-20-64 .../tests/core/basic20# snap recovery --unicode
never
Label Brand Model Notes
20200915 canonical* ubuntu-core-20-amd64-dangerous current
google:ubuntu-core-20-64 .../tests/core/basic20# snap recovery --unicode
auto
Label Brand Model Notes
20200915 canonical✓ ubuntu-core-20-amd64-dangerous current
google:ubuntu-core-20-64 .../tests/core/basic20# snap recovery --unicode
always
Label Brand Model Notes
20200915 canonical✓ ubuntu-core-20-amd64-dangerous current

google:ubuntu-core-20-64 .../tests/core/basic20# snap model --verbose
brand-id: canonical
model: ubuntu-core-20-amd64-dangerous
serial: ee7845cb-ef5a-40b8-83d7-13654c74ec65
architecture: amd64
base: core20
timestamp: 2020-01-13
google:ubuntu-core-20-64 .../tests/core/basic20# snap model
brand Canonical✓
model ubuntu-core-20-amd64-dangerous
serial ee7845cb-ef5a-40b8-83d7-13654c74ec65
2020-09-15 21:11:20 -03:00
Sergio Cazzolato
91cbda2812 Simplify even more how the brand is calculated 2020-09-15 17:05:58 -03:00
Sergio Cazzolato
223d4f1218 Simplify how the brand is obtained 2020-09-15 13:50:07 -03:00
Sergio Cazzolato
d22256d0ac Fixes for basic20 test running on external backend
This fixes:
 . Matching the right kernel which could be pc-kerne or pi-kernel
 . Checking snap recovery output against the model information

These changes are needed to make the test work with external backend on
lab devices
2020-09-10 18:58:09 -03:00
Michael Vogt
30a0b18e90 snap: rework output to be closer to "snap list" (thanks Samuele) 2020-07-16 18:50:53 +02:00
Michael Vogt
63dcfcd2d4 cmd: add new "snap recovery" command
The new "snap recovery" command lists the available recovery
systems.
2020-07-16 14:59:36 +02:00
Maciej Borzecki
8772dd3aa4 tests/core/basic20: verify that managed boot assets are in use
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2020-06-26 11:51:44 +02:00
Sergio Cazzolato
0fa575a077 Merge remote-tracking branch 'upstream/master' into tests-port-2-uc20-part1 2020-06-09 15:17:19 -03:00
Sergio Cazzolato
f987dbb0e1 Fix the basic20 test for uc20 on external backend 2020-06-09 00:28:25 -03:00
Sergio Cazzolato
d835716215 Add extra checks for tpm test on nested suite 2020-06-04 15:08:36 -03:00
Ian Johnson
951143c28d snap/squashfs: also symlink snap Install with uc20 seed snap dir layout (#8711)
This ensures that during install/recover mode we use symlinks in /var/lib/snapd/snaps to /var/lib/snapd/seed/systems//snaps, and that makebootable will still copy the full snap file to /run/mnt/ubuntu-data/... such that the initramfs and run mode see a normal snap file. Note that we specifically don't want the initramfs to use symlinks from ubuntu-data to ubuntu-seed because this is not trusted, this is enforced by passing a new InstallOptions to Container.Install with a MustNostCrossDevices flag.

This was prompted by https://bugs.launchpad.net/snapd/+bug/1878647 because there, the tmpfs we mount for ubuntu-data/writable is only 205M, and all the kernel and base snaps are over 205M and so the install runs out of space to copy the snap files onto the tmpfs and eventually snapd tries to uninstall itself during first-boot.

This fixes https://bugs.launchpad.net/snapd/+bug/1878647


* boot/makebootable: if kernel,base snaps are symlinks, follow symlink

This ensures that if we switch setup during install/recover mode to use symlinks
in /var/lib/snapd/snaps to /var/lib/snapd/seed/systems/<label>/snaps, that
makebootable will still copy the full snap file to /run/mnt/ubuntu-data/...
such that the initramfs and run mode see a normal snap file.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>

* snap/squashfs: fix creating symlinks when snap is in uc20 seed system snaps dir

During uc20 install and recover modes, we will have a tmpfs as our writable
partition and as such we don't really want or need to make a full copy of the
snap files into /var/lib/snapd/snaps, and can make do with a symlink instead.

However, during uc20 install and recover modes the snap files from the seed dir
will be of the form /var/lib/snapd/seed/systems<label>/snaps/<name>.snap and so
the previous logic to install it was wrong, as the <name>.snap would not be a
direct child of /var/lib/snapd/seed, and instead needs to check that it is just
prefixed with /var/lib/snapd/seed somewhere.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>

* snap/many: support InstallOptions + MustCopy for Install()

This will allow us from snapstate to decide how a snap file should be installed,
if it should be symlinked or if it should be always copied, etc. Eventually we
should also introduce logic to snapstate to decide if it should be linked to
remove the overlayfs specific logic from here where it is kind of awkward to
see.

Also add tests for the squashfs and snapstate implementations.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>

* overlord/snapstate: always copy files when seeding in uc20 run mode

This prevents us from inadventently installing symlinks from ubuntu-data to
ubuntu-seed, which would be insecure in the full disk encryption case because
an attacker could modify ubuntu-seed and after the disk is unlocked on
ubuntu-data and the system starts running, the snap from ubuntu-seed would be
mounted.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>

* snap: rename MustCopy to MustNotCrossDevices for InstallOptions

This option is really about security and ensuring that when we install a snap
that installation does not cross device/trust boundaries, i.e. on UC20 from
ubuntu-data (trusted) to ubuntu-seed (untrusted), so rename the option to better
reflect this.

Also, refactor the implementation to allow hard-links if MustNotCrossDevices is
true, as by definition hard-links cannot cross devices/filesystems, and really
should only limit symlinks.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>

* snap/snapdir: un-support MustNotCrossDevices in Install() for now

It's unclear what we want this implementation to look like, so for now just drop
it. `snap try` may be less secure on UC20 as a result, but that shouldn't be
happening on production devices anyways.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>

* tests/core/basic20: also test that no symlinks were created during seeding

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>

* tests/core/seed-base-symlinks: disable for UC20 permanently, adjust comment

We don't have symlinks from ubuntu-data /var/lib/snapd/snaps to ubuntu-seed at
/var/lib/snapd/seed by design on UC20 run mode.

Signed-off-by: Ian Johnson <ian.johnson@canonical.com>

* tests/core: fix spread tests adjustments

* squashfs: drop TODO:UC20 more likely to confuse than get ever addressed

Co-authored-by: Samuele Pedroni <pedronis@lucediurna.net>
2020-05-26 11:06:08 +02:00
Michael Vogt
912d1072c0 tests: fix shellcheck issue 2020-05-12 16:39:20 +02:00
Michael Vogt
205ba81b7b sysconfig: use new _writable_defaults dir to create cloud config
This commit creates the cloud configuration during install using
the new _writable_defaults mechanism from:
https://github.com/snapcore/core20/pull/46

This allows us to remove the "synced" setting from the writable-path
for the /etc/cloud dir.
2020-05-07 13:09:53 +02:00
Michael Vogt
2d5d77702d tests: disable recovery key check as we only encrypt with real TPM now 2020-04-15 18:44:49 +02:00
Michael Vogt
e0e7ee5d53 tests: only check for recovery key on systems with tpm 2020-04-07 07:43:11 +02:00
Claudio Matsuoka
827cd67b5f snap-bootstrap: also test the group of the recovery key file
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
2020-04-03 13:48:24 -03:00
Claudio Matsuoka
48e4b4101f tests: also check owner of recovery key file
Signed-off-by: Claudio Matsuoka <claudio.matsuoka@canonical.com>
2020-04-03 13:13:05 -03:00
Michael Vogt
bd3a3b177c devicestate: use /writable/system-data/var/lib/snapd/device/fde/recovery-key for the recovery key location 2020-04-03 12:54:02 +02:00