-
Notifications
You must be signed in to change notification settings - Fork 16
Fix permission error creating socket directory for non-root instances #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -24,12 +24,14 @@ import ( | |||||
| "net" | ||||||
| "os" | ||||||
| "os/exec" | ||||||
| "path/filepath" | ||||||
| goruntime "runtime" | ||||||
| "strconv" | ||||||
| "syscall" | ||||||
| "time" | ||||||
|
|
||||||
| "github.com/containerd/containerd/api/types" | ||||||
| "github.com/containerd/containerd/v2/defaults" | ||||||
| "github.com/containerd/containerd/v2/pkg/namespaces" | ||||||
| "github.com/containerd/containerd/v2/pkg/shim" | ||||||
| "github.com/containerd/errdefs" | ||||||
|
|
@@ -129,8 +131,8 @@ func (s *shimSocket) Close() { | |||||
| _ = shim.RemoveSocket(s.addr) | ||||||
| } | ||||||
|
|
||||||
| func newShimSocket(ctx context.Context, path, id string, debug bool) (*shimSocket, error) { | ||||||
| address, err := shim.SocketAddress(ctx, path, id, debug) | ||||||
| func newShimSocket(ctx context.Context, root, path, id string, debug bool) (*shimSocket, error) { | ||||||
| address, err := shim.CreateSocketAddress(ctx, root, path, id, debug) | ||||||
| if err != nil { | ||||||
| return nil, err | ||||||
| } | ||||||
|
|
@@ -195,8 +197,11 @@ func (manager) Start(ctx context.Context, id string, opts shim.StartOpts) (_ shi | |||||
| } | ||||||
| } | ||||||
| }() | ||||||
|
|
||||||
| s, err := newShimSocket(ctx, opts.Address, grouping, false) | ||||||
| socketDir := opts.SocketDir | ||||||
| if socketDir == "" { | ||||||
| socketDir = filepath.Join(defaults.DefaultStateDir, "s") | ||||||
|
||||||
| socketDir = filepath.Join(defaults.DefaultStateDir, "s") | |
| return params, fmt.Errorf("shim socket directory must be specified in options (SocketDir)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The newShimSocket parameters
rootandpathare ambiguous in this context (withpathactually being the containerd address). Renaming them to something likesocketDirandcontainerdAddress(and updating call sites) would reduce the chance of future misuse, especially now that the function takes both values.