Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
snap: add support for parsing snap layout section #3636
Conversation
zyga
requested a review
from
niemeyer
Aug 3, 2017
codecov-io
commented
Aug 3, 2017
•
Codecov Report
@@ Coverage Diff @@
## master #3636 +/- ##
==========================================
+ Coverage 75.32% 75.36% +0.03%
==========================================
Files 389 389
Lines 33666 33748 +82
==========================================
+ Hits 25359 25434 +75
- Misses 6489 6494 +5
- Partials 1818 1820 +2
Continue to review full report at Codecov.
|
zyga
requested a review
from
mvo5
Aug 4, 2017
mvo5
approved these changes
Aug 7, 2017
Code looks good from my POV, I had a hunch that VlidatePathVariables() could be written in a simpler way but I played around a bit and my version was not easier to read so my hunch was probably wrong.
| + for path, l := range y.Layout { | ||
| + mode := 0755 | ||
| + if l.Mode != "" { | ||
| + m, err := strconv.ParseInt(l.Mode, 8, 32) |
chipaca
Aug 7, 2017
Member
mode_t is unsigned, and os.FileMode is a uint32; math.MaxUint32 is a valid os.FileMode, and would fail to parse here. But also, os.ModeDir, a constant pre-defined probably-not-that-rare file mode, is not a valid int32.
zyga
Aug 8, 2017
Contributor
Ah, I didn't notice that the parsing function is incorrect too. Thank you!
| @@ -170,3 +177,73 @@ func ValidateApp(app *AppInfo) error { | ||
| } | ||
| return nil | ||
| } | ||
| + | ||
| +// ValidatePathVariables ensures that given path contains only $SNAP, $SNAP_DATA or $SNAP_COMMON. |
chipaca
Aug 7, 2017
Member
interesting that we don't support having a $ that isn't interpolating a variable (i.e., no \$)
| + } | ||
| + return nil | ||
| +} | ||
| + |
zyga commentedJul 31, 2017
The layout section defines the "shape" of the runtime mount namespace
of a given snap. Layout is entirely optional and is empty by default.
Tree kind of layout entries can be defind:
In addition, all kinds can use the "user", "group" and "mode" fields
to define the ownership and permissions of any parent directories that
may need to be created. At present those are limited to "root", "nobody"
and at most "0755" permissions.
Any path designators can expand the following environment variables:
$SNAP, $SNAP_DATA and $SNAP_COMMON.
Forum: https://forum.snapcraft.io/t/feature-snap-layouts/1471
Signed-off-by: Zygmunt Krynicki zygmunt.krynicki@canonical.com