59617 Commits

Author SHA1 Message Date
ernestl
40efd81c2f release: 2.63 2.63 2024-04-24 11:27:52 +02:00
Valentin David
b32dcdcd2e interfaces/udev: generate rules with deprecated command line (#13882)
Snapd from the snap generate udev rules that executes snap-device-helper
from the host. In cases when the snap is newer than the package, the
new command line is rejected by the old snap-device-helper from the
package. Because the new snap-device-helper accepts old command-line,
but just ignores the extra parameters, it is safer for now to generate
rules with the old command line.
2024-04-24 11:27:52 +02:00
Justin Cattle
e56b10fb43 interfaces/opengl: enable use of nvidia container toolkit CDI config generation (#13847)
The nvidia container toolkit needs to traverse the top level libs
directory in order to discover the libraries and generate a CDI config.
2024-04-24 11:27:52 +02:00
Zygmunt Bazyli Krynicki
b6f8ab33f6 tests/regression: skip lp-1848567 if internal parser is used (#13874)
The test uses host parser unconditionally, which may not understand
future syntax that is present in cases when apparmor is carried
by snapd snap package.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2024-04-24 11:27:52 +02:00
Maciej Borzecki
bf3af32bbc data/selinux: update policy to allow stat of /run/systemd/container (#13872)
Since 3cfa28a0fc snap-confine checks if the system is running in a container. It
does so by reading /run/systemd/container. Extend the SELinux to allow basic
search operations within /run/systemd. It is unlikely anyone runs snapd in a
container where the SELinux is enabled on the host, so the actual file read
permissions are likely not needed.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
2024-04-24 11:27:52 +02:00
Maciej Borzecki
e63665aa2c cmd/snap-confine: skip device cgroup setup when running inside a container (#13859)
* cmd/libsnap-confine-private: helper for detecting if executing inside a container

Add a helper which attempts to detect if the current process is executing inside
a container environment. Specifically, look for /run/systemd/container and check
whether it is non empty.

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

* cmd/snap-confine: do not setup device cgroup if running inside a container

Do not set up a device cgroup filter, if we're running inside the container. The
rationale is that the container environment has already shut down device access
sufficiently, and especially if running in unprivileged container, we may not be
able to set it up correctly anyway.

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

* cmd/snap-confine: allow reading of /run/systemd/container

Allow snap-confine to read /run/system/container to implement container
execution check.

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

* cmd/snap-confine: use strnlen for sc_is_container

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

---------

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Co-authored-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2024-04-24 11:27:52 +02:00
Zygmunt Bazyli Krynicki
9baeee4891 i/apparmor: allow snap-update-ns to traverse to /var/lib/snapd (#13858)
I've noticed this denial in one of my test systems:

  kwi 19 10:54:52 ubuntu-2204-cryptfs kernel: audit: type=1400
  audit(1713516892.723:323): apparmor="DENIED" operation="open" class="file"
  profile="snap-update-ns.chromium" name="/var/lib/snapd /" pid=8425 comm="5"
  requested_mask="r" denied_mask="r" fsuid=0 ouid=0

Given that snap-update-ns must access mount profiles and contains code to
safely traverse a path without any symbolic links, I think the extra
permissions is acceptable.

I did not audit the code to pinpoint the exact cause.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2024-04-24 11:27:52 +02:00
Zygmunt Bazyli Krynicki
e95b8018df i/apparmor: fix snap-update-ns with ecrypfs home (#13857)
Ever since snapd 2.62 was released, snap-update-ns requires opening the home
directory of the user for some validation and sanity checking. This is now
affected by a bug in base policy regarding ecryptfs. Add the similar workaround
we have in other templates.

Fixes: https://bugs.launchpad.net/ubuntu/+source/chromium-browser/+bug/2062330
Fixes: https://bugs.launchpad.net/ubuntu/+source/chromium-browser/+bug/2062173

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2024-04-24 11:27:52 +02:00
ernestl
35fed3fed9 overlord/snapstate: fix calls to compMntDir 2024-04-24 11:27:52 +02:00
ernestl
63324f0418 overlord/snapstate: fix calls to createTestComponent 2024-04-24 11:27:52 +02:00
alfonsosanchezbeato
6d806a77ac o/snapstate,tests: discard previous component on a component refresh (#13842)
* o/snapstate: store unlinked component information in change

As we will need this information in the component discard task.

* o/snapstate: discard previous component on a component refresh

Only one can be installed in the system at the same time.

* tests/component: check removal of older component after refresh

* o/snapstate: add function to retrieve component setup

Add function to find ComponentSetup for a task that is part of the
tasks created to do a component operation.

* o/snapstate: store unlinked component in ComponentSetup

* o/snapstate/backend: remove component related directories if empty

* o/snapstate: use SnapSetup to store the previous kernel revision

instead of having an object directly in the change.

* o/snapstate: store unlinked component in setup task

* o/snapstate: set previous kernel in setup task

instead of making it part of SnapSetup.

* o/snapstate: some additional tests
2024-04-24 11:27:52 +02:00
Zygmunt Bazyli Krynicki
46b66c4f00 i/apparmor: add missing expansion for s-u-n template (#13853)
This fixes access to /etc/apparmor.d/tunables when running from snapd snap.
When snapd snap re-executes, and uses apparmor_parser from snapd snap (those
are separate conditions), then it re-directs the parser away from host
/etc/apparmor.d and we have special code to load tunables from the host anyway.
Those tunables are themselves conditional on the conditional include syntax
that may or may not be supported by apparmor (otherwise the would be explicitly
spelled out in the template, and not dynamically expanded with custom logic).

The problem was introduced along with patch
b98e4af376 (i/apparmor: support for home.d
tunables from /etc/ (#13118)), as the case for snap-update-ns was missed, and
the default expansion is an empty string.

Regression-testing this requires that we re-package snapd snap, so the test
will come in with a separate patch as it requires somewhat more effort to
behave correctly.

This issue was identified by Maciej Borzecki.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2024-04-24 11:27:52 +02:00
Alfonso Sánchez-Beato
01abd57b52 o/snapstate: use StartBeforeDriversLoad only for systems with modes
We do not need early mounts for the kernel in UC16/18, and causes
problems with systemd on UC16.
2024-04-24 11:27:52 +02:00
Maciej Borzecki
ec6a5418d5 build-aux/snap: ship snap-debug-info.sh script
Ship the current version of snap-debug-info.sh script inside the snapd snapd, so
that folks no longer need to download it from snapd github repository.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
2024-04-24 11:27:52 +02:00
alfonsosanchezbeato
7277b01904 tests/core20-kernel-failover: use kernel from beta channel (#13839)
The one from edge will always fail if we have FDE, make sure that
there are no false negatives because of that.
2024-04-24 11:27:52 +02:00
Zygmunt Bazyli Krynicki
3bda7ef03a tests: fix fake-netplan-apply test (#13808)
* tests: fix fake-netplan-apply test

The test was meant to fail in a clear way on unsupported releases but due to an
unintentional refactor, it was just running on the wrong base.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

* tests: fake-netplan-apply equate jammy and mantic

Co-authored-by: Zeyad Yasser <zeyady98@gmail.com>

* tests: install core24 from edge for fake-netplan-apply

The netplan-snap is removed so that we can remove the base later.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

---------

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Co-authored-by: Zeyad Yasser <zeyady98@gmail.com>
2024-04-24 11:27:52 +02:00
alfonsosanchezbeato
f16e7774a8 tests/core20-kernel-failover: increase timeout waiting for try-kernel (#13835)
link. As sealing is taking longer than in the past.
2024-04-24 11:27:52 +02:00
alfonsosanchezbeato
bdeb1a9cf0 packaging: add kmod as Depends (#13830)
It is needed now on hybrid systems to be able to build the drivers
tree.
2024-04-24 11:27:52 +02:00
Maciej Borzecki
4e8dbc5523 overlord/snapstate/backend: mock depmod
The tests seem to call real depmod which fails when building on LP:

```
----------------------------------------------------------------------
FAIL: setup_test.go:770: setupSuite.TestRemoveKernelModulesComponentsFails

setup_test.go:786:
    s.testSetupKernelModulesComponents(c, firstInstalled, nil, ksnap, kernRev, "")
setup_test.go:709:
    c.Assert(err, IsNil)
... value *exec.Error = &exec.Error{Name:"depmod", Err:(*errors.errorString)(0x4000118380)} ("exec: \"depmod\": executable file not found in $PATH")

----------------------------------------------------------------------
FAIL: setup_test.go:656: setupSuite.TestSetupAndRemoveKernelModulesComponents

setup_test.go:662:
    // Set-up and then remove
    s.testSetupKernelModulesComponents(c, toInstall, nil, ksnap, kernRev, "")
setup_test.go:709:
    c.Assert(err, IsNil)
... value *exec.Error = &exec.Error{Name:"depmod", Err:(*errors.errorString)(0x4000118380)} ("exec: \"depmod\": executable file not found in $PATH")

----------------------------------------------------------------------
FAIL: setup_test.go:666: setupSuite.TestSetupAndRemoveKernelModulesComponentsWithInstalled

setup_test.go:672:
    s.testSetupKernelModulesComponents(c, firstInstalled, nil, ksnap, kernRev, "")
setup_test.go:709:
    c.Assert(err, IsNil)
... value *exec.Error = &exec.Error{Name:"depmod", Err:(*errors.errorString)(0x4000118380)} ("exec: \"depmod\": executable file not found in $PATH")

OOPS: 164 passed, 3 FAILED
```

Make sure to have a default mock which fails and a mock the appropriate variant
in tests which require it.

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
2024-04-24 11:27:52 +02:00
Ondra Kubik
2b786bf02f cmd: snap-bootstrap: fix unpreseeded sigle boot install (#13475)
Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>
2024-04-12 21:06:09 +02:00
Alfonso Sánchez-Beato
fe87c19891 kernel,overlord: fix component unit tests 2024-04-12 19:48:18 +01:00
Sergio Cazzolato
c2956eabe5 tests: improve nightly github workflow (#13825)
The main fix in this change is the cobertura file path is updated
Also several shellcheck improvements are included
2024-04-12 12:26:08 -03:00
Maciej Borzecki
25c9e7de42 daemon: fix notices API tests on non Ubuntu (#13823)
Snap mount location is hardcoded, but os-release is not mocked, so host paths
are assumed.

Failed like so:

```
----------------------------------------------------------------------
FAIL: api_notices_test.go:947: noticesSuite.TestAddNoticesSnapCmdReexecCore

api_notices_test.go:948:
    s.testAddNoticesSnapCmd(c, "/snap/core/12/usr/bin/snap", false)
api_base_test.go:648:
    c.Assert(rsp.Type, check.Equals, daemon.ResponseTypeSync, check.Commentf("expected sync resp: %#v, result: %+v", rsp, rsp.Result))
... obtained daemon.ResponseType = "error"
... expected daemon.ResponseType = "sync"
... expected sync resp: &daemon.respJSON{Type:"error", Status:403, StatusText:"", Result:(*daemon.errorResult)(0xc0007911d0), Change:"", Sources:[]string(nil), SuggestedCurrency:"", WarningTimestamp:<nil>, WarningCount:0, Maintenance:(*daemon.errorResult)(nil)}, result: &{Message:only snap command can record notices Kind:login-required Value:<nil>}
... Difference:
...     "error" != "sync"

```

Signed-off-by: Maciej Borzecki <maciej.borzecki@canonical.com>
2024-04-12 16:04:58 +02:00
alfonsosanchezbeato
1a5cef2ef6 o/snapstate: add support for kernel-modules handlers (#13748)
* kernel,overlord: use function from kernel pkg to get kernel early

mount dir.

* o/snapstate/sequence: add ancillary methods to retrieve components

for a given snap revision in the sequence. One of the methods can be
given a component type for filtering.

* o/snapstate/backend: add methods to set-up kernel-modules components

* o/snapstate: add handlers to set-up kernel-modules components

* o/snapstate: add specific setup task for kernel-modules components

* o/{devicestate,snapstate}: change name of kernel set-up tasks

* systemd: add before dependency to early mounts for local-fs.target

So dependencies are the same as when mounting in /snap, as that is
where we will do also the early mounts now.

* kernel: use normal mount points when building drivers tree

* overlord/devicestate: no need to remove early mount anymore

* overlord/snapstate: consider kernel type when ensuring the mounts

* kernel: put modules back in "updates" folder

As that gives priority to the kernel modules under that directory (see
depmod.d(5)).
2024-04-12 16:00:19 +02:00
Zeyad Yasser
b3c05c968f cmd/snap: record snap-run-inhibit notice (#13770)
* cmd/snap: record snap-run-inhibit notice

Record a snap-run-inhibit notice when snap run is inhibited due refresh.

* cmd/snap: remove old desktop notifications (thanks @pedronis @zyga)
* cmd/snap: always send notices when snap run is inhibited
	+ fallback to text if no snap has the marker snap-refresh-observe
	interface connected and a terminal is detected.
* cmd/snap: send text fallback notification to stderr (thanks @bboozzoo)
* cmd/snap: initialize inhibition flow only when it is needed

Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>

* tests/main: add test for snap run inhibition flows

* test/main/snap-run-inhibition-flow: remove text fallback check
	Text fallback is inconsistent across systems due to the terminal
	checks in snapd. It is hard to mock a real terminal in all systems
	while redirecting output to a file for testing.

Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>

---------

Signed-off-by: Zeyad Gouda <zeyad.gouda@canonical.com>
2024-04-12 14:58:44 +02:00