ipn/ipnlocal: fix (*profileManager).DefaultUserProfileID for users other than current

Currently, profileManager filters profiles based on their creator/owner and the "current user"'s UID.
This causes DefaultUserProfileID(uid) to work incorrectly when the UID doesn't match the current user.

While we plan to remove the concept of the "current user" completely, we're not there yet.

In this PR, we fix DefaultUserProfileID by updating profileManager to allow checking profile access
for a given UID and modifying helper methods to accept UID as a parameter when returning
matching profiles.

Updates #14823

Signed-off-by: Nick Khyl <nickk@tailscale.com>
This commit is contained in:
Nick Khyl
2025-02-07 15:27:31 -06:00
committed by Nick Khyl
parent 532e38bdc8
commit 122255765a
2 changed files with 28 additions and 26 deletions

View File

@@ -129,10 +129,10 @@ func TestProfileList(t *testing.T) {
pm.SetCurrentUserID("user1")
checkProfiles(t, "alice", "bob")
if lp := pm.findProfileByKey(carol.Key()); lp.Valid() {
if lp := pm.findProfileByKey("user1", carol.Key()); lp.Valid() {
t.Fatalf("found profile for user2 in user1's profile list")
}
if lp := pm.findProfileByName(carol.Name()); lp.Valid() {
if lp := pm.findProfileByName("user1", carol.Name()); lp.Valid() {
t.Fatalf("found profile for user2 in user1's profile list")
}