mirror of
https://github.com/tailscale/tailscale.git
synced 2026-11-28 04:26:26 -08:00
The Taildrive file server for a share is started as the share's user with sudo, falling back to su. If neither works and tailscaled is root, userServer.run refuses to start it. On systems that ship neither tool, such as OpenWrt, a share created by root could therefore never be served: the run loop kept failing with `"root" is root` and remote peers saw an empty, unwritable share until sudo was installed. When the share's user is the user tailscaled is already running as, there is nothing to switch to, so run the file server directly. This is what `sudo -u root` already did where sudo is installed. Shares owned by any other user still go through sudo or su as before. Fixes #22413 Change-Id: Ied5f51e01183f90ef1f7d2ffc386847d9eea633a Signed-off-by: Sai Kumar Pola <[email protected]>
25 lines
531 B
Go
25 lines
531 B
Go
// Copyright (c) Tailscale Inc & contributors
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package driveimpl
|
|
|
|
import (
|
|
"os/user"
|
|
"testing"
|
|
)
|
|
|
|
func TestIsCurrentUser(t *testing.T) {
|
|
u, err := user.Current()
|
|
if err != nil {
|
|
t.Skipf("can't determine current user: %v", err)
|
|
}
|
|
if !isCurrentUser(u.Username) {
|
|
t.Errorf("isCurrentUser(%q) = false; want true", u.Username)
|
|
}
|
|
for _, name := range []string{"", u.Username + "-not-me"} {
|
|
if isCurrentUser(name) {
|
|
t.Errorf("isCurrentUser(%q) = true; want false", name)
|
|
}
|
|
}
|
|
}
|