fix(gateway): don't block status/stop on non-linux

This commit is contained in:
Alix-007 2026-04-07 10:57:46 +08:00
parent e8458e169c
commit 2f3899f6ae
3 changed files with 17 additions and 9 deletions

View file

@ -96,9 +96,14 @@ func resolveGatewayTarget(homePath string) (*gatewayTarget, error) {
return nil, fmt.Errorf("failed to find gateway process (PID: %d): %w", data.PID, err)
}
err = verifyGatewayProcessIdentity(data.PID)
if err != nil {
return nil, err
// Hardening: when possible, ensure the PID file still points to a picoclaw
// gateway process before we report or signal it. Currently we only have a
// reliable, dependency-free implementation on Linux (/proc).
if runtime.GOOS == "linux" {
err = verifyGatewayProcessIdentity(data.PID)
if err != nil {
return nil, err
}
}
return &gatewayTarget{

View file

@ -73,6 +73,9 @@ func TestGatewayStopCmdNotRunning(t *testing.T) {
}
func TestGatewayStatusCmdRejectsNonGatewayPID(t *testing.T) {
if runtime.GOOS != "linux" {
t.Skip("process identity verification is linux-only (/proc)")
}
if runtime.GOOS == "windows" {
t.Skip("requires POSIX signal semantics")
}
@ -98,6 +101,9 @@ func TestGatewayStatusCmdRejectsNonGatewayPID(t *testing.T) {
}
func TestGatewayStopCmdRejectsNonGatewayPID(t *testing.T) {
if runtime.GOOS != "linux" {
t.Skip("process identity verification is linux-only (/proc)")
}
if runtime.GOOS == "windows" {
t.Skip("requires POSIX signal semantics")
}

View file

@ -2,11 +2,8 @@
package gateway
import "fmt"
func verifyGatewayProcessIdentity(processID int) error {
return fmt.Errorf(
"gateway process identity verification is not supported on this platform (PID: %d)",
processID,
)
// Best-effort: non-Linux platforms don't have a portable, dependency-free way
// to validate /proc-style executable + argv identity. Don't block status/stop.
return nil
}