mirror of
https://github.com/rwinkhart/sys.git
synced 2026-09-05 16:47:27 -04:00
windows: make SID.String() conform to the String interface
This function shouldn't return an error. Like other String() functions everywhere in Golang, this should instead return empty or a token value during an error, so that it can be passed to %v and similar. Also, allow for SID strings of maximum size. Change-Id: Ib6d8407f8ad0bdabcb22c31b8f387594f2ea7672 Reviewed-on: https://go-review.googlesource.com/c/sys/+/196799 Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
This commit is contained in:
@@ -99,12 +99,8 @@ func TestCreateWellKnownSid(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to create well known sid for administrators: %v", err)
|
||||
}
|
||||
sidStr, err := sid.String()
|
||||
if err != nil {
|
||||
t.Fatalf("Unable to convert sid into string: %v", err)
|
||||
}
|
||||
if sidStr != "S-1-5-32-544" {
|
||||
t.Fatalf("Expecting administrators to be S-1-5-32-544, but found %s instead", sidStr)
|
||||
if got, want := sid.String(), "S-1-5-32-544"; got != want {
|
||||
t.Fatalf("Builtin Administrators SID = %s, want %s", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,8 +275,7 @@ func TestSddlConversion(t *testing.T) {
|
||||
t.Fatal("Invalid security descriptor owner")
|
||||
}
|
||||
if !sdOwner.IsWellKnown(windows.WinBuiltinAdministratorsSid) {
|
||||
got, _ := sdOwner.String()
|
||||
t.Fatalf("Owner = %q; want S-1-5-32-544", got)
|
||||
t.Fatalf("Owner = %q; want S-1-5-32-544", sdOwner)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user