tailscale/cmd
Nick Khyl cab0e1a6f7 uti/syspolicy: user policy support, auto-refresh and initial preparation for policy structs
This updates the syspolicy package to support multiple policy sources in the
three policy scopes: user, profile, and device, and provides a merged resultant
policy. A policy source is a syspolicy/source.Store that has a name and provides
access to policy settings for a given scope. It can be registered with
syspolicy/rsop.RegisterStore. Policy sources and policy stores can be either
platform-specific or platform-agnostic. On Windows, we have the Registry-based,
platform-specific policy store implemented as
syspolicy/source.PlatformPolicyStore. This store provides access to the Group
Policy and MDM policy settings stored in the Registry. On other platforms, we
currently provide a wrapper that converts a syspolicy.Handler into a
syspolicy/source.Store. However, we should update them in follow-up PRs. An
example of a platform-agnostic policy store would be a policy deployed from the
control, a local policy config file, or even environment variables.

We maintain the current, most recent version of the resultant policy for each
scope in an rsop.Policy. This is done by reading and merging the policy settings
from the registered stores the first time the resultant policy is requested,
then re-reading and re-merging them if a store implements the source.Changeable
interface and reports a policy change. Policy change notifications are debounced
to avoid re-reading policy settings multiple times if there are several changes
within a short period. The rsop.Policy can notify clients if the resultant
policy has changed. However, we do not currently expose this via the syspolicy
package and plan to do so differently along with a struct-based policy hierarchy
in the next PR.

To facilitate this, all policy settings should be registered with the
setting.Register function. The syspolicy package does this automatically for all
policy settings defined in policy_keys.go.

The new functionality is available through the existing syspolicy.Read* set of
functions. However, we plan to expose it via a struct-based policy hierarchy,
along with policy change notifications that other subsystems can use, in the
next PR. We also plan to send the resultant policy back from tailscaled to the
clients via the LocalAPI.

This is primarily a foundational PR to facilitate future changes, but the
immediate observable changes on Windows include:
- The service will use the current policy setting values instead of those read
  at OS boot time.
- The GUI has access to policy settings configured on a per-user basis.
On Android:
- We now report policy setting usage via clientmetrics.

Updates #12687

Signed-off-by: Nick Khyl <nickk@tailscale.com>
2024-08-02 20:01:13 -05:00
..
addlicense all: update tools that manage copyright headers 2023-01-27 15:36:29 -08:00
build-webclient client/web: precompress assets 2023-12-07 20:57:31 -05:00
cloner cmd/cloner, cmd/viewer: add _test prefix for files generated with the test build tag 2024-07-12 15:31:34 -05:00
connector-gen cmd/connector-gen: add helper tool for wide app connector configurations 2023-12-15 09:29:42 -08:00
containerboot cmd/containerboot,cmd/k8s-operator: enable IPv6 for fqdn egress proxies (#12577) 2024-07-05 12:21:48 +01:00
derper uti/syspolicy: user policy support, auto-refresh and initial preparation for policy structs 2024-08-02 20:01:13 -05:00
derpprobe cmd/derpprobe: support 'local' derpmap to get derp map via LocalAPI 2024-06-06 13:14:27 -07:00
dist release/dist/qnap: add qnap target builder 2024-04-22 17:43:28 -04:00
get-authkey util/cmpx: delete now that we're using Go 1.22 2024-02-07 18:10:15 -08:00
gitops-pusher cmd/gitops-pusher: only use OAuth creds if non-empty string 2024-02-09 10:55:59 -05:00
hello cmd/hello: link to the Hello KB article (#11022) 2024-02-02 15:48:31 -08:00
k8s-nameserver cmd/k8s-nameserver: fix AAAA record query response (#12412) 2024-06-10 17:57:22 +01:00
k8s-operator uti/syspolicy: user policy support, auto-refresh and initial preparation for policy structs 2024-08-02 20:01:13 -05:00
mkmanifest cmd/mkmanifest, cmd/tailscale, cmd/tailscaled: remove Windows arm32 resources from OSS 2023-03-01 15:45:12 -07:00
mkpkg go.mod: upgrade nfpm to v2 (#8786) 2023-08-03 13:00:45 -07:00
mkversion version/mkversion: open-source version generation logic 2023-02-18 05:21:05 +00:00
nardump all: update copyright and license headers 2023-01-27 15:36:29 -08:00
natc go.mod: bump bart 2024-07-08 19:10:44 -07:00
netlogfmt all: use Go 1.22 range-over-int 2024-04-16 15:32:38 -07:00
nginx-auth tailcfg,all: add and use Node.IsTagged() 2023-03-13 08:44:25 -07:00
pgproxy tsnet: split user facing and backend logging 2024-05-10 15:29:13 -07:00
printdep cmd/printdep: print correct toolchain URL 2023-02-11 17:57:36 +00:00
proxy-to-grafana cmd/proxy-to-grafana: add flag for alternative control server 2024-06-21 12:17:39 +02:00
sniproxy all: use math/rand/v2 more 2024-06-05 15:24:04 -07:00
speedtest all: update copyright and license headers 2023-01-27 15:36:29 -08:00
ssh-auth-none-demo all: replace deprecated ioutil references 2023-08-23 23:53:19 +01:00
stunc cmd/stunc: support user-specified port (#12469) 2024-06-14 09:46:16 -07:00
stund types/opt: add generic Value[T any] for optional values of any types 2024-07-08 17:00:43 -05:00
stunstamp cmd/stunstamp: fix handling of invalid DERP map resp (#12679) 2024-07-01 16:07:48 -07:00
sync-containers all: adjust some build tags for plan9 2023-08-24 15:42:35 -07:00
tailscale uti/syspolicy: user policy support, auto-refresh and initial preparation for policy structs 2024-08-02 20:01:13 -05:00
tailscaled uti/syspolicy: user policy support, auto-refresh and initial preparation for policy structs 2024-08-02 20:01:13 -05:00
testcontrol all: use Go 1.22 range-over-int 2024-04-16 15:32:38 -07:00
testwrapper cmd/testwrapper: apply results of all unit tests to coverage for all packages 2024-02-21 13:08:17 -06:00
tsconnect all: use math/rand/v2 more 2024-06-05 15:24:04 -07:00
tsidp tsnet: split user facing and backend logging 2024-05-10 15:29:13 -07:00
tsshd all: update copyright and license headers 2023-01-27 15:36:29 -08:00
viewer cmd/viewer, types/views, util/codegen: add viewer support for custom container types 2024-07-19 12:50:39 -05:00
xdpderper all: add test for package comments, fix, add comments as needed 2024-07-10 09:57:00 -07:00