carlos / platform Public

Clone
git clone https://amadan.net/carlos/platform

Plain git — no account needed to clone.

Download

Download this file

1//go:build linux
2
3package host
4
5import (
6 "os"
7 "testing"
8)
9
10func 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