Download this file
| 1 | //go:build linux |
| 2 | |
| 3 | package host |
| 4 | |
| 5 | import ( |
| 6 | "os" |
| 7 | "testing" |
| 8 | ) |
| 9 | |
| 10 | func TestPlan9ProductionControllerBindsLiveProcess(t *testing.T) { |
| 11 | reader := productionStopControllers{} |
| 12 | first, err := reader.VerifiedController(t.Context(), os.Getpid()) |
| 13 | if err != nil { |
| 14 | t.Fatal(err) |
| 15 | } |
| 16 | second, err := reader.VerifiedController(t.Context(), os.Getpid()) |
| 17 | if err != nil || first != second || len(first) != 64 { |
| 18 | t.Fatalf("unstable process identity: %s %s %v", first, second, err) |
| 19 | } |
| 20 | if _, err = reader.VerifiedController(t.Context(), -1); err == nil { |
| 21 | t.Fatal("accepted nonexistent controller") |
| 22 | } |
| 23 | if os.Geteuid() != 0 { |
| 24 | if _, err := readClaimEvidenceKey("/etc/carlos/host-evidence.key"); err == nil { |
| 25 | t.Fatal("nonroot read evidence key") |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | |