7483 Commits

Author SHA1 Message Date
Michael Vogt
f28aa2676e Merge pull request #11515 from valentindavid/valentindavid/partially-revert-systemd-simplification
snap-bootstrap: Partially revert simplifications of mount dependencies
2022-03-21 12:52:03 +01:00
Ian Johnson
a6ffa57c1e cmd/snap-update-ns/change.go: sort needed, desired and not reused mount entries
* cmd/snap-update-ns/bootstrap.go: fix comment typos

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

* cmd/snap-update-ns/change.go: sort needed, desired and not reused mount entries

Sort new mount entries by their mimic creation directories, such that the mimic
directories that end up being created are done so in lexographical order.

Also update a single unit test where there were multiple mimic directories
being created because now all mount entries that create mimic directories are
performed first.

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

* cmd/snap-update-ns/change.go: stop using experimental flag

This experimental flag is not necessary anymore, and in fact is actively
harmful in that it is causing snaps to crash when they are running and an
update happens either to snapd or to their content snap dependencies and we end
up completely discarding the per-snap namespace, which leads to some
destructive effects inside the "sort of inheriting" per-user namespaces, that
then later do not get undone and thus recreated in the per-user namespace as
those namespaces aren't properly setup to inherit the constructive updates.

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

* cmd/snap-update-ns: remove old implementation

It's not used anymore, so we can just delete this code wholesale.

Also undo a typo fix, "s" is the British spelling so this can be left as-is.

Thanks to Alberto for spotting that this was leftover.

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

* cmd/snap-update-ns: unconditionally perform the "overname" mounts first

* cmd/snap-update-ns: ignore errors on unexisting mounts

When unmounting, we can get the EINVAL error if the given mount point
does not exist. Previously, this code was handling this fine for the
umount() syscall, but we do also need the same logic when attempting to
remount a mount as private.

* data/selinux: update policy to allow more mounts

When supporting appstream-metadata interface, snap-update-ns will mount
directories labeled as usr_t (eg. /usr/share/metainfo, /usr/share/appdata) and
fwdupd_cache_t (eg. /var/cache/app-info).

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>

* tests/regression/lp-1855596: test parallel installs + $SNAP/... layouts too

Test that with parallel installs and layouts which trigger mounts on top of
$SNAP/... (which itself will be an overname mount in a parallel install snap)
still work and we can still refresh such mount setups.

This is successful because we always handle overname mounts first when creating
the mounts and any such mounts underneath the overname are then ordered
properly.

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

* tests: remove duplicate tests

With commit df6bbd5c64d2820836e74039726a10dfe844cd91
(cmd/snap-update-ns/change.go: stop using experimental flag) a bunch of
tests which were nearly identical save for the fact that they were
exercising different implementations of the NeededChanges() function,
have become exact duplicates, since now there's only one implementation.

So, let's keep only one copy of them.

* cmd/snap-update-ns: add unit test for existing directories

Verify that the order of the changes matches the expectations when some
of the paths already exist.

* cmd/snap-update-ns: address review comments

* cmd/snap-update-ns: update doc-comments, eliminate code duplication

Thanks to Samuele for pointing out the inconsistency in the comment here.

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

* tests/mounts-persist-refresh-content-snap: regression test for firefox crash

This ensures that files which are shared via mounts in the MountConnectedPlug
method in an interface like the desktop interface remain shared in the per-user
mount namespace when the content snap is refreshed (not the main snap itself
even). We don't expect this situation to happen much when refresh app awareness
is fully enabled by default, but it is still important to test that the
snap-update-ns isn't horribly breaking apps when refreshes happen to take place
when apps are still running (this could be the case for desktop systems which
have a running app for more than 14 days for example).

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

* tests/main/mounts-persist-refresh-content-snap: fix newline at EOF

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

* tests/mounts-persist-refresh-content-snap: fix firefox crash regression test

To actually reproduce the crash, we need to use layouts with sources from the
files that the content interface is sharing with the snap.

Additionally, create the fonts dir and restart snapd before installing the
snap, actually exit 1 if the process died and kill the parent process last with
the other child processes in the restore section, and fix the shellcheck issue.

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

* tests/main/mounts-persist-refresh-content-snap: don't run on core

The rootfs is read-only and can't have the fonts directory created there.

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

* tests/main/mounts-persist-refresh-content-snap: fix exiting in happy case

It works much better to have the loop just exit itself and then kill the
process too just in case.

Finally, limit to 10 minutes in case we do get something wrong so we don't 
waste too much time waiting for processes to exit.

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

* tests: improve process handling

The `-p` option to `ps` was missing, and we can just use `wait` for
checking process termination.

* tests: sort yaml keys according to predefined order

Co-authored-by: Alberto Mardegan <mardy@users.sourceforge.net>
Co-authored-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2022-03-21 12:50:35 +01:00
Michael Vogt
8603cf4a7e Merge pull request #11505 from stolowski/core20-preseed/snap-preseed-reorg
cmd/snap-preseed, image: move preseeding code to image/preseed
2022-03-21 12:23:54 +01:00
Michael Vogt
fec3ee3669 Merge pull request #11532 from bboozzoo/bboozzoo/make-vet-1.18-happy
cmd/snap: make 1.18 vet happy
2022-03-18 11:02:37 +01:00
Paweł Stołowski
473a59573f Merge branch 'master' into core20-preseed/snap-preseed-reorg 2022-03-18 10:56:08 +01:00
Michael Vogt
2af863e2aa Merge pull request #11068 from alfonsosanchezbeato/piboot
bootloader: add support for piboot
2022-03-18 10:03:03 +01:00
Maciej Borzecki
52e75ac014 cmd/snap: make 1.18 vet happy
Go vet in 1.18 is more picky about fmt.*rintln and additional newlines at the
end of output, thus producing errors like:

./cmd_info_test.go:1197:4: fmt.Fprintln arg list ends with redundant newline
./cmd_info_test.go:1201:4: fmt.Fprintln arg list ends with redundant newline
./cmd_routine_portal_info_test.go:101:4: fmt.Fprintln arg list ends with redundant newline
./cmd_routine_portal_info_test.go:161:4: fmt.Fprintln arg list ends with redundant newline
./cmd_run_test.go:1755:5: fmt.Fprintln arg list ends with redundant newline

See https://github.com/golang/go/issues/49350 and https://go.dev/doc/go1.18#vet
Although I believe we should not be hitting this case, still it does not make
sense to output so many newlines, so it's worth fixing.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2022-03-18 08:30:29 +01:00
Valentin David
b50ff77d98 snap-bootstrap: Partially revert simplifications of mount dependencies
In a previous change, we removed a lot of useless dependencies in
mounts generated by `snap-bootstrap initramfs-mounts`. But because of
some cleanup was done also on core22, we get an issue with a missing
dependency from `local-fs.target`. Mounts get unmounted in the main
boot of core22 (not core20) because they are not part of any active
target.
2022-03-17 15:02:56 +01:00
Alfonso Sánchez-Beato
97e5728407 c/s-b/cmd_initramfs_mounts_test: add test case for update bootloader vars 2022-03-16 17:20:40 +01:00
Paweł Stołowski
f68cbf7147 Fix unreachable code. 2022-03-16 11:28:16 +01:00
Paweł Stołowski
397fa54979 Merge branch 'master' into core20-preseed/snap-preseed-reorg 2022-03-16 11:17:21 +01:00
Paweł Stołowski
df9f9d16d9 Provide Core20/Classic exported functions. 2022-03-16 10:48:54 +01:00
Paweł Stołowski
9e7f672c28 Move preseeding code to a separate package under image/preseed. 2022-03-15 13:04:58 +01:00
Michael Vogt
277eb06412 many: replace use of "sanity" with more inclusive naming
This commit replaces the use of "sanity" with more inclusive
naming.

When `sanity` is used in a more general sense either `validity`
or `quick` is used.
2022-03-14 18:22:34 +01:00
Michael Vogt
e240ef5520 Merge pull request #11461 from stolowski/core20-preseed/snap-preseed-cmd
cmd/snap-preseed: support for core20 preseeding
2022-03-14 14:55:04 +01:00
Michael Vogt
b3ff6f138d Merge pull request #11449 from MiguelPires/cmd-core22
cmd: set core22 migration related env vars and update spread test
2022-03-14 13:13:00 +01:00
Paweł Stołowski
e79b3dbc00 Probe for UC20 image dir, drop --core20 flag. 2022-03-14 09:50:34 +01:00
Paweł Stołowski
e5c253cf24 Naming tweaks. 2022-03-14 09:21:32 +01:00
Paweł Stołowski
4be07839f6 Fix code comment. 2022-03-14 09:11:39 +01:00
Paweł Stołowski
bd54cc1593 Support for core20 preseeding via snap-preseed command. 2022-03-14 09:11:39 +01:00
Maciej Borzecki
e87659a1bb cmd/snap: add support for rebooting to factory-reset
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2022-03-10 10:51:50 +01:00
Michael Vogt
57b1cecba8 Merge pull request #11444 from bboozzoo/bboozzoo/misc-analyzer-fixes
cmd: misc analyzer fixes
2022-03-08 18:32:08 +01:00
Miguel Pires
26656586bc cmd/snap: set core22 migration related env vars 2022-03-08 13:13:19 +00:00
Miguel Pires
803e770435 Merge branch 'master' into core22-migration 2022-03-04 16:59:16 +00:00
Maciej Borzecki
1d237c6f2f Merge remote-tracking branch 'upstream/master' into bboozzoo/misc-analyzer-fixes 2022-03-04 12:27:30 +01:00