aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/elevate/membership.go
diff options
context:
space:
mode:
authorSimon Rozman <simon@rozman.si>2019-08-29 11:04:07 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-08-30 08:47:21 -0600
commit8623ff4d1dcecab97347f9306a618ef5f473835d (patch)
tree4c57eadc8d704277c3f03550896122115418941e /elevate/membership.go
parentelevate: check for desktop admin ownership (diff)
downloadwireguard-windows-8623ff4d1dcecab97347f9306a618ef5f473835d.tar.xz
wireguard-windows-8623ff4d1dcecab97347f9306a618ef5f473835d.zip
main: display localized "Administrators" group name
Signed-off-by: Simon Rozman <simon@rozman.si>
Diffstat (limited to 'elevate/membership.go')
-rw-r--r--elevate/membership.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/elevate/membership.go b/elevate/membership.go
index 131c6d97..0c090271 100644
--- a/elevate/membership.go
+++ b/elevate/membership.go
@@ -15,7 +15,7 @@ func isAdmin(token windows.Token) bool {
return false
}
var checkableToken windows.Token
- err = windows.DuplicateTokenEx(token, windows.TOKEN_QUERY | windows.TOKEN_IMPERSONATE, nil, windows.SecurityIdentification, windows.TokenImpersonation, &checkableToken)
+ err = windows.DuplicateTokenEx(token, windows.TOKEN_QUERY|windows.TOKEN_IMPERSONATE, nil, windows.SecurityIdentification, windows.TokenImpersonation, &checkableToken)
if err != nil {
return false
}
@@ -52,10 +52,22 @@ func IsAdminDesktop() (bool, error) {
}
defer windows.CloseHandle(process)
var token windows.Token
- err = windows.OpenProcessToken(process, windows.TOKEN_QUERY | windows.TOKEN_IMPERSONATE, &token)
+ err = windows.OpenProcessToken(process, windows.TOKEN_QUERY|windows.TOKEN_IMPERSONATE, &token)
if err != nil {
return false, err
}
defer token.Close()
return TokenIsElevatedOrElevatable(token), nil
-} \ No newline at end of file
+}
+
+func AdminGroupName() string {
+ builtinAdminsGroup, err := windows.CreateWellKnownSid(windows.WinBuiltinAdministratorsSid)
+ if err != nil {
+ return "Administrators"
+ }
+ name, _, _, err := builtinAdminsGroup.LookupAccount("")
+ if err != nil {
+ return "Administrators"
+ }
+ return name
+}