fix(gateway): don't block status/stop on non-linux
This commit is contained in:
parent
e8458e169c
commit
2f3899f6ae
3 changed files with 17 additions and 9 deletions
|
|
@ -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)
|
return nil, fmt.Errorf("failed to find gateway process (PID: %d): %w", data.PID, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = verifyGatewayProcessIdentity(data.PID)
|
// Hardening: when possible, ensure the PID file still points to a picoclaw
|
||||||
if err != nil {
|
// gateway process before we report or signal it. Currently we only have a
|
||||||
return nil, err
|
// reliable, dependency-free implementation on Linux (/proc).
|
||||||
|
if runtime.GOOS == "linux" {
|
||||||
|
err = verifyGatewayProcessIdentity(data.PID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return &gatewayTarget{
|
return &gatewayTarget{
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,9 @@ func TestGatewayStopCmdNotRunning(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGatewayStatusCmdRejectsNonGatewayPID(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" {
|
if runtime.GOOS == "windows" {
|
||||||
t.Skip("requires POSIX signal semantics")
|
t.Skip("requires POSIX signal semantics")
|
||||||
}
|
}
|
||||||
|
|
@ -98,6 +101,9 @@ func TestGatewayStatusCmdRejectsNonGatewayPID(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGatewayStopCmdRejectsNonGatewayPID(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" {
|
if runtime.GOOS == "windows" {
|
||||||
t.Skip("requires POSIX signal semantics")
|
t.Skip("requires POSIX signal semantics")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,8 @@
|
||||||
|
|
||||||
package gateway
|
package gateway
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
func verifyGatewayProcessIdentity(processID int) error {
|
func verifyGatewayProcessIdentity(processID int) error {
|
||||||
return fmt.Errorf(
|
// Best-effort: non-Linux platforms don't have a portable, dependency-free way
|
||||||
"gateway process identity verification is not supported on this platform (PID: %d)",
|
// to validate /proc-style executable + argv identity. Don't block status/stop.
|
||||||
processID,
|
return nil
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue