JuliusBrussee/caveman · error

native runtime chmod socket

Error message

native runtime chmod socket: %w

What it means

Once listening, ServeUnix Chmods the socket file to 0600 so only the owner can connect. If that chmod fails, the listener is torn down via defers and "native runtime chmod socket" is returned. This enforces per-user access to the runtime endpoint.

Solutions

  1. Move the socket to a local filesystem (e.g. /tmp or the user's home) that supports chmod
  2. Ensure the process user owns the socket path directory
  3. Check for security/AV software interfering with socket file permissions

Example fix

// before
ServeUnix(ctx, "/mnt/nfs-share/rt.sock", rt) // chmod unsupported
// after
ServeUnix(ctx, "/tmp/rt.sock", rt)
Defensive patterns

Strategy: try-catch

Validate before calling

// verify the target filesystem supports chmod before binding
probe := filepath.Dir(socketPath)
if err := os.Chmod(probe, 0o700); err != nil {
	return fmt.Errorf("filesystem does not support chmod: %w", err)
}

Try / catch

if err := nativeruntime.ServeUnix(ctx, path, rt); err != nil {
	if strings.Contains(err.Error(), "chmod socket") {
		// fall back to a local filesystem path
		return nativeruntime.ServeUnix(ctx, "/tmp/nativeruntime.sock", rt)
	}
	return err
}

Prevention

When it happens

Trigger: os.Chmod(path, 0o600) fails on the freshly bound socket: filesystem does not support it (network/9p mounts), ownership mismatch, or a race replacing the socket file.

Common situations: Sockets placed on tmpfs variants or mounted shares with odd permission semantics; security software resetting ownership; running the server as a different uid than expected.

Understand the failure class

Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/7de5d306c627fd18. Report an issue: GitHub.

Appendix: source

Thrown at proxy/internal/nativeruntime/server_unix.go:61

		conn, dialErr := net.DialTimeout("unix", path, 50*time.Millisecond)
		if dialErr == nil {
			_ = conn.Close()
			return errors.New("native runtime: socket already active")
		}
		if err := os.Remove(path); err != nil {
			return fmt.Errorf("native runtime remove stale socket: %w", err)
		}
	} else if !os.IsNotExist(err) {
		return fmt.Errorf("native runtime inspect socket: %w", err)
	}
	listener, err := net.Listen("unix", path)
	if err != nil {
		return fmt.Errorf("native runtime listen: %w", err)
	}
	defer listener.Close()
	defer os.Remove(path)
	if err := os.Chmod(path, 0o600); err != nil {
		return fmt.Errorf("native runtime chmod socket: %w", err)
	}
	go func() {
		<-ctx.Done()
		_ = listener.Close()
	}()
	for {
		conn, err := listener.Accept()
		if err != nil {
			if ctx.Err() != nil {
				return nil
			}
			return fmt.Errorf("native runtime accept: %w", err)
		}
		go serveConn(ctx, conn, runtime)
	}
}

View on GitHub (pinned to 3ee70a1026)