can't mkdir SNAP_USER_COMMON directory

Bug #1611063 reported by Chris J Arges
44
This bug affects 9 people
Affects Status Importance Assigned to Milestone
Snappy
Fix Released
Undecided
Unassigned
snapd (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

In my snap I would like to use the SNAP_USER_COMMON directory in order to persist data across versions. I've observed this both for a snap that executes as a normal user and one that executes as root (daemon).

Test case:
git clone https://gist.github.com/arges/0e31fae032d3d57c5031339e13e81ede

$ make-it-so

mkdir: cannot create directory '/home/arges/snap/make-it-so/common': Permission denied
touch: cannot touch '/home/arges/snap/make-it-so/common/canttouchit': No such file or directory

$ dmesg | tail

[14090.089664] audit: type=1400 audit(1470677502.367:131): apparmor="DENIED" operation="mkdir" profile="snap.make-it-so.make-it-so" name="/home/arges/snap/make-it-so/common/" pid=4061 comm="mkdir" requested_mask="c" denied_mask="c" fsuid=1000 ouid=1000

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Note that snapd should be creating this directory for you and you shouldn't have to create it yourself.

tags: added: snapd-interface
Revision history for this message
Bruno Nova (brunonova) wrote :

Yes, the problem is probably that the launcher script in /snap/bin/ doesn't create that directory.
Maybe the description of the bug should be changed?

The launcher scripts needs to include these lines, I think:
if [ ! -d "$SNAP_USER_COMMON" ]; then
   mkdir -p "$SNAP_USER_COMMON"
fi

Changed in snappy:
status: New → Confirmed
Changed in snapd (Ubuntu):
status: New → Confirmed
Revision history for this message
Eldar Khayrullin (eldar) wrote :

To brunonova, your methode shows perm denied:
mkdir: cannot create directory '/home/user/snap/my-snap/common': Permission denied

Revision history for this message
Eldar Khayrullin (eldar) wrote :

The temporary solve:
$ snap run my-snap
This cmd create COMMON directory (Needs to ignore errors of prev cmd).

Revision history for this message
Bruno Nova (brunonova) wrote :

@Eldar, I was talking about the launcher scripts created in "/snap/bin/" by snapd itself during "snap install", not about scripts bundled with the snap.

As users, we can create the "common" directory manually.
But, as developers/packagers, we can't do much.

Revision history for this message
Eldar Khayrullin (eldar) wrote :

@Bruno, Ok, I'm agree with you.

Revision history for this message
Kyle Fazzari (kyrofa) wrote :

Note that this issue will be resolved as soon as `snap run` is used to launch apps (it's what has the logic to create this directory). That will be released soon!

Changed in snapd (Ubuntu):
status: Confirmed → Triaged
Changed in snappy:
status: Confirmed → Triaged
Revision history for this message
Michael Vogt (mvo) wrote :

We use `snap run` now and this will create the dir with the right permissions automatically

Changed in snapd (Ubuntu):
status: Triaged → Fix Released
Changed in snappy:
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.