Hi,
I’m trying to use the new layouts feature for a snap to bind mount something on top of $SNAP_DATA, however I’m having some trouble getting it set up as it seems the mount isn’t performed.
I have the following reproducer source:
name: layouts-snap-data-test
version: '0.1'
summary: Test of snapd
description: layouts test with $SNAP_DATA
grade: stable
confinement: strict
apps:
layouts-snap-data-test:
command: ls -lah /etc/mything
passthrough:
layouts:
/etc/mything:
bind: $SNAP_DATA/etc/mything
parts:
my-part:
plugin: nil
And when I build and install this snap, I’m not able to access /etc/mything
. I presume this has to do with the directory $SNAP_DATA/etc/mything
not existing when the mount profile is setup for the snap, as this is run before anything else, and so upon initial install, there’s nothing inside $SNAP_DATA
when the mounts run, and bind mounts to my knowledge don’t work if both the source and target directory don’t exist.
If that is the case, what’s the expected remedy here for using layouts with the bind method to paths not inside $SNAP (which are guaranteed to exist)? Should layouts setup a task to create that directory/file? Another option could be to not create the directory when the initial mount namespace is setup, but then let any hooks run that need to, then finally before finishing the install/refresh check if the layouts need to be run again. This would give at least the install
, and post-refresh
hooks a chance to create the necessary files for the bind mount to succeed.
Also, I tried the above snap with an install hook like this to no avail:
#!/bin/bash -e
mkdir -p $SNAP_DATA/etc/mything
Ping @zyga-snapd