diff options
author | Fabricio Voznika <fvoznika@google.com> | 2018-08-24 10:16:38 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-08-24 10:17:42 -0700 |
commit | a81a4402a265aec6715172cd3502ee7eebbf64aa (patch) | |
tree | ca68f0086761e850760931820f3dd34d9affd764 /runsc/cmd | |
parent | 64403265a04aa0c8be3ebb652a09f6e2d7a84ca7 (diff) |
Add option to panic gofer if writes are attempted over RO mounts
This is used when '--overlay=true' to guarantee writes are not sent to gofer.
PiperOrigin-RevId: 210116288
Change-Id: I7616008c4c0e8d3668e07a205207f46e2144bf30
Diffstat (limited to 'runsc/cmd')
-rw-r--r-- | runsc/cmd/gofer.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/runsc/cmd/gofer.go b/runsc/cmd/gofer.go index ed4b1d29c..e23f64d12 100644 --- a/runsc/cmd/gofer.go +++ b/runsc/cmd/gofer.go @@ -38,6 +38,8 @@ type Gofer struct { // controllerFD is the file descriptor of a stream socket for the // control server that is donated to this process. controllerFD int + + panicOnWrite bool } // Name implements subcommands.Command. @@ -61,6 +63,7 @@ func (g *Gofer) SetFlags(f *flag.FlagSet) { f.Var(&g.ioFDs, "io-fds", "list of FDs to connect 9P servers. They must follow this order: root first, then mounts as defined in the spec") f.BoolVar(&g.applyCaps, "apply-caps", true, "if true, apply capabilities to restrict what the Gofer process can do") f.IntVar(&g.controllerFD, "controller-fd", -1, "required FD of a stream socket for the control server that must be donated to this process") + f.BoolVar(&g.panicOnWrite, "panic-on-write", false, "if true, panics on attempts to write to RO mounts. RW mounts are unnaffected") } // Execute implements subcommands.Command. @@ -110,7 +113,8 @@ func (g *Gofer) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) ats := make([]p9.Attacher, 0, len(spec.Mounts)+1) p := absPath(g.bundleDir, spec.Root.Path) ats = append(ats, fsgofer.NewAttachPoint(p, fsgofer.Config{ - ROMount: spec.Root.Readonly, + ROMount: spec.Root.Readonly, + PanicOnWrite: g.panicOnWrite, // Docker uses overlay2 by default for the root mount, and overlay2 does a copy-up when // each file is opened as writable. Thus, we open files lazily to avoid copy-up. LazyOpenForWrite: true, @@ -123,6 +127,7 @@ func (g *Gofer) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) p = absPath(g.bundleDir, m.Source) ats = append(ats, fsgofer.NewAttachPoint(p, fsgofer.Config{ ROMount: isReadonlyMount(m.Options), + PanicOnWrite: g.panicOnWrite, LazyOpenForWrite: false, })) |