mirror of
https://github.com/tailscale/tailscale.git
synced 2026-02-12 03:01:28 +01:00
This file was never truly necessary and has never actually been used in the history of Tailscale's open source releases. A Brief History of AUTHORS files --- The AUTHORS file was a pattern developed at Google, originally for Chromium, then adopted by Go and a bunch of other projects. The problem was that Chromium originally had a copyright line only recognizing Google as the copyright holder. Because Google (and most open source projects) do not require copyright assignemnt for contributions, each contributor maintains their copyright. Some large corporate contributors then tried to add their own name to the copyright line in the LICENSE file or in file headers. This quickly becomes unwieldy, and puts a tremendous burden on anyone building on top of Chromium, since the license requires that they keep all copyright lines intact. The compromise was to create an AUTHORS file that would list all of the copyright holders. The LICENSE file and source file headers would then include that list by reference, listing the copyright holder as "The Chromium Authors". This also become cumbersome to simply keep the file up to date with a high rate of new contributors. Plus it's not always obvious who the copyright holder is. Sometimes it is the individual making the contribution, but many times it may be their employer. There is no way for the proejct maintainer to know. Eventually, Google changed their policy to no longer recommend trying to keep the AUTHORS file up to date proactively, and instead to only add to it when requested: https://opensource.google/docs/releasing/authors. They are also clear that: > Adding contributors to the AUTHORS file is entirely within the > project's discretion and has no implications for copyright ownership. It was primarily added to appease a small number of large contributors that insisted that they be recognized as copyright holders (which was entirely their right to do). But it's not truly necessary, and not even the most accurate way of identifying contributors and/or copyright holders. In practice, we've never added anyone to our AUTHORS file. It only lists Tailscale, so it's not really serving any purpose. It also causes confusion because Tailscalars put the "Tailscale Inc & AUTHORS" header in other open source repos which don't actually have an AUTHORS file, so it's ambiguous what that means. Instead, we just acknowledge that the contributors to Tailscale (whoever they are) are copyright holders for their individual contributions. We also have the benefit of using the DCO (developercertificate.org) which provides some additional certification of their right to make the contribution. The source file changes were purely mechanical with: git ls-files | xargs sed -i -e 's/\(Tailscale Inc &\) AUTHORS/\1 contributors/g' Updates #cleanup Change-Id: Ia101a4a3005adb9118051b3416f5a64a4a45987d Signed-off-by: Will Norris <will@tailscale.com>
146 lines
5.5 KiB
Go
146 lines
5.5 KiB
Go
// Copyright (c) Tailscale Inc & contributors
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
// Package policyclient contains the minimal syspolicy interface as needed by
|
|
// client code using syspolicy. It's the part that's always linked in, even if the rest
|
|
// of syspolicy is omitted from the build.
|
|
package policyclient
|
|
|
|
import (
|
|
"time"
|
|
|
|
"tailscale.com/util/syspolicy/pkey"
|
|
"tailscale.com/util/syspolicy/ptype"
|
|
"tailscale.com/util/testenv"
|
|
)
|
|
|
|
// Client is the interface between code making questions about the system policy
|
|
// and the actual implementation.
|
|
type Client interface {
|
|
// GetString returns a string policy setting with the specified key,
|
|
// or defaultValue (and a nil error) if it does not exist.
|
|
GetString(key pkey.Key, defaultValue string) (string, error)
|
|
|
|
// GetStringArray returns a string array policy setting with the specified key,
|
|
// or defaultValue (and a nil error) if it does not exist.
|
|
GetStringArray(key pkey.Key, defaultValue []string) ([]string, error)
|
|
|
|
// GetBoolean returns a boolean policy setting with the specified key,
|
|
// or defaultValue (and a nil error) if it does not exist.
|
|
GetBoolean(key pkey.Key, defaultValue bool) (bool, error)
|
|
|
|
// GetUint64 returns a numeric policy setting with the specified key,
|
|
// or defaultValue (and a nil error) if it does not exist.
|
|
GetUint64(key pkey.Key, defaultValue uint64) (uint64, error)
|
|
|
|
// GetDuration loads a policy from the registry that can be managed by an
|
|
// enterprise policy management system and describes a duration for some
|
|
// action. The registry value should be a string that time.ParseDuration
|
|
// understands. If the registry value is "" or can not be processed,
|
|
// defaultValue (and a nil error) is returned instead.
|
|
GetDuration(key pkey.Key, defaultValue time.Duration) (time.Duration, error)
|
|
|
|
// GetPreferenceOption loads a policy from the registry that can be
|
|
// managed by an enterprise policy management system and allows administrative
|
|
// overrides of users' choices in a way that we do not want tailcontrol to have
|
|
// the authority to set. It describes user-decides/always/never options, where
|
|
// "always" and "never" remove the user's ability to make a selection. If not
|
|
// present or set to a different value, defaultValue (and a nil error) is returned.
|
|
GetPreferenceOption(key pkey.Key, defaultValue ptype.PreferenceOption) (ptype.PreferenceOption, error)
|
|
|
|
// GetVisibility returns whether a UI element should be visible based on
|
|
// the system's configuration.
|
|
// If unconfigured, implementations should return [ptype.VisibleByPolicy]
|
|
// and a nil error.
|
|
GetVisibility(key pkey.Key) (ptype.Visibility, error)
|
|
|
|
// SetDebugLoggingEnabled enables or disables debug logging for the policy client.
|
|
SetDebugLoggingEnabled(enabled bool)
|
|
|
|
// HasAnyOf returns whether at least one of the specified policy settings is
|
|
// configured, or an error if no keys are provided or the check fails.
|
|
HasAnyOf(keys ...pkey.Key) (bool, error)
|
|
|
|
// RegisterChangeCallback registers a callback function that will be called
|
|
// whenever a policy change is detected. It returns a function to unregister
|
|
// the callback and an error if the registration fails.
|
|
RegisterChangeCallback(cb func(PolicyChange)) (unregister func(), err error)
|
|
}
|
|
|
|
// Get returns a non-nil [Client] implementation as a function of the
|
|
// build tags. It returns a no-op implementation if the full syspolicy
|
|
// package is omitted from the build, or in tests.
|
|
func Get() Client {
|
|
if testenv.InTest() {
|
|
// This is a little redundant (the Windows implementation at least
|
|
// already does this) but it's here for redundancy and clarity, that we
|
|
// don't want to accidentally use the real system policy when running
|
|
// tests.
|
|
return NoPolicyClient{}
|
|
}
|
|
return client
|
|
}
|
|
|
|
// RegisterClientImpl registers a [Client] implementation to be returned by
|
|
// [Get].
|
|
func RegisterClientImpl(c Client) {
|
|
client = c
|
|
}
|
|
|
|
var client Client = NoPolicyClient{}
|
|
|
|
// PolicyChange is the interface representing a change in policy settings.
|
|
type PolicyChange interface {
|
|
// HasChanged reports whether the policy setting identified by the given key
|
|
// has changed.
|
|
HasChanged(pkey.Key) bool
|
|
|
|
// HasChangedAnyOf reports whether any of the provided policy settings
|
|
// changed in this change.
|
|
HasChangedAnyOf(keys ...pkey.Key) bool
|
|
}
|
|
|
|
// NoPolicyClient is a no-op implementation of [Client] that only
|
|
// returns default values.
|
|
type NoPolicyClient struct{}
|
|
|
|
var _ Client = NoPolicyClient{}
|
|
|
|
func (NoPolicyClient) GetBoolean(key pkey.Key, defaultValue bool) (bool, error) {
|
|
return defaultValue, nil
|
|
}
|
|
|
|
func (NoPolicyClient) GetString(key pkey.Key, defaultValue string) (string, error) {
|
|
return defaultValue, nil
|
|
}
|
|
|
|
func (NoPolicyClient) GetStringArray(key pkey.Key, defaultValue []string) ([]string, error) {
|
|
return defaultValue, nil
|
|
}
|
|
|
|
func (NoPolicyClient) GetUint64(key pkey.Key, defaultValue uint64) (uint64, error) {
|
|
return defaultValue, nil
|
|
}
|
|
|
|
func (NoPolicyClient) GetDuration(name pkey.Key, defaultValue time.Duration) (time.Duration, error) {
|
|
return defaultValue, nil
|
|
}
|
|
|
|
func (NoPolicyClient) GetPreferenceOption(name pkey.Key, defaultValue ptype.PreferenceOption) (ptype.PreferenceOption, error) {
|
|
return defaultValue, nil
|
|
}
|
|
|
|
func (NoPolicyClient) GetVisibility(name pkey.Key) (ptype.Visibility, error) {
|
|
return ptype.VisibleByPolicy, nil
|
|
}
|
|
|
|
func (NoPolicyClient) HasAnyOf(keys ...pkey.Key) (bool, error) {
|
|
return false, nil
|
|
}
|
|
|
|
func (NoPolicyClient) SetDebugLoggingEnabled(enabled bool) {}
|
|
|
|
func (NoPolicyClient) RegisterChangeCallback(cb func(PolicyChange)) (unregister func(), err error) {
|
|
return func() {}, nil
|
|
}
|