summaryrefslogtreecommitdiffhomepage
path: root/ipn/ipnserver/server.go
diff options
context:
space:
mode:
authorAndrew Lytvynov <awly@tailscale.com>2023-11-02 16:39:08 -0600
committerAndrew Lytvynov <awly@tailscale.com>2023-11-02 16:39:08 -0600
commit7ee8828139382ae814662d828fbc5ba4804ed4b2 (patch)
treeba2be9865c752bb333bc443b9a2fdfd4956cc4c5 /ipn/ipnserver/server.go
parent71450164146ec634dce148969ec96b785476d768 (diff)
downloadtailscale-awly/linux-sudoers-local-admin-poc.tar.xz
tailscale-awly/linux-sudoers-local-admin-poc.zip
ipn: mark /etc/sudoers members as local admin on linuxawly/linux-sudoers-local-admin-poc
Just a POC, probably a bad idea.
Diffstat (limited to 'ipn/ipnserver/server.go')
-rw-r--r--ipn/ipnserver/server.go30
1 files changed, 4 insertions, 26 deletions
diff --git a/ipn/ipnserver/server.go b/ipn/ipnserver/server.go
index 755919275..9cdb90905 100644
--- a/ipn/ipnserver/server.go
+++ b/ipn/ipnserver/server.go
@@ -202,7 +202,10 @@ func (s *Server) serveHTTP(w http.ResponseWriter, r *http.Request) {
lah := localapi.NewHandler(lb, s.logf, s.netMon, s.backendLogID)
lah.PermitRead, lah.PermitWrite = s.localAPIPermissions(ci)
lah.PermitCert = s.connCanFetchCerts(ci)
- lah.CallerIsLocalAdmin = s.connIsLocalAdmin(ci)
+ lah.CallerIsLocalAdmin, err = ci.IsLocalAdmin()
+ if err != nil {
+ s.logf("IsLocalAdmin: %v", err)
+ }
lah.ServeHTTP(w, r)
return
}
@@ -364,31 +367,6 @@ func (s *Server) connCanFetchCerts(ci *ipnauth.ConnIdentity) bool {
return false
}
-// connIsLocalAdmin reports whether ci has administrative access to the local
-// machine, for whatever that means with respect to the current OS.
-//
-// This returns true only on Windows machines when the client user is a
-// member of the built-in Administrators group (but not necessarily elevated).
-// This is useful because, on Windows, tailscaled itself always runs with
-// elevated rights: we want to avoid privilege escalation for certain mutative operations.
-func (s *Server) connIsLocalAdmin(ci *ipnauth.ConnIdentity) bool {
- tok, err := ci.WindowsToken()
- if err != nil {
- if !errors.Is(err, ipnauth.ErrNotImplemented) {
- s.logf("ipnauth.ConnIdentity.WindowsToken() error: %v", err)
- }
- return false
- }
- defer tok.Close()
-
- isAdmin, err := tok.IsAdministrator()
- if err != nil {
- s.logf("ipnauth.WindowsToken.IsAdministrator() error: %v", err)
- return false
- }
- return isAdmin
-}
-
// addActiveHTTPRequest adds c to the server's list of active HTTP requests.
//
// If the returned error may be of type inUseOtherUserError.