26 Commits

Author SHA1 Message Date
Valentin David
c827e52caf many: use snapd.mounts targets to schedule mount units
`snapd.mounts-pre.target` will be before any mount unit,
`snapd.mounts.target`.  Now we can schedule before or after mounts
without needing to modify the mount units.

We also install those mounts to `snapd.mounts.target` so that we can
make snapd.service for example, "want" all mounts.
2022-10-20 14:49:21 +02:00
Alberto Mardegan
9ba87a56c0 data/systemd/Makefile: add comment warning about "snapd." prefix
I've been hit by this working on abranch where I was adding my own
service. Thanks @mvo5 for the time-saver hint!
2022-08-31 12:04:55 +03:00
Michael Vogt
946a7c3913 rename snapd.manager -> snapd.run-from-snap 2018-06-05 19:28:58 +02:00
Michael Vogt
5db282d81c address review feedback 2018-06-05 18:20:15 +02:00
Michael Vogt
843d77072a address review feedback 2018-06-05 11:58:36 +02:00
Michael Vogt
1ab0f4c791 Merge remote-tracking branch 'upstream/master' into snapd-manage-for-bases 2018-06-05 09:49:04 +02:00
Michael Vogt
6cb04a1d2e address review feedback 2018-05-30 11:03:51 +02:00
Michael Vogt
03bb87cf21 data: add helper that can generate/start/stop the snapd service
The snapd.manage script is the interface that the base snaps will
use to start/stop snapd when snapd is run from a base.

Putting the script inside snapd means that we can evolve it without
having to modify any of the bases that use it. If we e.g. use
more systemd units etc.

There will be a coresponding PR for core18 that will use this
script to launch snapd on boot.

Note that this is currently hard to (spread) test because our
current core already has a snapd.{socket,service}. However once
we can bootstrap a core18 system testing this will happen naturally.
2018-05-25 09:59:40 +02:00
Zygmunt Krynicki
e8c7893f54 data/systemd: add snapd.apparmor.service
This patch adds a new systemd service unit that loads apparmor profiles
on early machine boot-up. It is needed because there are no standardized
apparmor userspace tools that load profiles from
/var/lib/snapd/apparmor/profiles. On Ubuntu and Debian the init scripts
are patched to support this internally but, e.g. on openSUSE they do not.

In general distributions don't ship vanilla upstream init scripts and
until a future release that unifies distributions and makes the list of
profile-holding directories configurable we must do our own thing.

This was requested by jdstrand as an alternative to storing our profiles
in /etc/apparmor.d/.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2018-05-24 14:01:47 +02:00
Zygmunt Krynicki
5991293808 many: add the snapd-generator (#4797)
* many: add the snapd-generator

This patch removes the snap.mount (or var-lib-snapd-snap.mount) unit
and replaces it with a systemd generator that does creates such unit
dynamically at runtime, on early boot, when the system is running
without mount event sharing on the root filesystem.

This fixes a bug where if packaging ships the snap.mount unit and the
unit is stopped (even if it is not started) it would stop all the snap
mount units on the system, resulting in broken snaps.

Since the mount unit is no longer known to packaging it will not be
automatically stopped/started by generated maintainer scripts and thus
avoid the issue.
2018-03-09 11:04:46 +01:00
Zygmunt Krynicki
89d254511b data/systemd: tweak comment
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2018-01-30 08:25:11 +01:00
Zygmunt Krynicki
bd774c33f4 cmd/snap-update-ns: restore old behavior
This will make the release manager happy as we have less unknowns to
deal with. We can polish this by removing that fragment post release.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2018-01-29 22:49:22 +01:00
Zygmunt Krynicki
0d402b6030 data/systemd: use syntax compatible with old make
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2018-01-29 21:35:06 +01:00
Zygmunt Krynicki
3763e29b55 many: generate snap.mount unit name dynamically
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2018-01-29 19:35:57 +01:00
Zygmunt Krynicki
2c49b3edbc many: fix removal of snaps inside LXD
On LXD the root filesystem is not mounted with sharing of mount events
so we don't get propagation of mount and unmount events, as snaps get
added and removed, into persistent mount namespaces.

To work around this ship a snap.mount systemd unit that creates a
bind-mount at /snap and makes it shared. The unit is only active inside
LXD which is a high-priority target.

We may want to expand on this to other containers supported in the same
way but this will be in another patch. One of the existing tests that
checked for the sharing is now removed as it artificially broke what we
were doing, instead a new test, explicitly using LXD is added, that
doesn't do any magic manipulation and should be representative of
real-world use.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
2018-01-29 13:49:38 +01:00
John R. Lenton
67b6ba2483 Fix 14.04 (thank you spread), address review feedback (thank you mvo)
Also do some work to keep the diffs between 14.04 and 16.04 small.
2017-08-29 18:32:47 +01:00
Michael Vogt
e4eeecdf40 Add snapd.core-fixup.service unit
This unit will ensure we fix incorrect owner for some files and
directories on some Ubuntu Core devices.
2017-07-03 11:42:06 +01:00
Michael Vogt
70b7f3a164 add stub new snap-repair command and add timer 2017-05-23 11:34:19 +02:00
Michael Vogt
c3d85175d3 simplify further, thanks to zyga 2017-04-05 11:55:58 +02:00
Michael Vogt
1216ab2e3b tweak data/systemd/Makefile to be slightly simpler 2017-04-05 10:11:09 +02:00
Simon Fels
1a162709f1 data/systemd: integrate changes requested in review 2017-04-04 10:11:15 +02:00
Simon Fels
3dda15198e data/systemd: make install step dynamic too and add clean target 2017-04-04 07:33:25 +02:00
Simon Fels
9f331c183a data/systemd: abstract build code in our makefile a bit more 2017-04-03 12:36:58 +02:00
Simon Fels
f63c7bbbd2 data/systemd: add template for snapd.system-shutdown.service too 2017-03-29 13:45:51 +02:00
Simon Fels
3e2a80a6c5 data/systemd,packaging/debian: add install rule for all systemd units 2017-03-28 14:28:58 +02:00