-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ipn/ipnauth, util/winutil: add temporary LookupPseudoUser workaround …
…to address os/user.LookupId errors on Windows I added util/winutil/LookupPseudoUser, which essentially consists of the bits that I am in the process of adding to Go's standard library. We check the provided SID for "S-1-5-x" where 17 <= x <= 20 (which are the known pseudo-users) and then manually populate a os/user.User struct with the correct information. Fixes #869 Signed-off-by: Aaron Klotz <aaron@tailscale.com>
- Loading branch information
Showing
6 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package winutil | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
const ( | ||
localSystemSID = "S-1-5-18" | ||
networkSID = "S-1-5-2" | ||
) | ||
|
||
func TestLookupPseudoUser(t *testing.T) { | ||
localSystem, err := LookupPseudoUser(localSystemSID) | ||
if err != nil { | ||
t.Errorf("LookupPseudoUser(%q) error: %v", localSystemSID, err) | ||
} | ||
if localSystem.Gid != localSystemSID { | ||
t.Errorf("incorrect Gid, got %q, want %q", localSystem.Gid, localSystemSID) | ||
} | ||
t.Logf("localSystem: %v", localSystem) | ||
|
||
// networkSID is a built-in known group but not a pseudo-user. | ||
_, err := LookupPseudoUser(networkSID) | ||
if err == nil { | ||
t.Errorf("LookupPseudoUser(%q) unexpectedly succeeded", networkSID) | ||
} | ||
} |