From 362fe29186c680c2fd9d2da643f5a2973145c38a Mon Sep 17 00:00:00 2001 From: Nick Khyl Date: Fri, 20 Nov 2026 15:01:02 -0800 Subject: [PATCH] feature/nodeattrpolicy,tailcfg,util/syspolicy: add a nodeAttr-based policy store Add the system-policy node attribute, whose values map policy setting keys to values, and an extension that exposes them as a policy store in the current profile's scope. The store is replaced whenever the self node's attribute changes and removed as soon as another profile becomes current, before the policy is applied to that profile's prefs. The store is only registered if the new AllowTailnetPolicies device policy setting is enabled. Only profile settings can be configured this way, and settings configured for the device, such as via MDM, take precedence. Updates tailscale/corp#51945 Change-Id: Ic27f180f599d374f9a719877a3037a5f2df30365 Signed-off-by: Nick Khyl --- cmd/tailscaled/depaware.txt | 1 + docs/windows/policy/en-US/tailscale.adml | 6 + docs/windows/policy/tailscale.admx | 10 + feature/condregister/maybe_syspolicy.go | 5 +- feature/tailnetsyspolicy/tailnetsyspolicy.go | 144 ++++++++ .../tailnetsyspolicy/tailnetsyspolicy_test.go | 334 ++++++++++++++++++ tailcfg/nodecap/nodecap.go | 15 + util/syspolicy/pkey/pkey.go | 5 + util/syspolicy/policy_keys.go | 1 + 9 files changed, 520 insertions(+), 1 deletion(-) create mode 100644 feature/tailnetsyspolicy/tailnetsyspolicy.go create mode 100644 feature/tailnetsyspolicy/tailnetsyspolicy_test.go diff --git a/cmd/tailscaled/depaware.txt b/cmd/tailscaled/depaware.txt index cf050ebc0..a421de696 100644 --- a/cmd/tailscaled/depaware.txt +++ b/cmd/tailscaled/depaware.txt @@ -321,6 +321,7 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de L tailscale.com/feature/linkspeed from tailscale.com/feature/condregister L tailscale.com/feature/linuxdnsfight from tailscale.com/feature/condregister tailscale.com/feature/netlog from tailscale.com/feature/condregister/netlog + tailscale.com/feature/tailnetsyspolicy from tailscale.com/feature/condregister tailscale.com/feature/portlist from tailscale.com/feature/condregister tailscale.com/feature/portmapper from tailscale.com/feature/condregister/portmapper tailscale.com/feature/posture from tailscale.com/feature/condregister diff --git a/docs/windows/policy/en-US/tailscale.adml b/docs/windows/policy/en-US/tailscale.adml index 0f2f69a8b..e8429926e 100644 --- a/docs/windows/policy/en-US/tailscale.adml +++ b/docs/windows/policy/en-US/tailscale.adml @@ -123,6 +123,12 @@ If you enable this policy setting, you can specify how long Tailscale will wait If you disable or don't configure this policy setting, Tailscale will only reconnect if a user chooses to or if required by a different policy setting. Refer to https://pkg.go.dev/time#ParseDuration for information about the supported duration strings.]]> + Allow policy settings from the tailnet + Allow users to restart tailscaled + + + + + + + + + + diff --git a/feature/condregister/maybe_syspolicy.go b/feature/condregister/maybe_syspolicy.go index 66d44ea38..f36cd820e 100644 --- a/feature/condregister/maybe_syspolicy.go +++ b/feature/condregister/maybe_syspolicy.go @@ -5,4 +5,7 @@ package condregister -import _ "tailscale.com/feature/syspolicy" +import ( + _ "tailscale.com/feature/syspolicy" + _ "tailscale.com/feature/tailnetsyspolicy" +) diff --git a/feature/tailnetsyspolicy/tailnetsyspolicy.go b/feature/tailnetsyspolicy/tailnetsyspolicy.go new file mode 100644 index 000000000..c2d274793 --- /dev/null +++ b/feature/tailnetsyspolicy/tailnetsyspolicy.go @@ -0,0 +1,144 @@ +// Copyright (c) Tailscale Inc & contributors +// SPDX-License-Identifier: BSD-3-Clause + +// Package tailnetsyspolicy registers a policy store with the policy settings +// that the control plane sent to the current profile's node +// in the [nodecap.SysPolicy] node attribute. +package tailnetsyspolicy + +import ( + "encoding/json" + "sync" + + "tailscale.com/feature" + "tailscale.com/ipn" + "tailscale.com/ipn/ipnext" + "tailscale.com/tailcfg" + "tailscale.com/tailcfg/nodecap" + "tailscale.com/types/logger" + "tailscale.com/types/views" + "tailscale.com/util/syspolicy/pkey" + "tailscale.com/util/syspolicy/policyclient" + "tailscale.com/util/syspolicy/rsop" + "tailscale.com/util/syspolicy/setting" + "tailscale.com/util/syspolicy/source" +) + +const featureName = "tailnet-syspolicy" + +func init() { + if feature.Register(featureName) { + ipnext.RegisterExtension(featureName, newExtension) + } +} + +func newExtension(logf logger.Logf, sb ipnext.SafeBackend) (ipnext.Extension, error) { + return &extension{ + logf: logger.WithPrefix(logf, featureName+": "), + polc: sb.Sys().PolicyClientOrDefault(), + }, nil +} + +// extension keeps a [setting.CurrentProfileScope] policy store in sync with +// the self node's [nodecap.SysPolicy] values. The store is only registered +// if [pkey.AllowTailnetSysPolicy] is enabled and the node has the attribute. +// Settings in the store are overridden by those configured for the device, +// such as via MDM. +type extension struct { + logf logger.Logf + polc policyclient.Client + host ipnext.Host + + unregisterPolicyCb func() + + mu sync.Mutex // lock order: LocalBackend.mu, then e.mu + reg *rsop.StoreRegistration // or nil if the store is not registered + vals views.Slice[tailcfg.RawMessage] // values the registered store was created from +} + +func (e *extension) Name() string { return featureName } + +func (e *extension) Init(h ipnext.Host) error { + e.host = h + unregister, err := e.polc.RegisterChangeCallback("", func(pc policyclient.PolicyChange) { + if pc.HasChanged(pkey.AllowTailnetSysPolicy) { + e.update() + } + }) + if err != nil { + return err + } + e.unregisterPolicyCb = unregister + h.Hooks().OnSelfChange.Add(func(tailcfg.NodeView) { e.update() }) + // OnSelfChange is not called when a profile switch discards the self node. + h.Hooks().ProfileStateChange.Add(func(ipn.LoginProfileView, ipn.PrefsView, bool) { e.update() }) + e.update() + return nil +} + +func (e *extension) Shutdown() error { + e.unregisterPolicyCb() + e.mu.Lock() + defer e.mu.Unlock() + if e.reg == nil { + return nil + } + return e.reg.Unregister() +} + +// update registers, replaces or unregisters the store if the current node's +// [nodecap.SysPolicy] values or [pkey.AllowTailnetSysPolicy] have changed. +// +// When called by LocalBackend, LocalBackend.mu is held, and the store is +// updated before update returns, so on a profile switch the old profile's +// policy settings are gone before LocalBackend applies the policy to the +// new profile's prefs. +func (e *extension) update() { + e.mu.Lock() + defer e.mu.Unlock() + + var vals views.Slice[tailcfg.RawMessage] + if allowed, _ := e.polc.GetBoolean(pkey.AllowTailnetSysPolicy, false); allowed { + if self := e.host.NodeBackend().Self(); self.Valid() { + vals = self.CapMap().Get(nodecap.TailnetSysPolicy) + } + } + if views.SliceEqual(vals, e.vals) { + return + } + + var reg *rsop.StoreRegistration + var err error + switch { + case vals.Len() == 0: + err = e.reg.Unregister() + case e.reg == nil: + reg, err = rsop.RegisterStore("Tailnet", setting.CurrentProfileScope, source.NewJSONPolicyStore(e.parse(vals))) + default: + reg, err = e.reg.ReplaceStore(source.NewJSONPolicyStore(e.parse(vals))) + } + if err != nil { + e.logf("failed to update the policy store: %v", err) + return + } + e.reg, e.vals = reg, vals +} + +// parse returns profile policy settings merged from vals, each of which is +// a JSON object that maps policy setting keys to values. If more than one of +// them has a value for the same key, the last one wins. +func (e *extension) parse(vals views.Slice[tailcfg.RawMessage]) map[string]any { + var settings map[string]any + for _, v := range vals.All() { + if err := json.Unmarshal([]byte(v), &settings); err != nil { + e.logf("ignoring an invalid %q value: %v", nodecap.TailnetSysPolicy, err) + } + } + for k := range settings { + if d, err := setting.DefinitionOf(pkey.Key(k)); err != nil || d.Scope() != setting.ProfileSetting { + e.logf("ignoring %q: not a profile policy setting", k) + delete(settings, k) + } + } + return settings +} diff --git a/feature/tailnetsyspolicy/tailnetsyspolicy_test.go b/feature/tailnetsyspolicy/tailnetsyspolicy_test.go new file mode 100644 index 000000000..3c99f5ea9 --- /dev/null +++ b/feature/tailnetsyspolicy/tailnetsyspolicy_test.go @@ -0,0 +1,334 @@ +// Copyright (c) Tailscale Inc & contributors +// SPDX-License-Identifier: BSD-3-Clause + +package tailnetsyspolicy + +import ( + "net/netip" + "testing" + "time" + + "tailscale.com/ipn" + "tailscale.com/ipn/ipnlocal" + "tailscale.com/ipn/ipnlocal/ipnlocaltest" + "tailscale.com/tailcfg" + "tailscale.com/tailcfg/nodecap" + "tailscale.com/tsd" + "tailscale.com/tstest" + "tailscale.com/types/key" + "tailscale.com/types/netmap" + "tailscale.com/types/persist" + "tailscale.com/util/eventbus/eventbustest" + "tailscale.com/util/syspolicy/pkey" + "tailscale.com/util/syspolicy/policyclient" + "tailscale.com/util/syspolicy/ptype" + "tailscale.com/util/syspolicy/rsop" + "tailscale.com/util/syspolicy/setting" + "tailscale.com/util/syspolicy/source" +) + +// newTestBackend returns a backend with the extension initialized and +// [pkey.AllowTailnetSysPolicy] set to allow in a device policy store. +func newTestBackend(t *testing.T, allow bool) *ipnlocal.LocalBackend { + t.Helper() + err := setting.SetDefinitionsForTest(t, + setting.NewDefinition(pkey.AllowTailnetSysPolicy, setting.DeviceSetting, setting.BooleanValue), + setting.NewDefinition(pkey.ControlURL, setting.DeviceSetting, setting.StringValue), + setting.NewDefinition(pkey.AllowedSuggestedExitNodes, setting.ProfileSetting, setting.StringListValue), + setting.NewDefinition(pkey.AllowExitNodeOverride, setting.ProfileSetting, setting.BooleanValue), + setting.NewDefinition(pkey.EnableRunExitNode, setting.ProfileSetting, setting.PreferenceOptionValue), + setting.NewDefinition(pkey.EnableTailscaleDNS, setting.ProfileSetting, setting.PreferenceOptionValue), + setting.NewDefinition(pkey.EnableTailscaleSubnets, setting.ProfileSetting, setting.PreferenceOptionValue), + setting.NewDefinition(pkey.ExitNodeAllowLANAccess, setting.ProfileSetting, setting.PreferenceOptionValue), + setting.NewDefinition(pkey.ExitNodeID, setting.ProfileSetting, setting.StringValue), + setting.NewDefinition(pkey.ReconnectAfter, setting.ProfileSetting, setting.DurationValue), + setting.NewDefinition(pkey.KeyExpirationNoticeTime, setting.UserSetting, setting.DurationValue), + ) + if err != nil { + t.Fatalf("SetDefinitionsForTest: %v", err) + } + allowStore = source.NewTestStoreOf(t, source.TestSettingOf(pkey.AllowTailnetSysPolicy, allow)) + if _, err := rsop.RegisterStoreForTest(t, "Allow", setting.DeviceScope, allowStore); err != nil { + t.Fatalf("RegisterStoreForTest: %v", err) + } + sys := tsd.NewSystemWithBus(eventbustest.NewBus(t)) + sys.PolicyClient.Set(testPolicyClient{}) + b := ipnlocaltest.NewBackendWithSys(t, sys) + b.ForTest().InitExtensions() + if err := b.ForTest().SetPersist(&persist.Persist{}); err != nil { + t.Fatalf("SetPersist: %v", err) + } + return b +} + +// allowStore is the device policy store with [pkey.AllowTailnetSysPolicy] +// registered by newTestBackend. +var allowStore *source.TestStore + +// numTailnetSettings returns the number of settings in the effective policy +// other than [pkey.AllowTailnetSysPolicy]. +func numTailnetSettings(t *testing.T) int { + t.Helper() + return effectivePolicy(t).Len() - 1 +} + +func testNetMap(policy ...tailcfg.RawMessage) *netmap.NetworkMap { + self := &tailcfg.Node{ + ID: 10, + StableID: "self", + Key: key.NewNode().Public(), + Name: "self.example.ts.net.", + Hostinfo: (&tailcfg.Hostinfo{}).View(), + Addresses: []netip.Prefix{netip.MustParsePrefix("100.64.0.1/32")}, + MachineAuthorized: true, + } + if policy != nil { + self.CapMap = tailcfg.NodeCapMap{nodecap.TailnetSysPolicy: policy} + } + return &netmap.NetworkMap{SelfNode: self.View()} +} + +// testPolicyClient is a [policyclient.Client] that reads the effective policy +// from the registered stores, as tailscaled's client does outside of tests. +type testPolicyClient struct { + policyclient.NoPolicyClient +} + +func policyFor(uid string) (*rsop.Policy, error) { + if uid != "" { + return rsop.PolicyFor(setting.UserScopeOf(uid)) + } + return rsop.PolicyFor(setting.DefaultScope()) +} + +func getSetting[T any](key pkey.Key, def T) (T, error) { + policy, err := policyFor("") + if err != nil { + return def, err + } + if v, ok := policy.Get().Get(key).(T); ok { + return v, nil + } + return def, nil +} + +func (testPolicyClient) GetString(key pkey.Key, def string) (string, error) { + return getSetting(key, def) +} + +func (testPolicyClient) GetStringArray(key pkey.Key, def []string) ([]string, error) { + return getSetting(key, def) +} + +func (testPolicyClient) GetBoolean(key pkey.Key, def bool) (bool, error) { + return getSetting(key, def) +} + +func (testPolicyClient) GetDuration(key pkey.Key, def time.Duration) (time.Duration, error) { + return getSetting(key, def) +} + +func (testPolicyClient) GetPreferenceOption(key pkey.Key, def ptype.PreferenceOption) (ptype.PreferenceOption, error) { + return getSetting(key, def) +} + +func (testPolicyClient) GetPolicySnapshot(uid string) (*policyclient.PolicySnapshot, error) { + policy, err := policyFor(uid) + if err != nil { + return nil, err + } + return policy.Get(), nil +} + +func (testPolicyClient) RegisterChangeCallback(uid string, cb func(policyclient.PolicyChange)) (func(), error) { + policy, err := policyFor(uid) + if err != nil { + return nil, err + } + return policy.RegisterChangeCallback(cb), nil +} + +// effectivePolicy returns the policy for the scope used by LocalBackend. +func effectivePolicy(t *testing.T) *setting.Snapshot { + t.Helper() + policy, err := policyFor("") + if err != nil { + t.Fatalf("PolicyFor: %v", err) + } + return policy.Get() +} + +func waitForPrefs(t *testing.T, b *ipnlocal.LocalBackend, what string, cond func(ipn.PrefsView) bool) { + t.Helper() + err := tstest.WaitFor(10*time.Second, func() error { + if !cond(b.Prefs()) { + return errNotYet + } + return nil + }) + if err != nil { + t.Fatalf("timed out waiting for prefs: %s; got %v", what, b.Prefs().Pretty()) + } +} + +type notYetError struct{} + +func (notYetError) Error() string { return "not yet" } + +var errNotYet = notYetError{} + +func TestSettings(t *testing.T) { + b := newTestBackend(t, true) + b.ForTest().ApplyNetMap(testNetMap( + `{ + "AdvertiseExitNode": "always", + "AllowedSuggestedExitNodes": ["node1", "node2"], + "ExitNode.AllowOverride": true, + "ExitNodeAllowLANAccess": "always", + "ExitNodeID": "node1", + "KeyExpirationNotice": "48h", + "ReconnectAfter": "5m", + "UseTailscaleDNSSettings": "never", + "UseTailscaleSubnets": "never", + "LoginURL": "https://login.example.com" + }`, + )) + + // The effective policy is updated by the time the netmap is applied. + got := effectivePolicy(t) + want := map[pkey.Key]any{ + pkey.EnableRunExitNode: ptype.AlwaysByPolicy, + pkey.AllowedSuggestedExitNodes: []string{"node1", "node2"}, + pkey.AllowExitNodeOverride: true, + pkey.ExitNodeAllowLANAccess: ptype.AlwaysByPolicy, + pkey.ExitNodeID: "node1", + pkey.ReconnectAfter: 5 * time.Minute, + pkey.EnableTailscaleDNS: ptype.NeverByPolicy, + pkey.EnableTailscaleSubnets: ptype.NeverByPolicy, + } + for k, want := range want { + got, err := got.GetErr(k) + if err != nil { + t.Errorf("%s: %v", k, err) + continue + } + if gotList, ok := got.([]string); ok { + if wantList := want.([]string); len(gotList) != len(wantList) || gotList[0] != wantList[0] || gotList[1] != wantList[1] { + t.Errorf("%s = %v; want %v", k, gotList, wantList) + } + } else if got != want { + t.Errorf("%s = %v; want %v", k, got, want) + } + } + // Device and user settings cannot be configured via the node attribute. + for _, k := range []pkey.Key{pkey.ControlURL, pkey.KeyExpirationNoticeTime} { + if v, err := got.GetErr(k); err == nil { + t.Errorf("%s = %v; want it not configured", k, v) + } + } + + waitForPrefs(t, b, "policy applied", func(p ipn.PrefsView) bool { + return p.ExitNodeID() == "node1" && p.ExitNodeAllowLANAccess() && !p.CorpDNS() && !p.RouteAll() && p.AdvertisesExitNode() + }) + + // A change to the node attribute replaces the settings. + b.ForTest().ApplyNetMap(testNetMap(`{"UseTailscaleDNSSettings": "always"}`)) + got = effectivePolicy(t) + if numTailnetSettings(t) != 1 || got.Get(pkey.EnableTailscaleDNS) != ptype.AlwaysByPolicy { + t.Errorf("policy = %v; want only %s", got, pkey.EnableTailscaleDNS) + } + waitForPrefs(t, b, "CorpDNS", func(p ipn.PrefsView) bool { return p.CorpDNS() }) +} + +func TestMultipleValues(t *testing.T) { + b := newTestBackend(t, true) + b.ForTest().ApplyNetMap(testNetMap( + `{"ExitNodeID": "node1", "UseTailscaleSubnets": "never"}`, + `not JSON`, + `{"ExitNodeID": "node2"}`, + )) + got := effectivePolicy(t) + if got, want := got.Get(pkey.ExitNodeID), "node2"; got != want { + t.Errorf("%s = %v; want %v", pkey.ExitNodeID, got, want) + } + if got, want := got.Get(pkey.EnableTailscaleSubnets), ptype.NeverByPolicy; got != want { + t.Errorf("%s = %v; want %v", pkey.EnableTailscaleSubnets, got, want) + } +} + +func TestDevicePolicyWins(t *testing.T) { + b := newTestBackend(t, true) + store := source.NewTestStoreOf(t, source.TestSettingOf(pkey.ExitNodeID, "device-node")) + if _, err := rsop.RegisterStoreForTest(t, "Device", setting.DeviceScope, store); err != nil { + t.Fatalf("RegisterStoreForTest: %v", err) + } + b.ForTest().ApplyNetMap(testNetMap(`{"ExitNodeID": "node1", "ReconnectAfter": "5m"}`)) + got := effectivePolicy(t) + if got, want := got.Get(pkey.ExitNodeID), "device-node"; got != want { + t.Errorf("%s = %v; want %v", pkey.ExitNodeID, got, want) + } + if got, want := got.Get(pkey.ReconnectAfter), 5*time.Minute; got != want { + t.Errorf("%s = %v; want %v", pkey.ReconnectAfter, got, want) + } +} + +// TestProfileSwitch verifies that the settings stop applying as soon as +// another profile becomes the current one. +func TestProfileSwitch(t *testing.T) { + b := newTestBackend(t, true) + b.ForTest().ApplyNetMap(testNetMap(`{"ExitNodeID": "node1", "UseTailscaleDNSSettings": "never"}`)) + waitForPrefs(t, b, "policy applied", func(p ipn.PrefsView) bool { + return p.ExitNodeID() == "node1" && !p.CorpDNS() + }) + oldProfile := b.CurrentProfile().ID() + + if err := b.NewProfile(); err != nil { + t.Fatalf("NewProfile: %v", err) + } + if numTailnetSettings(t) != 0 { + t.Errorf("policy after a profile switch = %v; want none", effectivePolicy(t)) + } + if p := b.Prefs(); p.ExitNodeID() != "" || !p.CorpDNS() { + t.Errorf("new profile's prefs = %v; want them unaffected by the old profile's policy", p.Pretty()) + } + + // The old profile keeps the prefs the policy set, as with any other policy + // that no longer applies, and gets the settings back with its netmap. + if err := b.SwitchProfile(oldProfile); err != nil { + t.Fatalf("SwitchProfile: %v", err) + } + if numTailnetSettings(t) != 0 { + t.Errorf("policy before the netmap is received = %v; want none", effectivePolicy(t)) + } + b.ForTest().ApplyNetMap(testNetMap(`{"ExitNodeID": "node2"}`)) + waitForPrefs(t, b, "ExitNodeID", func(p ipn.PrefsView) bool { return p.ExitNodeID() == "node2" }) +} + +// TestAllowTailnetSysPolicy verifies that the node attribute is only used +// while [pkey.AllowTailnetSysPolicy] is enabled. +func TestAllowTailnetSysPolicy(t *testing.T) { + b := newTestBackend(t, false) + b.ForTest().ApplyNetMap(testNetMap(`{"ExitNodeID": "node1"}`)) + if numTailnetSettings(t) != 0 { + t.Fatalf("policy = %v; want no tailnet settings", effectivePolicy(t)) + } + + waitForExitNodeID := func(want any) { + t.Helper() + err := tstest.WaitFor(10*time.Second, func() error { + if effectivePolicy(t).Get(pkey.ExitNodeID) != want { + return errNotYet + } + return nil + }) + if err != nil { + t.Fatalf("timed out waiting for %s = %v; policy = %v", pkey.ExitNodeID, want, effectivePolicy(t)) + } + } + allowStore.SetBooleans(source.TestSettingOf(pkey.AllowTailnetSysPolicy, true)) + waitForExitNodeID("node1") + waitForPrefs(t, b, "ExitNodeID", func(p ipn.PrefsView) bool { return p.ExitNodeID() == "node1" }) + + allowStore.SetBooleans(source.TestSettingOf(pkey.AllowTailnetSysPolicy, false)) + waitForExitNodeID(nil) +} diff --git a/tailcfg/nodecap/nodecap.go b/tailcfg/nodecap/nodecap.go index 58fd041d3..8d1479f1d 100644 --- a/tailcfg/nodecap/nodecap.go +++ b/tailcfg/nodecap/nodecap.go @@ -106,6 +106,21 @@ const ( // e.g. https://tailscale.com/cap/funnel-ports?ports=80,443,8080-8090 FunnelPorts Cap = "https://tailscale.com/cap/funnel-ports" + // TailnetSysPolicy configures policy settings that apply while the profile + // of the node it is granted to is the current profile. Each CapMap value + // is a JSON object that maps policy setting keys, as defined in + // [tailscale.com/util/syspolicy/pkey], to their values, such as + // {"ExitNodeID": "auto:any", "ExitNode.AllowOverride": true}. + // If more than one value configures the same setting, the last one wins. + // + // Only profile settings are supported; the rest are ignored. A setting + // that is also configured for the device, such as via MDM, keeps its + // device value. + // + // The attribute is ignored unless the AllowTailnetSysPolicy device policy + // setting is enabled. + TailnetSysPolicy Cap = "https://tailscale.com/cap/tailnet-syspolicy" + // OnlyTCP443 specifies that the client should not attempt to generate // any outbound traffic that isn't TCP on port 443 (HTTPS). This is used for // clients in restricted environments where only HTTPS traffic is allowed diff --git a/util/syspolicy/pkey/pkey.go b/util/syspolicy/pkey/pkey.go index 1b38ed783..3d7548eed 100644 --- a/util/syspolicy/pkey/pkey.go +++ b/util/syspolicy/pkey/pkey.go @@ -54,6 +54,11 @@ const ( // On other platforms, it is the client's responsibility to restart tailscaled. AllowTailscaledRestart Key = "AllowTailscaledRestart" + // AllowTailnetSysPolicy is a boolean key that controls whether policy settings + // received from the control plane for the current profile's tailnet are used. + // The default is false. See [tailscale.com/tailcfg/nodecap.SystemPolicy]. + AllowTailnetSysPolicy Key = "AllowTailnetSysPolicy" + // ExitNodeID is the exit node's node id. default ""; if blank, no exit node is forced. // Exit node ID takes precedence over exit node IP. // To find the node ID, go to /api.md#device. diff --git a/util/syspolicy/policy_keys.go b/util/syspolicy/policy_keys.go index 4d3760286..c0176ca2e 100644 --- a/util/syspolicy/policy_keys.go +++ b/util/syspolicy/policy_keys.go @@ -15,6 +15,7 @@ import ( // This includes the first time a policy needs to be read from any source. var implicitDefinitions = []*setting.Definition{ // Device policy settings (can only be configured on a per-device basis): + setting.NewDefinition(pkey.AllowTailnetSysPolicy, setting.DeviceSetting, setting.BooleanValue), setting.NewDefinition(pkey.AllowTailscaledRestart, setting.DeviceSetting, setting.BooleanValue), setting.NewDefinition(pkey.AlwaysOn, setting.DeviceSetting, setting.BooleanValue), setting.NewDefinition(pkey.AlwaysOnOverrideWithReason, setting.DeviceSetting, setting.BooleanValue),