Pin devbox sockets before granting service ACLs (#486 A)
Address Task 5b review round 1: verify an O_PATH descriptor and grant through procfs so replacing a socket name cannot redirect the ACL write. Drop chmod; the ACL sets the final 0660 mode. Test direct symlink refusal and a swap between the check and grant without changing the target file. Correct bad-allow rendering and empty-login display, return the registrar sockets directory on path refusals, and mark superseded copy-deck rows. Root devbox/ACL tests, copy gates, registrar tests, Darwin build and vet pass.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9 files changed,
+209
−31
devbox_acl_linux.go+35 −2devbox_acl_linux_test.go+32 −2devbox_acl_other.go+12 −1devbox_cli.go+26 −12devbox_identity_cli_test.go+80 −8docs/superpowers/plans/2026-10-30-devbox-mode-copy.md+9 −0internal/devbox/registrar.go+6 −2internal/devbox/registrar_socket_linux_test.go+6 −2internal/devbox/registrar_test.go+3 −2
diff --git a/devbox_acl_linux.go b/devbox_acl_linux.go| index 621dac834..053f4244c 100644 |
| --- a/devbox_acl_linux.go |
| +++ b/devbox_acl_linux.go |
| @@ -5,15 +5,48 @@ package main |
| import ( |
| "encoding/binary" |
| "os" |
| + "runtime" |
| + "strconv" |
| "golang.org/x/sys/unix" |
| ) |
| +// Pin the inode before inspecting it: the service owns the sticky parent |
| +// directory and can replace either the socket or the directory itself. |
| +func openDevboxSocket(path string, uid int) (*os.File, error) { |
| + fd, err := unix.Open(path, unix.O_PATH|unix.O_NOFOLLOW|unix.O_CLOEXEC, 0) |
| + if err != nil { |
| + return nil, refuseWith(devboxNotASocket(path)) |
| + } |
| + var stat unix.Stat_t |
| + if err := unix.Fstat(fd, &stat); err != nil || stat.Mode&unix.S_IFMT != unix.S_IFSOCK { |
| + unix.Close(fd) |
| + return nil, refuseWith(devboxNotASocket(path)) |
| + } |
| + if int(stat.Uid) != uid { |
| + unix.Close(fd) |
| + return nil, refuseWith(devboxSocketNotYours(path)) |
| + } |
| + return os.NewFile(uintptr(fd), path), nil |
| +} |
| + |
| func grantServiceACL(path string, serviceUID uint32) error { |
| - if err := os.Chmod(path, 0o600); err != nil { |
| + socket, err := openDevboxSocket(path, os.Geteuid()) |
| + if err != nil { |
| return err |
| } |
| - return unix.Setxattr(path, "system.posix_acl_access", devboxServiceACL(serviceUID), 0) |
| + defer socket.Close() |
| + return grantDevboxSocketACL(socket, serviceUID) |
| +} |
| + |
| +// O_PATH fds cannot use Fsetxattr. Procfs resolves this descriptor to the |
| +// checked inode even if its original name has been removed or replaced. |
| +// The ACL itself sets owner/mask/other mode bits; no separate chmod is needed. |
| +func grantDevboxSocketACL(socket *os.File, serviceUID uint32) error { |
| + path := "/proc/self/fd/" + strconv.FormatUint(uint64(socket.Fd()), 10) |
| + err := unix.Setxattr(path, "system.posix_acl_access", devboxServiceACL(serviceUID), 0) |
| + runtime.KeepAlive(socket) |
| + return err |
| } |
| func devboxServiceACL(serviceUID uint32) []byte { |
diff --git a/devbox_acl_linux_test.go b/devbox_acl_linux_test.go| index 1de320bec..2a85d0c61 100644 |
| --- a/devbox_acl_linux_test.go |
| +++ b/devbox_acl_linux_test.go |
| @@ -55,8 +55,8 @@ func TestGrantServiceACLSocket(t *testing.T) { |
| err = grantServiceACL(path, uint32(os.Getuid())) |
| if errors.Is(err, unix.EOPNOTSUPP) || errors.Is(err, unix.ENOSYS) { |
| fi, statErr := os.Stat(path) |
| - if statErr != nil || fi.Mode().Perm() != 0o600 { |
| - t.Fatalf("unsupported ACL left permissions open: %v, %v", fi, statErr) |
| + if statErr != nil || fi.Mode().Perm() != 0o777 { |
| + t.Fatalf("unsupported ACL changed permissions: %v, %v", fi, statErr) |
| } |
| t.Skipf("socket ACL unsupported: %v", err) |
| } |
| @@ -103,3 +103,33 @@ func TestDevboxServiceUID(t *testing.T) { |
| t.Fatalf("default service UID = %d, %v; want %s", uid, err, want.Uid) |
| } |
| } |
| + |
| +func TestGrantServiceACLRefusesSymlink(t *testing.T) { |
| + dir := t.TempDir() |
| + target := filepath.Join(dir, "private") |
| + if err := os.WriteFile(target, []byte("private data"), 0600); err != nil { |
| + t.Fatal(err) |
| + } |
| + path := filepath.Join(dir, "tool.sock") |
| + if err := os.Symlink(target, path); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := grantServiceACL(path, uint32(os.Getuid())); err == nil { |
| + t.Error("granted ACL through a symlink") |
| + } |
| + assertDevboxACLTargetUntouched(t, target) |
| +} |
| + |
| +func assertDevboxACLTargetUntouched(t *testing.T, path string) { |
| + t.Helper() |
| + fi, err := os.Stat(path) |
| + if err != nil || fi.Mode().Perm() != 0600 { |
| + t.Errorf("target mode = %v, %v; want 0600", fi, err) |
| + } |
| + if data, err := os.ReadFile(path); err != nil || string(data) != "private data" { |
| + t.Errorf("target content = %q, %v", data, err) |
| + } |
| + if _, err := unix.Getxattr(path, "system.posix_acl_access", nil); !errors.Is(err, unix.ENODATA) { |
| + t.Errorf("target ACL changed: %v", err) |
| + } |
| +} |
diff --git a/devbox_acl_other.go b/devbox_acl_other.go| index ee744b687..89c508fbe 100644 |
| --- a/devbox_acl_other.go |
| +++ b/devbox_acl_other.go |
| @@ -2,8 +2,19 @@ |
| package main |
| -import "errors" |
| +import ( |
| + "errors" |
| + "os" |
| +) |
| func grantServiceACL(path string, serviceUID uint32) error { |
| return errors.ErrUnsupported |
| } |
| + |
| +func openDevboxSocket(path string, uid int) (*os.File, error) { |
| + return nil, errors.ErrUnsupported |
| +} |
| + |
| +func grantDevboxSocketACL(socket *os.File, serviceUID uint32) error { |
| + return errors.ErrUnsupported |
| +} |
diff --git a/devbox_cli.go b/devbox_cli.go| index 13fa2324e..9049ebbcc 100644 |
| --- a/devbox_cli.go |
| +++ b/devbox_cli.go |
| @@ -101,6 +101,14 @@ func devboxMissingServiceUser(user string) string { |
| func devboxBadAllow(login string) string { |
| return fmt.Sprintf("%s is not a tailnet login. give logins such as alice@github, separated by commas, with no spaces", login) // DBX-C106 |
| } |
| + |
| +// Quote an empty entry so C106 still has a visible subject. |
| +func devboxAllowLogin(login string) string { |
| + if login == "" { |
| + return strconv.Quote(login) |
| + } |
| + return login |
| +} |
| func devboxAllowedAccess(logins string) string { |
| return fmt.Sprintf("private: %s", logins) // DBX-C115 |
| } |
| @@ -227,11 +235,11 @@ type devboxCLI struct { |
| goos string |
| uid int |
| serviceUID func() (uint32, error) |
| - grantACL func(string, uint32) error |
| + grantACL func(*os.File, uint32) error |
| } |
| func newDevboxCLI(stdout, stderr io.Writer) *devboxCLI { |
| - return &devboxCLI{stdout: stdout, stderr: stderr, socket: devboxSocketPath(), branch: gitCurrentBranch, now: time.Now, goos: runtime.GOOS, uid: os.Geteuid(), serviceUID: devboxServiceUID, grantACL: grantServiceACL} |
| + return &devboxCLI{stdout: stdout, stderr: stderr, socket: devboxSocketPath(), branch: gitCurrentBranch, now: time.Now, goos: runtime.GOOS, uid: os.Geteuid(), serviceUID: devboxServiceUID, grantACL: grantDevboxSocketACL} |
| } |
| func runDevbox(args []string) { |
| @@ -392,7 +400,7 @@ func (c *devboxCLI) share(args []string) error { |
| allow, err = devbox.ValidateAllow(strings.Split(*allowFlag, ",")) |
| if err != nil { |
| if errors.As(err, &invalid) { |
| - return refuseWith(devboxBadAllow(invalid.Login)) |
| + return refuseWith(devboxBadAllow(devboxAllowLogin(invalid.Login))) |
| } |
| return err |
| } |
| @@ -617,7 +625,10 @@ func (rc refusalContext) render(w devbox.WireError) error { |
| case devbox.CodeUnknownLink: |
| return refuseWith(devboxUnknownLink(rc.name)) |
| case devbox.CodeSocketPath: |
| - return refuseWith(devboxSocketPathRefusal(rc.path, devboxSocketsDir())) |
| + if w.SocketsDir == "" { |
| + return refuseWith(devboxNotUnderstood) |
| + } |
| + return refuseWith(devboxSocketPathRefusal(rc.path, w.SocketsDir)) |
| case devbox.CodeNotASocket: |
| return refuseWith(devboxNotASocket(rc.path)) |
| case devbox.CodeSocketNotYours: |
| @@ -627,7 +638,12 @@ func (rc refusalContext) render(w devbox.WireError) error { |
| case devbox.CodeSocketUnsupported: |
| return refuseWith(devboxSocketUnsupported) |
| case devbox.CodeBadAllow: |
| - return refuseWith(devboxBadAllow(rc.allow)) |
| + _, err := devbox.ValidateAllow(strings.Split(rc.allow, ",")) |
| + var invalid *devbox.AllowError |
| + if errors.As(err, &invalid) { |
| + return refuseWith(devboxBadAllow(devboxAllowLogin(invalid.Login))) |
| + } |
| + return refuseWith(devboxNotUnderstood) |
| case devbox.CodeInternal: |
| return refuseWith(devboxInternal) |
| } |
| @@ -852,18 +868,16 @@ func (c *devboxCLI) prepareSocket(path string) (string, error) { |
| if !filepath.IsAbs(clean) || filepath.Dir(clean) != filepath.Clean(devboxSocketsDir()) { |
| return "", refuseWith(devboxSocketPathRefusal(path, devboxSocketsDir())) |
| } |
| - fi, err := os.Lstat(clean) |
| - if err != nil || fi.Mode()&os.ModeSocket == 0 { |
| - return "", refuseWith(devboxNotASocket(path)) |
| - } |
| - if uid, ok := fileOwner(fi); !ok || uid != c.uid { |
| - return "", refuseWith(devboxSocketNotYours(path)) |
| + socket, err := openDevboxSocket(clean, c.uid) |
| + if err != nil { |
| + return "", err |
| } |
| + defer socket.Close() |
| uid, err := c.serviceUID() |
| if err != nil { |
| return "", refuseWith(devboxMissingServiceUser(devboxServiceUser())) |
| } |
| - if err := c.grantACL(clean, uid); err != nil { |
| + if err := c.grantACL(socket, uid); err != nil { |
| return "", refuseWith(devboxSocketACLFailed(path)) |
| } |
| return clean, nil |
diff --git a/devbox_identity_cli_test.go b/devbox_identity_cli_test.go| index 979b0c8dc..118e3cfd9 100644 |
| --- a/devbox_identity_cli_test.go |
| +++ b/devbox_identity_cli_test.go |
| @@ -102,6 +102,9 @@ func TestDevboxShareAllowMalformed(t *testing.T) { |
| for _, bad := range []string{"", "bad login", "tab\tlogin", "é@github", strings.Repeat("a", devbox.MaxAllowLogin+1)} { |
| t.Run(bad, func(t *testing.T) { |
| out, errOut, code := runDevboxCLI(t, "/missing", nil, "share", "--port", "8080", "--allow", "alice@github,"+bad, "shop") |
| + if bad == "" { |
| + bad = `""` |
| + } |
| want := bad + " is not a tailnet login. give logins such as alice@github, separated by commas, with no spaces\n" |
| if code != 1 || out != "" || errOut != want { |
| t.Fatalf("share = %d, %q, %q; want %q", code, out, errOut, want) |
| @@ -158,7 +161,7 @@ func TestDevboxSocketRefusedOnDarwin(t *testing.T) { |
| mod := func(c *devboxCLI) { |
| c.goos = "darwin" |
| c.serviceUID = func() (uint32, error) { t.Fatal("looked up service user"); return 0, nil } |
| - c.grantACL = func(string, uint32) error { t.Fatal("wrote ACL"); return nil } |
| + c.grantACL = func(*os.File, uint32) error { t.Fatal("wrote ACL"); return nil } |
| } |
| out, errOut, code := runDevboxCLI(t, "/missing", mod, args...) |
| want := "--socket works on Linux devboxes only for now. on this devbox, use --port\n" |
| @@ -214,7 +217,7 @@ func TestDevboxSocketLocalRefusals(t *testing.T) { |
| c.uid++ |
| } |
| c.serviceUID = func() (uint32, error) { t.Fatal("looked up service user before local refusal"); return 0, nil } |
| - c.grantACL = func(string, uint32) error { t.Fatal("wrote ACL before local refusal"); return nil } |
| + c.grantACL = func(*os.File, uint32) error { t.Fatal("wrote ACL before local refusal"); return nil } |
| } |
| want := tt.path + " is not directly inside " + dir + ". have your tool create its socket there, then share it" |
| if tt.want == "socket" { |
| @@ -240,7 +243,7 @@ func TestDevboxSocketSetupRefusals(t *testing.T) { |
| t.Run("missing user", func(t *testing.T) { |
| t.Setenv("CARLOS_DEVBOX_SERVICE_USER", "devbox-no-such-user-486") |
| mod := func(c *devboxCLI) { |
| - c.grantACL = func(string, uint32) error { t.Fatal("ACL written without user"); return nil } |
| + c.grantACL = func(*os.File, uint32) error { t.Fatal("ACL written without user"); return nil } |
| } |
| out, errOut, code := runDevboxCLI(t, h.sock, mod, "share", "--socket", path, "shop") |
| want := "this machine has no devbox service user called devbox-no-such-user-486. tell whoever runs this devbox\n" |
| @@ -250,9 +253,9 @@ func TestDevboxSocketSetupRefusals(t *testing.T) { |
| }) |
| t.Run("acl", func(t *testing.T) { |
| mod := func(c *devboxCLI) { |
| - c.grantACL = func(got string, uid uint32) error { |
| - if got != path || uid != me() { |
| - t.Fatalf("grant = %q, %d", got, uid) |
| + c.grantACL = func(got *os.File, uid uint32) error { |
| + if got.Name() != path || uid != me() { |
| + t.Fatalf("grant = %q, %d", got.Name(), uid) |
| } |
| return os.ErrPermission |
| } |
| @@ -301,10 +304,10 @@ func TestDevboxIdentityRefusalRendering(t *testing.T) { |
| {devbox.CodeSocketNotYours, path + " belongs to another account. you can only share a socket you created"}, |
| {devbox.CodeSocketUnreachable, "nothing is answering on " + path + ". start your tool, then share again"}, |
| {devbox.CodeSocketUnsupported, "--socket works on Linux devboxes only for now. on this devbox, use --port"}, |
| - {devbox.CodeBadAllow, "alice@github is not a tailnet login. give logins such as alice@github, separated by commas, with no spaces"}, |
| + {devbox.CodeBadAllow, devboxNotUnderstood}, |
| } { |
| t.Run(tt.code, func(t *testing.T) { |
| - if err := rc.render(devbox.WireError{Code: tt.code}); err == nil || err.Error() != tt.want { |
| + if err := rc.render(devbox.WireError{Code: tt.code, SocketsDir: devbox.DefaultSocketsDir}); err == nil || err.Error() != tt.want { |
| t.Fatalf("render = %v, want %q", err, tt.want) |
| } |
| }) |
| @@ -355,3 +358,72 @@ func TestDevboxIdentityHelp(t *testing.T) { |
| } |
| } |
| } |
| + |
| +func TestDevboxSocketACLPathSwap(t *testing.T) { |
| + h := newDevboxHarness(t, nil) |
| + path := devboxSocketTarget(t, h) |
| + target := filepath.Join(t.TempDir(), "private") |
| + if err := os.WriteFile(target, []byte("private data"), 0600); err != nil { |
| + t.Fatal(err) |
| + } |
| + moved := path + ".old" |
| + mod := func(c *devboxCLI) { |
| + c.grantACL = func(got *os.File, uid uint32) error { |
| + if err := os.Rename(path, moved); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.Symlink(target, path); err != nil { |
| + t.Fatal(err) |
| + } |
| + return grantDevboxSocketACL(got, uid) |
| + } |
| + } |
| + out, errOut, code := runDevboxCLI(t, h.sock, mod, "share", "--socket", path, "shop") |
| + if code != 1 || out != "" || errOut != devboxNotASocket(path)+"\n" { |
| + t.Errorf("share = %d, %q, %q", code, out, errOut) |
| + } |
| + assertDevboxACLTargetUntouched(t, target) |
| + fi, err := os.Stat(moved) |
| + if err != nil || fi.Mode().Perm() != 0660 { |
| + t.Errorf("pinned socket mode = %v, %v; want 0660", fi, err) |
| + } |
| + if len(h.r.Links.All()) != 0 { |
| + t.Fatal("swapped socket registered") |
| + } |
| +} |
| + |
| +func TestDevboxSocketDirectoryMismatch(t *testing.T) { |
| + h := newDevboxHarness(t, nil) |
| + path := devboxSocketTarget(t, h) |
| + h.r.SocketsDir = t.TempDir() |
| + out, errOut, code := runDevboxCLI(t, h.sock, nil, "share", "--socket", path, "shop") |
| + want := devboxSocketPathRefusal(path, h.r.SocketsDir) + "\n" |
| + if code != 1 || out != "" || errOut != want { |
| + t.Fatalf("share = %d, %q, %q; want %q", code, out, errOut, want) |
| + } |
| +} |
| + |
| +func TestDevboxBadAllowRendering(t *testing.T) { |
| + for _, tt := range []struct{ raw, want string }{ |
| + {"alice@github,bob@github", devboxNotUnderstood}, |
| + {"alice@github,bad login", "bad login is not a tailnet login. give logins such as alice@github, separated by commas, with no spaces"}, |
| + {"alice@github,", `"" is not a tailnet login. give logins such as alice@github, separated by commas, with no spaces`}, |
| + {"", `"" is not a tailnet login. give logins such as alice@github, separated by commas, with no spaces`}, |
| + } { |
| + rc := refusalContext{allow: tt.raw} |
| + if err := rc.render(devbox.WireError{Code: devbox.CodeBadAllow}); err == nil || err.Error() != tt.want { |
| + t.Errorf("render %q = %v, want %q", tt.raw, err, tt.want) |
| + } |
| + } |
| + out, errOut, code := runDevboxCLI(t, "/missing", nil, "share", "--port", "8080", "--allow", "", "shop") |
| + if code != 1 || out != "" || errOut != "\"\" is not a tailnet login. give logins such as alice@github, separated by commas, with no spaces\n" { |
| + t.Fatalf("empty allow = %d, %q, %q", code, out, errOut) |
| + } |
| +} |
| + |
| +func TestDevboxSocketPathWithoutRegistrarDirectory(t *testing.T) { |
| + rc := refusalContext{path: "/example/tool.sock"} |
| + if err := rc.render(devbox.WireError{Code: devbox.CodeSocketPath}); err == nil || err.Error() != devboxNotUnderstood { |
| + t.Fatalf("old registrar path refusal = %v", err) |
| + } |
| +} |
diff --git a/docs/superpowers/plans/2026-10-30-devbox-mode-copy.md b/docs/superpowers/plans/2026-10-30-devbox-mode-copy.md| index ca0159ae8..37cc830aa 100644 |
| --- a/docs/superpowers/plans/2026-10-30-devbox-mode-copy.md |
| +++ b/docs/superpowers/plans/2026-10-30-devbox-mode-copy.md |
| @@ -55,6 +55,9 @@ target is the folder's name as it was shared. |
| | DBX-C8 | devbox_cli.go | a folder of static files to publish. the link serves a copy, and sharing again replaces it | approved | |
| | DBX-C9 | devbox_cli.go | unshare removes a link you published. without a name it uses your git branch | approved | |
| | DBX-C10 | devbox_cli.go | list shows every link on this devbox, who owns it and whether it is answering | approved | |
| + |
| +DBX-C2 and DBX-C4 are superseded by DBX-C94 and DBX-C113, respectively. |
| + |
| ## Output |
| | id | file | text | status | |
| @@ -69,6 +72,9 @@ target is the folder's name as it was shared. |
| | DBX-C18 | devbox_cli.go | not answering | approved | |
| | DBX-C19 | devbox_cli.go | serving | approved | |
| | DBX-C20 | devbox_cli.go | account removed | approved | |
| + |
| +DBX-C13 is superseded by DBX-C109. |
| + |
| ## Refusals |
| | id | file | text | status | |
| @@ -90,6 +96,9 @@ target is the folder's name as it was shared. |
| | DBX-C35 | devbox_cli.go | the devbox service answered with something this carlos does not understand. update carlos and try again | approved | |
| | DBX-C53 | devbox_cli.go | <name> is already in use on this devbox. pick another name | approved | |
| | DBX-C54 | devbox_cli.go | the devbox service could not finish that. try again, or tell whoever runs this devbox | approved | |
| + |
| +DBX-C26 is superseded by DBX-C97. |
| + |
| ## Runbook: infra/devbox/README.md |
| Headings, the purpose paragraph, one sentence for each one-time root step and |
diff --git a/internal/devbox/registrar.go b/internal/devbox/registrar.go| index dfcbe1d6e..17e1804a6 100644 |
| --- a/internal/devbox/registrar.go |
| +++ b/internal/devbox/registrar.go |
| @@ -128,8 +128,9 @@ type Registrar struct { |
| // WireError is the body of every refusal. |
| type WireError struct { |
| - Code string `json:"code"` |
| - Owner string `json:"owner,omitempty"` |
| + Code string `json:"code"` |
| + Owner string `json:"owner,omitempty"` |
| + SocketsDir string `json:"socketsDir,omitempty"` |
| } |
| // ListEntry is one link as share, unshare and /list report it. |
| @@ -977,6 +978,9 @@ func (r *Registrar) serveShareSocket(uid uint32, w http.ResponseWriter, req *htt |
| } |
| socket, ref := checkSocket(req.Context(), r.SocketsDir, in.Path, uid) |
| if ref != nil { |
| + if ref.body.Code == CodeSocketPath { |
| + ref.body.SocketsDir = r.SocketsDir |
| + } |
| return nil, ref |
| } |
diff --git a/internal/devbox/registrar_socket_linux_test.go b/internal/devbox/registrar_socket_linux_test.go| index 005a212cc..767803023 100644 |
| --- a/internal/devbox/registrar_socket_linux_test.go |
| +++ b/internal/devbox/registrar_socket_linux_test.go |
| @@ -121,14 +121,18 @@ func TestShareSocketRefusesSymlink(t *testing.T) { |
| func TestShareSocketRefusesOutsideDir(t *testing.T) { |
| f, path, _ := socketFixture(t) |
| f.r.SocketsDir = filepath.Join(f.r.SocketsDir, "inside") |
| - wantCode(t, shareAllow(t, f, uint32(os.Getuid()), KindSocket, "shop", path, nil), CodeSocketPath) |
| + if got := wantCode(t, shareAllow(t, f, uint32(os.Getuid()), KindSocket, "shop", path, nil), CodeSocketPath); got.SocketsDir != f.r.SocketsDir { |
| + t.Fatalf("sockets directory = %q, want %q", got.SocketsDir, f.r.SocketsDir) |
| + } |
| noSocketWrite(t, f) |
| } |
| func TestShareSocketRefusesBadPath(t *testing.T) { |
| f, path, _ := socketFixture(t) |
| for _, path := range []string{"", "relative.sock", "@abstract", f.r.SocketsDir, filepath.Join(f.r.SocketsDir, "missing"), filepath.Join(f.r.SocketsDir, "nested", "shop.sock"), f.r.SocketsDir + "/../shop.sock"} { |
| - wantCode(t, shareAllow(t, f, uint32(os.Getuid()), KindSocket, "shop", path, nil), CodeSocketPath) |
| + if got := wantCode(t, shareAllow(t, f, uint32(os.Getuid()), KindSocket, "shop", path, nil), CodeSocketPath); got.SocketsDir != f.r.SocketsDir { |
| + t.Fatalf("sockets directory = %q, want %q", got.SocketsDir, f.r.SocketsDir) |
| + } |
| } |
| file := filepath.Join(f.r.SocketsDir, "file") |
| if err := os.WriteFile(file, nil, 0o600); err != nil { |
diff --git a/internal/devbox/registrar_test.go b/internal/devbox/registrar_test.go| index b409e3dda..9633162f2 100644 |
| --- a/internal/devbox/registrar_test.go |
| +++ b/internal/devbox/registrar_test.go |
| @@ -133,11 +133,12 @@ func wantCode(t *testing.T, rec *httptest.ResponseRecorder, code string) WireErr |
| if rec.Code < 400 { |
| t.Fatalf("refusal %q answered %d", code, rec.Code) |
| } |
| - // R1: codes and data only. The body has no field beyond code and owner. |
| + // R1: codes and data only. A socket-path refusal may name the service |
| + // sockets directory; other refusals carry only code and owner. |
| var raw map[string]any |
| _ = json.Unmarshal(rec.Body.Bytes(), &raw) |
| for k := range raw { |
| - if k != "code" && k != "owner" { |
| + if k != "code" && k != "owner" && !(k == "socketsDir" && code == CodeSocketPath) { |
| t.Fatalf("wire error carries %q: %s", k, rec.Body) |
| } |
| } |