mirror of
https://github.com/tailscale/tailscale.git
synced 2025-07-28 06:43:44 +00:00
feature/taildrop, ipn/ipnlocal: remove leftover dup calls to osshare
I'd moved the osshare calls to feature/taildrop hooks, but forgot to remove them from ipnlocal, or lost them during a rebase. But then I noticed cmd/tailscaled also had some, so turn those into a hook. Updates #12614 Change-Id: I024fb1d27fbcc49c013158882ee5982c2737037d Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
e2814871a7
commit
165b99278b
@ -936,7 +936,6 @@ tailscale.com/cmd/k8s-operator dependencies: (generated by github.com/tailscale/
|
||||
tailscale.com/util/nocasemaps from tailscale.com/types/ipproto
|
||||
💣 tailscale.com/util/osdiag from tailscale.com/ipn/localapi
|
||||
W 💣 tailscale.com/util/osdiag/internal/wsc from tailscale.com/util/osdiag
|
||||
tailscale.com/util/osshare from tailscale.com/ipn/ipnlocal
|
||||
tailscale.com/util/osuser from tailscale.com/ipn/ipnlocal
|
||||
tailscale.com/util/race from tailscale.com/net/dns/resolver
|
||||
tailscale.com/util/racebuild from tailscale.com/logpolicy
|
||||
|
@ -253,6 +253,7 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de
|
||||
tailscale.com/clientupdate from tailscale.com/client/web+
|
||||
LW tailscale.com/clientupdate/distsign from tailscale.com/clientupdate
|
||||
tailscale.com/cmd/tailscaled/childproc from tailscale.com/cmd/tailscaled+
|
||||
tailscale.com/cmd/tailscaled/tailscaledhooks from tailscale.com/cmd/tailscaled+
|
||||
tailscale.com/control/controlbase from tailscale.com/control/controlhttp+
|
||||
tailscale.com/control/controlclient from tailscale.com/cmd/tailscaled+
|
||||
tailscale.com/control/controlhttp from tailscale.com/control/controlclient
|
||||
|
@ -15,9 +15,9 @@ import (
|
||||
"golang.org/x/sys/windows"
|
||||
"golang.org/x/sys/windows/svc"
|
||||
"golang.org/x/sys/windows/svc/mgr"
|
||||
"tailscale.com/cmd/tailscaled/tailscaledhooks"
|
||||
"tailscale.com/logtail/backoff"
|
||||
"tailscale.com/types/logger"
|
||||
"tailscale.com/util/osshare"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -81,8 +81,9 @@ func installSystemDaemonWindows(args []string) (err error) {
|
||||
}
|
||||
|
||||
func uninstallSystemDaemonWindows(args []string) (ret error) {
|
||||
// Remove file sharing from Windows shell (noop in non-windows)
|
||||
osshare.SetFileSharingEnabled(false, logger.Discard)
|
||||
for _, f := range tailscaledhooks.UninstallSystemDaemonWindows {
|
||||
f()
|
||||
}
|
||||
|
||||
m, err := mgr.Connect()
|
||||
if err != nil {
|
||||
|
12
cmd/tailscaled/tailscaledhooks/tailscaledhooks.go
Normal file
12
cmd/tailscaled/tailscaledhooks/tailscaledhooks.go
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
// Package tailscaledhooks provides hooks for optional features
|
||||
// to add to during init that tailscaled calls at runtime.
|
||||
package tailscaledhooks
|
||||
|
||||
import "tailscale.com/feature"
|
||||
|
||||
// UninstallSystemDaemonWindows is called when the Windows
|
||||
// system daemon is uninstalled.
|
||||
var UninstallSystemDaemonWindows feature.Hooks[func()]
|
@ -12,12 +12,14 @@ import (
|
||||
"maps"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"tailscale.com/client/tailscale/apitype"
|
||||
"tailscale.com/cmd/tailscaled/tailscaledhooks"
|
||||
"tailscale.com/ipn"
|
||||
"tailscale.com/ipn/ipnext"
|
||||
"tailscale.com/ipn/ipnstate"
|
||||
@ -31,6 +33,13 @@ import (
|
||||
|
||||
func init() {
|
||||
ipnext.RegisterExtension("taildrop", newExtension)
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
tailscaledhooks.UninstallSystemDaemonWindows.Add(func() {
|
||||
// Remove file sharing from Windows shell.
|
||||
osshare.SetFileSharingEnabled(false, logger.Discard)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func newExtension(logf logger.Logf, b ipnext.SafeBackend) (ipnext.Extension, error) {
|
||||
|
@ -102,7 +102,6 @@ import (
|
||||
"tailscale.com/util/httpm"
|
||||
"tailscale.com/util/mak"
|
||||
"tailscale.com/util/multierr"
|
||||
"tailscale.com/util/osshare"
|
||||
"tailscale.com/util/osuser"
|
||||
"tailscale.com/util/rands"
|
||||
"tailscale.com/util/set"
|
||||
@ -274,7 +273,6 @@ type LocalBackend struct {
|
||||
machinePrivKey key.MachinePrivate
|
||||
tka *tkaState // TODO(nickkhyl): move to nodeContext
|
||||
state ipn.State // TODO(nickkhyl): move to nodeContext
|
||||
capFileSharing bool // whether netMap contains the file sharing capability
|
||||
capTailnetLock bool // whether netMap contains the tailnet lock capability
|
||||
// hostinfo is mutated in-place while mu is held.
|
||||
hostinfo *tailcfg.Hostinfo // TODO(nickkhyl): move to nodeContext
|
||||
@ -460,7 +458,6 @@ func NewLocalBackend(logf logger.Logf, logID logid.PublicID, sys *tsd.System, lo
|
||||
}
|
||||
|
||||
envknob.LogCurrent(logf)
|
||||
osshare.SetFileSharingEnabled(false, logf)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
clock := tstime.StdClock{}
|
||||
@ -6140,13 +6137,6 @@ func (b *LocalBackend) setNetMapLocked(nm *netmap.NetworkMap) {
|
||||
b.health.SetControlHealth(nil)
|
||||
}
|
||||
|
||||
// Determine if file sharing is enabled
|
||||
fs := nm.HasCap(tailcfg.CapabilityFileSharing)
|
||||
if fs != b.capFileSharing {
|
||||
osshare.SetFileSharingEnabled(fs, b.logf)
|
||||
}
|
||||
b.capFileSharing = fs
|
||||
|
||||
if nm.HasCap(tailcfg.NodeAttrLinuxMustUseIPTables) {
|
||||
b.capForcedNetfilter = "iptables"
|
||||
} else if nm.HasCap(tailcfg.NodeAttrLinuxMustUseNfTables) {
|
||||
|
@ -69,7 +69,6 @@ func TestHandlePeerAPI(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
isSelf bool // the peer sending the request is owned by us
|
||||
capSharing bool // self node has file sharing capability
|
||||
debugCap bool // self node has debug capability
|
||||
reqs []*http.Request
|
||||
checks []check
|
||||
@ -77,7 +76,6 @@ func TestHandlePeerAPI(t *testing.T) {
|
||||
{
|
||||
name: "not_peer_api",
|
||||
isSelf: true,
|
||||
capSharing: true,
|
||||
reqs: []*http.Request{httptest.NewRequest("GET", "/", nil)},
|
||||
checks: checks(
|
||||
httpStatus(200),
|
||||
@ -88,7 +86,6 @@ func TestHandlePeerAPI(t *testing.T) {
|
||||
{
|
||||
name: "not_peer_api_not_owner",
|
||||
isSelf: false,
|
||||
capSharing: true,
|
||||
reqs: []*http.Request{httptest.NewRequest("GET", "/", nil)},
|
||||
checks: checks(
|
||||
httpStatus(200),
|
||||
@ -161,7 +158,6 @@ func TestHandlePeerAPI(t *testing.T) {
|
||||
var e peerAPITestEnv
|
||||
lb := &LocalBackend{
|
||||
logf: e.logBuf.Logf,
|
||||
capFileSharing: tt.capSharing,
|
||||
clock: &tstest.Clock{},
|
||||
}
|
||||
lb.currentNode().SetNetMap(&netmap.NetworkMap{SelfNode: selfNode.View()})
|
||||
|
@ -365,7 +365,6 @@ tailscale.com/tsnet dependencies: (generated by github.com/tailscale/depaware)
|
||||
tailscale.com/util/nocasemaps from tailscale.com/types/ipproto
|
||||
💣 tailscale.com/util/osdiag from tailscale.com/ipn/localapi
|
||||
W 💣 tailscale.com/util/osdiag/internal/wsc from tailscale.com/util/osdiag
|
||||
tailscale.com/util/osshare from tailscale.com/ipn/ipnlocal
|
||||
tailscale.com/util/osuser from tailscale.com/ipn/ipnlocal
|
||||
tailscale.com/util/race from tailscale.com/net/dns/resolver
|
||||
tailscale.com/util/racebuild from tailscale.com/logpolicy
|
||||
|
@ -20,6 +20,7 @@ import (
|
||||
_ "golang.zx2c4.com/wireguard/windows/tunnel/winipcfg"
|
||||
_ "tailscale.com/client/local"
|
||||
_ "tailscale.com/cmd/tailscaled/childproc"
|
||||
_ "tailscale.com/cmd/tailscaled/tailscaledhooks"
|
||||
_ "tailscale.com/control/controlclient"
|
||||
_ "tailscale.com/derp/derphttp"
|
||||
_ "tailscale.com/drive/driveimpl"
|
||||
|
Loading…
x
Reference in New Issue
Block a user