63 Commits

Author SHA1 Message Date
Samuele Pedroni
d1b236a676 interfaces/systemd: fix typos
thanks @anonymouse64
2021-07-16 18:10:25 +02:00
Samuele Pedroni
d6dfd88a0c interfaces/systemd: service name uniqueness across snaps is implicit
add comment to clarify this
2021-07-16 16:29:45 +02:00
Samuele Pedroni
02121299a5 interfaces: s/affix/suffix/
it makes sense anyway and is simpler. Thanks @jhenstridge

also bump the copyrights
2021-07-16 16:27:37 +02:00
Samuele Pedroni
3562d23173 interfaces/systemd: fix typo
thanks @mardy
2021-07-16 15:59:17 +02:00
Samuele Pedroni
73c26e8567 interfaces/systemd: slightly more informative clashing def internal errors
track which interface we are operating on to allow for this
2021-07-09 18:47:12 +02:00
Samuele Pedroni
1e9efcdb90 interfaces: make the service naming entirely internal to systemd BE
this is somewhat simpler for the callers and more consistent because
the systemd backend needs to control the naming pattern to allow
update/removal anyway
2021-07-09 18:47:12 +02:00
Samuele Pedroni
f2cdb6dd92 asserts,interfaces,snap: fix imports order (according to gci) 2021-06-14 20:54:41 +02:00
Paweł Stołowski
324526359e Use systemd.New() in interfaces/systemd backend. Special-case Remove when preseeding (not a viable scenario, but added for completness). 2020-09-21 14:31:15 +02:00
Paweł Stołowski
d86b53cc47 Provide new constructor for systemd that omits rootDir and rename existing one to NewUnderRoot. 2020-09-03 12:42:36 +02:00
Zygmunt Krynicki
b2ad5e393a interfaces/systemd: compare dereferenced Service
The systemd backend is relatively unique, as it is only used by one
interface. The GPIO interface uses it to create systemd units which
export GPIOs from kernel / firmware to userspace and back.

The specification system for the systemd backend is comprised of named
services. The code allows for repeated generation of identical services,
sharing the same name, that are coalesced as long as their definitions
are identical.

Based on a customer report, we found a mistake in how this coalescing
was performed. The code performed pointer comparison, not object
equality comparison. This patch fixes this issue, adds unit tests
checking that case and improves the diagnostic error message to simplify
debugging in the future.

Fixes: https://bugs.launchpad.net/tillamook/+bug/1892804
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2020-08-26 20:03:33 +02:00
Zygmunt Krynicki
8072f1c9f7 interfaces: check !b.preseed earlier
This is a small stylistic change that doesn't impact semantics. Since
the pre-seed mode of fundamental importance I'd prefer if the condition
checking it was the earlier in the line, not at the very end.

Signed-off-by: Zygmunt Krynicki <me@zygoon.pl>
2020-08-07 13:44:17 +02:00
Paweł Stołowski
e1df8047fb Use emulation mode and skip daemon-reload / starting / stopping of services in systemd security backend if preseeding. 2020-08-06 11:26:41 +02:00
Pawel Stolowski
befb1a6e74 Pass unnamed interfaces.SecurityBackendOptions argument to Initialize for backends that don't use it. 2020-02-19 09:33:24 +01:00
Pawel Stolowski
b87345b8bb Introduce interfaces.SecurityBackendOptions for passing Preseed mode flag to backends via Initialize(). Change maybeRestart to a method of snap manager. 2020-02-18 10:43:41 +01:00
Zygmunt Krynicki
ac1589cf7f osutil: rename MemoryBlob -> MemoryFileState
Signed-off-by: Zygmunt Krynicki <me@zygoon.pl>
2019-09-27 18:32:36 +02:00
Zygmunt Krynicki
7876ce6f1e osutil: generalize SyncDir with FileState interface
The directory synchronization code grew out of the desire to have a set
of files described by a glob and short, in-memory contents be reflected
to the disk in an efficient and predictable way.

Recently this code has started to be used to install icon themes shipped
by snaps. This means it may be used to coerce snapd to read arbitrary
amount of data into memory.

This address this issue by generalizing the directory sync APIs to take
an interface instead of a concrete representation of the desired file.

There are now three concrete implementations, one that keeps the content
in memory, just like before, called MemoryBlob and two new ones:
FileReference and FileContentReference. Those both refer to an existing
file for content, opening up the possibility to refer to large files.
They only differ in the treatment of file mode, either mirroring the
mode of the file being referred or using a fixed mode, respectively.

Behind the scenes the EnsureFileState function will no longer read all
of the file into memory. Instead if will use FileReference to stream it,
chunk by chunk, in an attempt to see if the file is identical to what we
expected.

On top of that, if the file is not the same and the caller has provided
a FileReference or FileContentReference, the logic that writes a new
file and replaces the original is also using streaming, again saving a
in-memory copy.

This way we can now process files of arbitrary size using fixed amount
of memory. This involves the new icon wrapper which has been switched to
use FileContentReference.

The patch contains some verbose automatic changes around the code using
maps of FileState structure to replace them with maps of FileState
interface instead.

Signed-off-by: Zygmunt Krynicki <me@zygoon.pl>
2019-09-27 13:46:33 +02:00
James Henstridge
54e91e2a2d systemd: add support for controlling different systemd instances 2019-06-25 10:36:33 +08:00
Pawel Stolowski
3d42db9d0c Measurement -> Measurer 2019-03-13 17:19:35 +01:00
Pawel Stolowski
721196b56a Introduce an interface for Span/Timings. 2019-03-13 16:41:12 +01:00
Pawel Stolowski
a5bf6c84e4 Renaming. 2019-03-11 18:03:37 +01:00
Pawel Stolowski
79f3d87b42 Basic timings in interface manager. 2019-03-11 14:16:40 +01:00
Maciej Borzecki
0d78818222 interfaces: take instance name in ifacetest.InstallSnap (#5749) 2018-09-03 21:45:47 +01:00
Maciej Borzecki
ff216577f3 many: rename snap.Info.Name() to snap.Info.InstanceName(), leave parallel-install TODOs
In preparation for parallel installation of snaps, introduce the necessary
rename of snap.Info.Name() to snap.Info.InstanceName(). The change is benign and
will make subsequent parallel installs reviews easier and smaller.

Leave TODO notes about possible issues with parallel installation where
possible.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
2018-06-13 12:23:44 +02:00
Zygmunt Krynicki
7d95441dd4 many: add "snap debug sandbox-features" and needed bits (#5142)
* many: add "snap debug sandbox" and needed bits

This patch adds a way to inspect the features of the sandbox from a new
hidden, debugging command. The command shows a set of tags for each of
the security backends that are in use.

Having access to this command helps in two ways:

First of all, this is far more comprehensive and informative than the
very dry "partial" vs "full" output of "snap debug confinement". Snapd
offers a wide range of confinement technologies when used on a mainline
kernel and this should be celebrated.

Second of all having this allows us to write more precise tests. If a
test needs to be skipped because a specific thing is absent can now be
codified directly. This will allow both Debian and openSUSE to run far
more confinement-specific tests than we currently do simply because
"partial" apparmor is reported. Mainline kernel is very close to full
apparmor patch used by Ubuntu and the remaining differences don't apply
to many existing tests.

Technically this patch adds the key "sandbox", defined as a map of lists
of strings, to the sysinfo API and uses it in the new hidden command.
Each of the security backends can now optionally offer sandbox tags that
are associated with the backend name in the said map.

* interfaces: namespace kernel features with "kernel:"

This arrangement will allow the seccomp and apparmor backends to report
additional sandbox feature tags without risking any clash with kernel
reported things.

* interfaces/seccomp: return at least one sandbox tag from seccomp

In case the kernel doesn't advertise seccomp kernel features we don't
want to make the seccomp backend appear as missing or unused. Add an
explicitly managed tag to achieve that.

* interfaces/apparmor: dbus mediates more than just bus names

* many: rename sandbox tags to sandbox features

* cmd/snap: add support for "sandbox-features --required=..."

This patch allows using the sandbox-features command for simple
scripting, especially in spread tests, where we could check if a given
sandbox feature is present before checking confinement is effective.

* tests: fix and expand sandbox-features tests

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2018-05-14 20:08:27 +02:00
Pawel Stolowski
4895a11b5d Merge branch 'master' into ifaces-use-connected-types
Signed-off-by: Pawel Stolowski <stolowski@gmail.com>
2017-11-16 17:37:48 +01:00