Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions plugin/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"net/http"
"os"
"path/filepath"
"strings"
"testing"

nriNet "github.com/containerd/nri/pkg/net"
Expand Down Expand Up @@ -58,8 +59,13 @@ func Test_newCfgForManualLaunch(t *testing.T) {
os.Args = []string{"test-plugin"}
t.Setenv("XDG_RUNTIME_DIR", os.TempDir())
socketPath := api.DaemonSocketPath()
os.Remove(socketPath)
require.NoError(t, os.MkdirAll(filepath.Dir(socketPath), 0o755))
// Abstract sockets (leading "@", Linux) live in the abstract
// namespace, not on the filesystem, so they need no directory
// and leave nothing to clean up.
if !strings.HasPrefix(socketPath, "@") {
os.Remove(socketPath)
require.NoError(t, os.MkdirAll(filepath.Dir(socketPath), 0o755))
}
listener, err := net.Listen("unix", socketPath)
if err != nil {
t.Fatalf("listen failed: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion x/api/defaults_unix.go → x/api/defaults_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !windows
//go:build darwin

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[LOW] Platform coverage gap: non-darwin/non-linux Unix platforms have no DaemonSocketPath() implementation

The original defaults_unix.go used //go:build !windows, which implicitly covered FreeBSD, OpenBSD, illumos, and any other non-Windows platform. This PR replaces it with two explicitly-tagged files (darwin and linux), leaving every other Unix-like OS without an implementation of DaemonSocketPath() — the package would fail to compile on those platforms.

In practice, docker/secrets-engine targets Linux and macOS (darwin), so this is theoretical rather than immediately harmful. However, the narrowing of platform coverage introduces a latent regression relative to the prior code with no documented rationale for the exclusion.

If intentional, consider adding a comment to defaults_darwin.go (or a new defaults_unix_other.go with //go:build !linux && !windows && !darwin) explaining the scope decision, so future contributors understand why FreeBSD etc. are not supported.


package api

Expand Down
35 changes: 35 additions & 0 deletions x/api/defaults_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright 2025-2026 Docker, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build linux

package api

import (
"fmt"
"os"
)

// DaemonSocketPath returns the address of the daemon's listening socket.
//
// On Linux it is an abstract Unix domain socket: the address has a leading
// "@", which Go's net package maps to a NUL byte, placing the socket in the
// abstract namespace instead of on the filesystem.
//
// The address is namespaced by the user's UID so daemons run by different
// users on the same host do not collide (the abstract namespace is shared per
// network namespace, not per user as a filesystem path would be).
func DaemonSocketPath() string {
return fmt.Sprintf("@docker-secrets-engine/%d/daemon.sock", os.Getuid())
}
Loading