summaryrefslogtreecommitdiffhomepage
path: root/safesocket
AgeCommit message (Collapse)AuthorFilesLines
2026-03-23safesocket, ipn/ipnserver: use PeerCreds on solaris and illumosNahum Shalman1-1/+1
Updates tailscale/peercred#10 Signed-off-by: Nahum Shalman <nahamu@gmail.com>
2026-03-05all: fix typos in commentsBrad Fitzpatrick1-2/+2
Fix its/it's, who's/whose, wether/whether, missing apostrophes in contractions, and other misspellings across the codebase. Updates #cleanup Change-Id: I20453b81a7aceaa14ea2a551abba08a2e7f0a1d8 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2026-01-23all: remove AUTHORS file and references to itWill Norris11-11/+11
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>
2025-12-23ipn/ipnauth, safesocket: defer named pipe client's token retrieval until ↵Nick Khyl2-16/+65
ipnserver needs it An error returned by net.Listener.Accept() causes the owning http.Server to shut down. With the deprecation of net.Error.Temporary(), there's no way for the http.Server to test whether the returned error is temporary / retryable or not (see golang/go#66252). Because of that, errors returned by (*safesocket.winIOPipeListener).Accept() cause the LocalAPI server (aka ipnserver.Server) to shut down, and tailscaled process to exit. While this might be acceptable in the case of non-recoverable errors, such as programmer errors, we shouldn't shut down the entire tailscaled process for client- or connection-specific errors, such as when we couldn't obtain the client's access token because the client attempts to connect at the Anonymous impersonation level. Instead, the LocalAPI server should gracefully handle these errors by denying access and returning a 401 Unauthorized to the client. In tailscale/tscert#15, we fixed a known bug where Caddy and other apps using tscert would attempt to connect at the Anonymous impersonation level and fail. However, we should also fix this on the tailscaled side to prevent a potential DoS, where a local app could deliberately open the Tailscale LocalAPI named pipe at the Anonymous impersonation level and cause tailscaled to exit. In this PR, we defer token retrieval until (*WindowsClientConn).Token() is called and propagate the returned token or error via ipnauth.GetConnIdentity() to ipnserver, which handles it the same way as other ipnauth-related errors. Fixes #18212 Fixes tailscale/tscert#13 Signed-off-by: Nick Khyl <nickk@tailscale.com>
2025-10-02feature/featuretags, all: add build features, use existing ones in more placesBrad Fitzpatrick1-1/+7
Saves 270 KB. Updates #12614 Change-Id: I4c3fe06d32c49edb3a4bb0758a8617d83f291cf5 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-09-29feature/featuretags: make CLI connection error diagnostics modularBrad Fitzpatrick2-5/+9
Updates #12614 Change-Id: I09b8944166ee00910b402bcd5725cd7969e2c82c Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-05-07all: remove non-applicable "linux" deps on AndroidBrad Fitzpatrick1-1/+1
Updates #12614 Change-Id: I0e2a18eca3515d3d6206c059110556d2bbbb0c5c Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-04-02safesocket: fix Plan 9 implementationBrad Fitzpatrick1-108/+2
This wasn't right; it was spinning up new goroutines non-stop. Revert to a boring localhost TCP implementation for now. Updates #5794 Change-Id: If93caa20a12ee4e741c0c72b0d91cc0cc5870152 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-03-21safesocket: respect context timeout when sleeping for 250ms in retry loopBrad Fitzpatrick1-1/+5
Noticed while working on a dev tool that uses local.Client. Updates #cleanup Change-Id: I981efff74a5cac5f515755913668bd0508a4aa14 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2025-03-11safesocket, version: fix safesocket_darwin behavior for cmd/tailscale (#15275)Jonathan Nobels2-32/+78
fixes tailscale/tailscale#15269 Fixes the various CLIs for all of the various flavors of tailscaled on darwin. The logic in version is updated so that we have methods that return true only for the actual GUI app (which can beCLI) and the order of the checks in localTCPPortAndTokenDarwin are corrected so that the logic works with all 5 combinations of CLI and tailscaled. Signed-off-by: Jonathan Nobels <jonathan@tailscale.com>
2025-03-03safesocket: add isMacSysExt Check (#15192)Jonathan Nobels1-1/+1
fixes tailscale/corp#26806 IsMacSysApp is not returning the correct answer... It looks like the rest of the code base uses isMacSysExt (when what they really want to know is isMacSysApp). To fix the immediate issue (localAPI is broken entirely in corp), we'll add this check to safesocket which lines up with the other usages, despite the confusing naming. Signed-off-by: Jonathan Nobels <jonathan@tailscale.com>
2025-03-03safesocket: correct logic for determining if we're a macOS GUI client (#15187)Jonathan Nobels2-10/+10
fixes tailscale/corp#26806 This was still slightly incorrect. We care only if the caller is the macSys or macOs app. isSandBoxedMacOS doesn't give us the correct answer for macSys because technically, macsys isn't sandboxed. Signed-off-by: Jonathan Nobels <jonathan@tailscale.com>
2025-02-27safesocket: return an error for LocalTCPPortAndToken for tailscaled (#15144)Jonathan Nobels2-5/+14
fixes tailscale/corp#26806 Fixes a regression where LocalTCPPortAndToken needs to error out early if we're not running as sandboxed macos so that we attempt to connect using the normal unix machinery. Signed-off-by: Jonathan Nobels <jonathan@tailscale.com>
2025-02-06safesocket: add ability for Darwin clients to set explicit credentials (#14702)Jonathan Nobels2-90/+426
updates tailscale/corp#25687 The darwin appstore and standalone clients now support XPC and the keychain for passing user credentials securely between the gui process and an NEVPNExtension hosted tailscaled. Clients that can communicate directly with the network extension, via XPC or the keychain, are now expected to call SetCredentials and supply credentials explicitly, fixing issues with the cli breaking if the current user cannot read the contents of /Library/Tailscale due to group membership restrictions. This matches how those clients source and supply credentials to the localAPI http client. Non-platform-specific code that has traditionally been in the client is moved to safesocket. /Libraray/Tailscaled/sameuserproof has its permissions changed to that it's readably only by users in the admin group. This restricts standalone CLI access for and direct use of localAPI to admins. Signed-off-by: Jonathan Nobels <jonathan@tailscale.com>
2024-10-09safesocket: don't depend on go-ps on iOSBrad Fitzpatrick1-1/+1
There's never a tailscaled on iOS. And we can't run child processes to look for it anyway. Updates tailscale/corp#20099 Change-Id: Ieb3776f4bb440c4f1c442fdd169bacbe17f23ddb Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-08-22all: fix new lint warnings from bumping staticcheckBrad Fitzpatrick1-4/+0
In prep for updating to new staticcheck required for Go 1.23. Updates #12912 Change-Id: If77892a023b79c6fa798f936fc80428fd4ce0673 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-06-10safesocket: add ConnectContextMaisem Ali6-12/+26
This adds a variant for Connect that takes in a context.Context which allows passing through cancellation etc by the caller. Updates tailscale/corp#18266 Signed-off-by: Maisem Ali <maisem@tailscale.com>
2024-04-16all: use Go 1.22 range-over-intBrad Fitzpatrick2-2/+2
Updates #11058 Change-Id: I35e7ef9b90e83cac04ca93fd964ad00ed5b48430 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2024-03-14version,cli,safesocket: detect non-sandboxed macOS GUI (#11369)Andrea Gottardo1-1/+1
Updates ENG-2848 We can safely disable the App Sandbox for our macsys GUI, allowing us to use `tailscale ssh` and do a few other things that we've wanted to do for a while. This PR: - allows Tailscale SSH to be used from the macsys GUI binary when called from a CLI - tweaks the detection of client variants in prop.go, with new functions `IsMacSys()`, `IsMacSysApp()` and `IsMacAppSandboxEnabled()` Signed-off-by: Andrea Gottardo <andrea@gottardo.me>
2024-01-10safesocket: detect macsys from within tailscaledWill Norris1-1/+3
Use the helper method from the version package to detect that we are running the macsys network extension. This method does the same check for the HOME environment variable (which works fine in most cases) as well as the name of the executable (which is needed for the web client). Updates tailscale/corp#16393 Signed-off-by: Will Norris <will@tailscale.com>
2023-12-21all: cleanup unused code, part 2 (#10670)Andrew Lytvynov1-8/+0
And enable U1000 check in staticcheck. Updates #cleanup Signed-off-by: Andrew Lytvynov <awly@tailscale.com>
2023-12-21safesocket: remove ConnectionStrategy (#10662)Andrew Lytvynov7-57/+13
This type seems to be a migration shim for TCP tailscaled sockets (instead of unix/windows pipes). The `port` field was never set, so it was effectively used as a string (`path` field). Remove the whole type and simplify call sites to pass the socket path directly to `safesocket.Connect`. Updates #cleanup Signed-off-by: Andrew Lytvynov <awly@tailscale.com>
2023-10-26safesocket: make clear which net.Conns are winio typesBrad Fitzpatrick3-23/+117
Follow-up to earlier #9049. Updates #9049 Change-Id: I121fbd2468770233a23ab5ee3df42698ca1dabc2 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2023-10-26ipn, safesocket: use Windows token in LocalAPIAaron Klotz2-3/+180
On Windows, the idiomatic way to check access on a named pipe is for the server to impersonate the client on its current OS thread, perform access checks using the client's access token, and then revert the OS thread's access token back to its true self. The access token is a better representation of the client's rights than just a username/userid check, as it represents the client's effective rights at connection time, which might differ from their normal rights. This patch updates safesocket to do the aforementioned impersonation, extract the token handle, and then revert the impersonation. We retain the token handle for the remaining duration of the connection (the token continues to be valid even after we have reverted back to self). Since the token is a property of the connection, I changed ipnauth to wrap the concrete net.Conn to include the token. I then plumbed that change through ipnlocal, ipnserver, and localapi as necessary. I also added a PermitLocalAdmin flag to the localapi Handler which I intend to use for controlling access to a few new localapi endpoints intended for configuring auto-update. Updates https://github.com/tailscale/tailscale/issues/755 Signed-off-by: Aaron Klotz <aaron@tailscale.com>
2023-09-07safesocket, paths: add Plan 9 supportSkip Tavakkolian2-1/+125
Updates #5794 Change-Id: I69150ec18d101f55baabb38613512cde858447cb Co-authored-by: Brad Fitzpatrick <bradfitz@tailscale.com> Signed-off-by: Skip Tavakkolian <skip.tavakkolian@gmail.com>
2023-09-06cmd/tailscale: Check App Store tailscaled dialable before selecting. (#9234)Paul Scott1-0/+13
PR #9217 attempted to fix the same issue, but suffered from not letting the user connect to non-oss tailscaled if something was listening on the socket, as the --socket flag doesn't let you select the mac apps. Rather than leave the user unable to choose, we keep the mac/socket preference order the same and check a bit harder whether the macsys version really is running. Now, we prefer the App Store Tailscale (even if it's Stopped) and you can use --socket to sswitch. But if you quit the App Store Tailscale, we'll try the socket without needing the flag. Fixes #5761 Signed-off-by: Paul Scott <408401+icio@users.noreply.github.com>
2023-04-19safesocket: enable test to run on Windows unpriviligedJames Tucker3-4/+28
I manually tested that the code path that relaxes pipe permissions is not executed when run with elevated priviliges, and the test also passes in that case. Updates #7876 Signed-off-by: James Tucker <jftucker@gmail.com>
2023-04-14.github/workflows: reenable Windows CI, disable broken testsJames Tucker1-0/+3
We accidentally switched to ./tool/go in 4022796484db7f44f0a8598ed9a5d880d1a5b6ae which resulted in no longer running Windows builds, as this is attempting to run a bash script. I was unable to quickly fix the various tests that have regressed, so instead I've added skips referencing #7876, which we need to back and fix. Updates #7262 Updates #7876 Signed-off-by: James Tucker <james@tailscale.com>
2023-01-30safesocket: remove the now unused WindowsLocalPortMaisem Ali5-22/+15
Also drop the port param from safesocket.Listen. #cleanup Signed-off-by: Maisem Ali <maisem@tailscale.com>
2023-01-27all: update copyright and license headersWill Norris8-24/+16
This updates all source files to use a new standard header for copyright and license declaration. Notably, copyright no longer includes a date, and we now use the standard SPDX-License-Identifier header. This commit was done almost entirely mechanically with perl, and then some minimal manual fixes. Updates #6865 Signed-off-by: Will Norris <will@tailscale.com>
2022-11-30all: use named pipes on windowsMaisem Ali2-20/+24
Signed-off-by: Maisem Ali <maisem@tailscale.com>
2022-11-28safesocket: remove the IPN protocol supportBrad Fitzpatrick3-90/+16
Updates #6417 Change-Id: I78908633de842d83b2cc8b10a864a0f88ab1b113 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-11-04all: remove old +build tagsBrad Fitzpatrick2-2/+0
The //go:build syntax was introduced in Go 1.17: https://go.dev/doc/go1.17#build-lines gofmt has kept the +build and go:build lines in sync since then, but enough time has passed. Time to remove them. Done with: perl -i -npe 's,^// \+build.*\n,,' $(git grep -l -F '+build') Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-09-15refactor: move from io/ioutil to io and os packagesEng Zer Jun1-2/+1
The io/ioutil package has been deprecated as of Go 1.16 [1]. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. Reference: https://golang.org/doc/go1.16#ioutil Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-08-02all: gofmt for Go 1.19Brad Fitzpatrick3-11/+13
Updates #5210 Change-Id: Ib02cd5e43d0a8db60c1f09755a8ac7b140b670be Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2022-04-28safesocket: log warning when running sandboxed Mac binary as rootMihai Parparita1-0/+11
It won't work, provide a clue in the error output. Fixes #3063 Signed-off-by: Mihai Parparita <mihai@tailscale.com>
2022-04-25safesocket: fix CLI on standalone mac GUI buildBrad Fitzpatrick1-62/+13
Tested three macOS Tailscale daemons: - App Store (Network Extension) - Standalone (macsys) - tailscaled And two types of local IPC each: - IPN - HTTP And two CLI modes: - sandboxed (running the GUI binary as the CLI; normal way) - open source CLI hitting GUI (with #4525) Bonus: simplifies the code. Fixes tailscale/corp#4559 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-12-09safesocket: add ConnectionStrategy, provide control over fallbacksJosh Bleecher Snyder5-12/+69
fee2d9fad added support for cmd/tailscale to connect to IPNExtension. It came in two parts: If no socket was provided, dial IPNExtension first, and also, if dialing the socket failed, fall back to IPNExtension. The second half of that support caused the integration tests to fail when run on a machine that was also running IPNExtension. The integration tests want to wait until the tailscaled instances that they spun up are listening. They do that by dialing the new instance. But when that dial failed, it was falling back to IPNExtension, so it appeared (incorrectly) that tailscaled was running. Hilarity predictably ensued. If a user (or a test) explicitly provides a socket to dial, it is a reasonable assumption that they have a specific tailscaled in mind and don't want to fall back to IPNExtension. It is certainly true of the integration tests. Instead of adding a bool to Connect, split out the notion of a connection strategy. For now, the implementation remains the same, but with the details hidden a bit. Later, we can improve that. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-12-09all: minor code cleanupJosh Bleecher Snyder1-1/+0
Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-11-07safesocket: add js/wasm implementation with in-memory net.ConnBrad Fitzpatrick2-2/+24
Updates #3157 Change-Id: Ia35b1e259011fb86f8c4e01f62146f9fd4c9b7c6 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-11-05safesocket: add WindowsLocalPort constBrad Fitzpatrick1-0/+4
Remove all the 41112 references. Change-Id: I2d7ed330d457e3bb91b7e6416cfb2667611e50c4 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-10-27safesocket: fail early on js/wasmBrad Fitzpatrick1-0/+4
Updates #3157 Change-Id: Ib78efb3b1ba34ca4fb34296033b95327188774a7 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-09-24safesocket: actually fix CLI on macsys buildBrad Fitzpatrick1-6/+10
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-09-24safesocket: fix CLI for macsys GUI variantBrad Fitzpatrick1-1/+45
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-08-31safesocket: add connect retry loop to wait for tailscaledBrad Fitzpatrick2-1/+69
Updates #2708 Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
2021-08-24fix: typo spelling grammarslowy071-1/+1
Signed-off-by: slowy07 <slowy.arfy@gmail.com>
2021-08-05all: gofmt with Go 1.17Josh Bleecher Snyder1-0/+1
This adds "//go:build" lines and tidies up existing "// +build" lines. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-07-20safesocket: print full lsof command on failureJosh Bleecher Snyder1-3/+4
This makes it easier to manually run the command to discover why it is failing. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-07-20safesocket: reduce log spam while running integration testsJosh Bleecher Snyder1-6/+5
Instead of logging lsof execution failures to stdout, incorporate them into the returned error. While we're here, make it clear that the file success case always returns a nil error. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
2021-07-08safesocket: create the test socket in a temp dirJosh Bleecher Snyder1-2/+8
This allows the test to be run inside a mounted filesystem, which I'm doing now as a I develop on a linux VM. Fixes #2367. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>