8 Commits

Author SHA1 Message Date
Andrew Phelps
277fbc266e many: add components to interfaces.SnapAppSet (#13837) 2024-05-07 09:53:59 -04:00
Valentin David
8a0b9b2dcf 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 01:33:15 +02:00
Andrew Phelps
d8a2e847e5 many: introduce SnapAppSet for use in security backends (#13574)
* interfaces: introduce SnapAppSet and forward one to the security backends

* snap: implement methods on snap.Info for getting apps and hooks for slots and plugs

This will enable us to remove the Hooks fields from the SlotInfo and
PlugInfo structs.

* interfaces: implement methods on SnapAppSet in terms of methods on snap.Info

* snap, interfaces: replace usage of {Plug,Slot}Info.SecurityTags with methods on SnapAppSet

* i/builtin: replace slotAppLabelExpr and plugAppLabelExpr with corresponding methods on SnapAppSet

* snap, o/snapstate, interfaces: remove Hooks field on snap.PlugInfo and snap.SlotInfo

* builtin, interfaces: fix tests that use Specification that now have a SnapAppSet

* snap: add tests for new methods on Info

* interfaces, i/builtin: port over some tests for SnapAppSet methods {Plug,Slot}LabelExpression

* interfaces: test PlugSecurityTags and SlotSecurityTags methods

* interfaces: add doc comments to SnapAppSet and methods

* i/builtin: remove ported over tests

* interfaces, many: require that SnapAppSet methods for getting security tags are called with plug/slot that comes from correct snap

Many tests did not properly adhere to this requirment, so they had to be
modifed to modify this rule.

Additionally, a hack was inroduced in the methods for getting label
expressions on the SnapAppSet. If a plug/slot did not originate from the
same snap that the SnapAppSet was created from, then we will use the
snap.Info that the plug/slot carries in the method instead. This will
fail to work once component hooks are introduced, so this will need to
be resolved by then.

* interfaces: test fallback for using LabelExpr methods with mismatch plug/slot

* snap: correct placement of TODOs to preserve doc comments

* snap: add doc comments for Plug/Slot.Unscoped

* interfaces: test for using SecurityTagsForPlug and SecurityTagsForSlot with wrong snap

* interfaces: tweak error messages in SnapAppSet SecurityTags methods

* i/builtin: fix missed conflict

* i/apparmor: add doc comment to Specification.appSet

* snap: fix doc coment on PlugInfo.Unscoped
2024-02-19 11:57:42 +01:00
Valentin David
904b283191 cmd/snap-device-helper: do not read sysfs directly
udev does that for us and provides all the information we need even
for a delete event. So we can know if a device is a block without
guessing.
2024-02-12 08:45:59 +01:00
Valentin David
4f2d107db1 interfaces/udev: do not tag modules
Module loading generates event for devpath /module/<nameofmodule>.
Some modules and devices have the same KERNEL name. For example
rfkill. We need to ignore module insertions. Otherwise we get
error message when trying to run snap-device-helper.
2023-06-15 15:21:15 +02:00
Valentin David
32cf925deb i/b/dm_crypt: add missing permissions
Give lock permission to /dev/dm-*. Also allow to create
/run/cryptsetup.
2023-03-28 12:42:11 +02:00
Buğra Aydoğar
f3966b24b3 interfaces: allow access to the file locking mechanism for cryptosetup 2022-05-16 16:36:58 +03:00
Ondrej
fbb7adad0d interfaces: builtin: add dm-crypt interface to support external storage encryption
* interfaces: builtin: add dm-crypt interface

dm-crypt interface allows handling of dm-crypt devices
- setting up luks partition
- locking/unlocking of dm-crypt partition
- adding key(s) to kernel keyring
- formatting of encrypted partition(s) ( creation of fs)
- mounting of encrypted partition(s)

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* interfaces: builtin: add tests for dm-crypt interface

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* interfaces: builtin: dm-crypt: update summary

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* interfaces: builtin: dm-crypt: make udev rules more strict dm[0-9]->dm-[0-9]

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* interfaces: builtin: dm-crypt: fix typo and description

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* interfaces/tee: add dm-crypt interface

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* interfaces/builtin: update basedeclaration_test for dm-crypt interface

Signed-off-by: Ondrej Kubik <ondrej.kubik@canonical.com>

* interfaces: run `go fmt` on basedeclaration_test.go

* interfaces: add XXX comment about hardcoded mount points in dm-crypt interface

Co-authored-by: Michael Vogt <mvo@ubuntu.com>
2021-06-10 17:32:13 +02:00