Snaps can not write to /run by default

The topic was originally discussed on IRC in context for the livepatch snap which currently write a status file under /var/snapd/canonical-livepatch/current. The file/status is only valid until reboot so it would make more sense to have into under /run (it’s easier/better than having custom code to clean out the file on boot).

One suggested solution on IRC/#snappy was to maybe let snap access /run/snap.$SNAP_NAME by default. Having a custom /run space allowed by default can be useful.

Wdyt? (also reported on launchpad as https://bugs.launchpad.net/snapd/+bug/1802112)

we already have XDG_RUNTIME_DIR set by default in every snap, pointing to /run/user/<uid>/snap.<appname> (uid being 0 indeed for all daemon snaps)… i’m not sure if that dir is created for daemon snaps by default though … you might need a mkdir -p $XDG_RUNTIME_DIR in some wrapper script to create it first.

1 Like

I have now proposed https://github.com/snapcore/snapd/pull/6109