There's something weird about /tmp

Bug #1646968 reported by Barry Warsaw on 2016-12-02
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu Image
Barry Warsaw

Bug Description

I'm noticing a problem with the ubuntu-image snap which needs more investigation. I don't have time for that right now, so filing this bug for later.

If you install the ubuntu-image snap and run

$ ubuntu-image -o /tmp/ui.img -c edge -d pc-amd64-model.assertion

everything completes successfully, but there will be no /tmp/ui.img file. However if you use something like `-o /home/me/ui.img` then the file *will* end up in /home/me. I suspect that snapd is doing Something Funny with /tmp even though u-i is --devmode. So the /tmp you think you're using at the command line is not the /tmp that the snap sees.

Further, if you drop into pdb right at's finish() method, you can see that the workdir is /tmp/blah but that doesn't exist outside the snap, so again, I suspect it's a bind mounted directory or some such.

If we can't change this behavior in the snap, we'll need a way to detect it and warn the user.

Steve Langasek (vorlon) wrote :

This is expected behavior of a snap. The 'home' interface gives the snap visibility on the /home heirarchy as a bind mount; it does not give it access to the /tmp directory of the host system. So the output path is interpreted relative to the snap's container mountpoint only.

The fix for this requires the planned 'classic' mode, which is not yet implemented in snapd.

Changed in ubuntu-image:
milestone: 0.13 → none
Zygmunt Krynicki (zyga) wrote :

The /tmp directory is private for each snap. Have a look at for more details

Barry Warsaw (barry) wrote :

While we wait for classic mode, we should check the env for any $SNAP* environment variable[1] and warn if the directory starts with /tmp[2].

[1] Is this the best way to tell whether the code is running as a snap or as a classic deb?

[2] Are there any other paths that might also give users unexpected behavior?

Changed in ubuntu-image:
milestone: none → 0.13
Barry Warsaw (barry) wrote :

@zyga: Thanks for the link. Is there a dynamic way to calculate which directories might be problematic? From the article and appendix, I think we might also want to warn on /var/tmp though this will probably be less likely.

Barry Warsaw (barry) on 2016-12-08
Changed in ubuntu-image:
status: New → In Progress
importance: Undecided → High
assignee: nobody → Barry Warsaw (barry)
Barry Warsaw (barry) on 2016-12-08
Changed in ubuntu-image:
status: In Progress → Fix Committed
Barry Warsaw (barry) on 2017-01-09
Changed in ubuntu-image:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers