diff options
author | Fabricio Voznika <fvoznika@google.com> | 2018-11-01 17:51:22 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-11-01 17:52:11 -0700 |
commit | 5cd55cd90fd5a32685807a57617cde6f5f76d22b (patch) | |
tree | 626eaac23c76d63ef1917bb7e3e51fb618d20f7e /runsc/cmd/gofer.go | |
parent | b6b81fd04ba93db3268ff649c9d23a25c9b89db5 (diff) |
Use spec with clean paths for gofer
Otherwise the gofer's attach point may be different from sandbox when there
symlinks in the path.
PiperOrigin-RevId: 219730492
Change-Id: Ia9c4c2d16228c6a1a9e790e0cb673fd881003fe1
Diffstat (limited to 'runsc/cmd/gofer.go')
-rw-r--r-- | runsc/cmd/gofer.go | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/runsc/cmd/gofer.go b/runsc/cmd/gofer.go index 7cc666e10..4ec3dba9c 100644 --- a/runsc/cmd/gofer.go +++ b/runsc/cmd/gofer.go @@ -99,7 +99,12 @@ func (g *Gofer) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) panic("unreachable") } - spec, err := specutils.ReadSpec(g.bundleDir) + specFile, err := specutils.OpenCleanSpec(g.bundleDir) + if err != nil { + Fatalf("error opening spec: %v", err) + } + spec, err := specutils.ReadSpecFromFile(g.bundleDir, specFile) + specFile.Close() if err != nil { Fatalf("error reading spec: %v", err) } @@ -121,10 +126,14 @@ func (g *Gofer) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) // Start with root mount, then add any other additional mount as needed. ats := make([]p9.Attacher, 0, len(spec.Mounts)+1) - ats = append(ats, fsgofer.NewAttachPoint("/", fsgofer.Config{ + ap, err := fsgofer.NewAttachPoint("/", fsgofer.Config{ ROMount: spec.Root.Readonly, PanicOnWrite: g.panicOnWrite, - })) + }) + if err != nil { + Fatalf("Error creating attach point: %v", err) + } + ats = append(ats, ap) log.Infof("Serving %q mapped to %q on FD %d (ro: %t)", "/", root, g.ioFDs[0], spec.Root.Readonly) mountIdx := 1 // first one is the root @@ -134,7 +143,11 @@ func (g *Gofer) Execute(_ context.Context, f *flag.FlagSet, args ...interface{}) ROMount: isReadonlyMount(m.Options), PanicOnWrite: g.panicOnWrite, } - ats = append(ats, fsgofer.NewAttachPoint(m.Destination, cfg)) + ap, err := fsgofer.NewAttachPoint(m.Destination, cfg) + if err != nil { + Fatalf("Error creating attach point: %v", err) + } + ats = append(ats, ap) if mountIdx >= len(g.ioFDs) { Fatalf("No FD found for mount. Did you forget --io-fd? mount: %d, %v", len(g.ioFDs), m) |