Skip to content

Commit e1eaba4

Browse files
committed
Use relative path for vm state directory
Prevents socket paths becoming too long when the resolved current working directory differs from the given bundle path, for example current working directory resolving to `/private/var/...` but the bundle directory reported as `/var/...`. The vm state directory does not need to be associated with a specific bundle and the working directory assigned to the shim is sufficient as the parent for the vm state directory. Signed-off-by: Derek McGowan <derek@mcg.dev>
1 parent 6f02159 commit e1eaba4

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

internal/shim/task/service.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,12 @@ func (s *service) Create(ctx context.Context, r *taskAPI.CreateTaskRequest) (_ *
207207
}
208208
b.AddExtraFile(nwcfg.Filename, nwJSON)
209209

210-
vmState := filepath.Join(r.Bundle, "vm")
211-
if err := os.Mkdir(vmState, 0700); err != nil {
210+
// vmState directory should be a path under the current working directory, not specific to a single bundle
211+
vmState, err := filepath.Abs("vm")
212+
if err != nil {
213+
return nil, errgrpc.ToGRPCf(err, "failed to get absolute path for vm state directory")
214+
}
215+
if err := os.MkdirAll(vmState, 0700); err != nil {
212216
return nil, errgrpc.ToGRPCf(err, "failed to create vm state directory %q", vmState)
213217
}
214218
vmi, err := s.vmInstance(ctx, vmState)

0 commit comments

Comments
 (0)