diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-27 17:32:14 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-06-07 11:31:53 +0200 |
commit | 7b12ceede2b28ebe5dc22a50cb69fae1e97577a1 (patch) | |
tree | 9cb4a32a4ead2d32745b8df5787a11ed10c6cbc5 | |
parent | ui: confview: add more super horrible wm_sizing hacks (diff) | |
download | wireguard-windows-7b12ceede2b28ebe5dc22a50cb69fae1e97577a1.tar.xz wireguard-windows-7b12ceede2b28ebe5dc22a50cb69fae1e97577a1.zip |
services: iterate through groups using helper
-rw-r--r-- | services/tokens.go | 3 | ||||
-rw-r--r-- | tunnel/firewall/helpers.go | 3 |
2 files changed, 2 insertions, 4 deletions
diff --git a/services/tokens.go b/services/tokens.go index d3854f2d..ae89a185 100644 --- a/services/tokens.go +++ b/services/tokens.go @@ -18,9 +18,8 @@ func TokenIsMemberOfBuiltInAdministrator(token windows.Token) bool { if err != nil { return false } - groups := (*[(1 << 28) - 1]windows.SIDAndAttributes)(unsafe.Pointer(&gs.Groups[0]))[:gs.GroupCount] isAdmin := false - for _, g := range groups { + for _, g := range gs.AllGroups() { if (g.Attributes&windows.SE_GROUP_USE_FOR_DENY_ONLY != 0 || g.Attributes&windows.SE_GROUP_ENABLED != 0) && g.Sid.IsWellKnown(windows.WinBuiltinAdministratorsSid) { isAdmin = true break diff --git a/tunnel/firewall/helpers.go b/tunnel/firewall/helpers.go index 1c60558b..237a5f57 100644 --- a/tunnel/firewall/helpers.go +++ b/tunnel/firewall/helpers.go @@ -84,8 +84,7 @@ func getCurrentProcessSecurityDescriptor() (*wtFwpByteBlob, error) { return nil, wrapErr(err) } var sid *windows.SID - groups := (*[(1 << 28) - 1]windows.SIDAndAttributes)(unsafe.Pointer(&gs.Groups[0]))[:gs.GroupCount] - for _, g := range groups { + for _, g := range gs.AllGroups() { if g.Attributes != windows.SE_GROUP_ENABLED|windows.SE_GROUP_ENABLED_BY_DEFAULT|windows.SE_GROUP_OWNER { continue } |