diff --git a/cmd/tailscale/cli/blueprint_lock.go b/cmd/tailscale/cli/blueprint_lock.go index c27d528dc..f8f9672ef 100644 --- a/cmd/tailscale/cli/blueprint_lock.go +++ b/cmd/tailscale/cli/blueprint_lock.go @@ -29,8 +29,13 @@ type blueprintLockedField struct { // blueprintLockedFields enumerates every Prefs field that // `tailscale set` refuses to edit on a blueprint-bound node. The -// list is sourced verbatim from the Blueprints v1 spec; if you add -// or remove a locked field here, update the spec and BLUEPRINTS.md. +// list is sourced from spec §11; if you add or remove a locked field +// here, update the spec and BLUEPRINTS.md. +// +// Spec v2 excludes node-local concerns (hostname, operator) and the +// v1.1-era node-level toggles shields-up and webclient. AdvertiseRoutes +// also covers advertise-exit-node, since exit-node advertisement is +// stored as the v4+v6 default routes in Prefs.AdvertiseRoutes. // // The order matters: the first matching field in this slice is the // one named in the user-visible error message. Ordering follows the @@ -51,16 +56,6 @@ var blueprintLockedFields = []blueprintLockedField{ plural: "App connector advertisement", maskField: func(m *ipn.MaskedPrefs) bool { return m.AppConnectorSet }, }, - { - flag: "hostname", - plural: "Hostname", - maskField: func(m *ipn.MaskedPrefs) bool { return m.HostnameSet }, - }, - { - flag: "operator", - plural: "Operator user", - maskField: func(m *ipn.MaskedPrefs) bool { return m.OperatorUserSet }, - }, { flag: "ssh", plural: "SSH", @@ -76,16 +71,6 @@ var blueprintLockedFields = []blueprintLockedField{ plural: "Route acceptance", maskField: func(m *ipn.MaskedPrefs) bool { return m.RouteAllSet }, }, - { - flag: "shields-up", - plural: "Shields-up", - maskField: func(m *ipn.MaskedPrefs) bool { return m.ShieldsUpSet }, - }, - { - flag: "webclient", - plural: "Web client", - maskField: func(m *ipn.MaskedPrefs) bool { return m.RunWebClientSet }, - }, } // checkBlueprintSetLocked returns a non-nil error if curPrefs is diff --git a/cmd/tailscale/cli/blueprint_lock_test.go b/cmd/tailscale/cli/blueprint_lock_test.go index df6995aa2..05f8b4230 100644 --- a/cmd/tailscale/cli/blueprint_lock_test.go +++ b/cmd/tailscale/cli/blueprint_lock_test.go @@ -79,16 +79,6 @@ func TestCheckBlueprintSetLocked_AllLockedFields(t *testing.T) { setMask: func(m *ipn.MaskedPrefs) { m.AppConnectorSet = true }, wantField: "App connector advertisement", }, - { - name: "hostname", - setMask: func(m *ipn.MaskedPrefs) { m.HostnameSet = true }, - wantField: "Hostname", - }, - { - name: "operator", - setMask: func(m *ipn.MaskedPrefs) { m.OperatorUserSet = true }, - wantField: "Operator user", - }, { name: "ssh", setMask: func(m *ipn.MaskedPrefs) { m.RunSSHSet = true }, @@ -104,16 +94,6 @@ func TestCheckBlueprintSetLocked_AllLockedFields(t *testing.T) { setMask: func(m *ipn.MaskedPrefs) { m.RouteAllSet = true }, wantField: "Route acceptance", }, - { - name: "shields-up", - setMask: func(m *ipn.MaskedPrefs) { m.ShieldsUpSet = true }, - wantField: "Shields-up", - }, - { - name: "webclient", - setMask: func(m *ipn.MaskedPrefs) { m.RunWebClientSet = true }, - wantField: "Web client", - }, } cur := &ipn.Prefs{BlueprintID: "bp1"} for _, tt := range tests { @@ -137,6 +117,35 @@ func TestCheckBlueprintSetLocked_AllLockedFields(t *testing.T) { } } +// TestCheckBlueprintSetLocked_NodeLocalFieldsAllowed asserts the spec +// v2 narrowing: hostname, operator, shields-up, and webclient are +// node-local concerns that a blueprint has no opinion on. Setting any +// of them on a blueprint-bound node must NOT be rejected. +// +// This catches a regression where v1 (and the legacy v1.1 KB doc) +// listed these among the locked fields. Spec §11 dropped them. +func TestCheckBlueprintSetLocked_NodeLocalFieldsAllowed(t *testing.T) { + cur := &ipn.Prefs{BlueprintID: "bp1"} + tests := []struct { + name string + setMask func(*ipn.MaskedPrefs) + }{ + {"hostname", func(m *ipn.MaskedPrefs) { m.HostnameSet = true }}, + {"operator", func(m *ipn.MaskedPrefs) { m.OperatorUserSet = true }}, + {"shields-up", func(m *ipn.MaskedPrefs) { m.ShieldsUpSet = true }}, + {"webclient", func(m *ipn.MaskedPrefs) { m.RunWebClientSet = true }}, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + mp := &ipn.MaskedPrefs{} + tt.setMask(mp) + if err := checkBlueprintSetLocked(cur, mp); err != nil { + t.Errorf("bound prefs rejected node-local field %q: %v", tt.name, err) + } + }) + } +} + // TestCheckBlueprintSetLocked_NilPrefs verifies that a nil curPrefs // pointer (an unlikely but possible state during early daemon // boot) does not panic and is treated as not-bound.