There's something weird about /tmp

Bug #1646968 reported by Barry Warsaw
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Ubuntu Image
Fix Released
High
Barry Warsaw
snapd
Won't Fix
Undecided
Unassigned

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 builder.py'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.

Revision history for this message
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
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

The /tmp directory is private for each snap. Have a look at http://www.zygoon.pl/2016/08/snap-execution-environment.html for more details

Revision history for this message
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
Revision history for this message
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)
Changed in ubuntu-image:
status: New → In Progress
importance: Undecided → High
assignee: nobody → Barry Warsaw (barry)
Barry Warsaw (barry)
Changed in ubuntu-image:
status: In Progress → Fix Committed
Barry Warsaw (barry)
Changed in ubuntu-image:
status: Fix Committed → Fix Released
Revision history for this message
Zygmunt Krynicki (zyga) wrote :

There's no magic way to know which directories might be problematic. I'm not sure what to do with the bug but for the purpose of venting the attic I'm marking it as won't fix.

Changed in snappy:
status: New → Won't Fix
affects: snappy → snapd
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.