diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-16 13:06:58 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-16 13:06:58 +0200 |
commit | 7cf6b209f4cc2f0579c9b6475e12ef19cef731bb (patch) | |
tree | c9c412d2e082ebf0dbd946a023678b18fc1a56df /service/tokens.go | |
parent | ui: react to DPI changes in syntax editor (diff) | |
download | wireguard-windows-7cf6b209f4cc2f0579c9b6475e12ef19cef731bb.tar.xz wireguard-windows-7cf6b209f4cc2f0579c9b6475e12ef19cef731bb.zip |
service: token elevation stuff is upstream
Diffstat (limited to '')
-rw-r--r-- | service/tokens.go | 27 |
1 files changed, 0 insertions, 27 deletions
diff --git a/service/tokens.go b/service/tokens.go index f203f268..aade8734 100644 --- a/service/tokens.go +++ b/service/tokens.go @@ -13,33 +13,6 @@ import ( "golang.org/x/sys/windows" ) -func tokenIsElevated(token windows.Token) bool { - var isElevated uint32 - var outLen uint32 - err := windows.GetTokenInformation(token, windows.TokenElevation, (*byte)(unsafe.Pointer(&isElevated)), uint32(unsafe.Sizeof(isElevated)), &outLen) - if err != nil { - return false - } - return outLen == uint32(unsafe.Sizeof(isElevated)) && isElevated != 0 -} - -func getElevatedToken(token windows.Token) (windows.Token, error) { - if tokenIsElevated(token) { - return token, nil - } - var linkedToken windows.Token - var outLen uint32 - err := windows.GetTokenInformation(token, windows.TokenLinkedToken, (*byte)(unsafe.Pointer(&linkedToken)), uint32(unsafe.Sizeof(linkedToken)), &outLen) - if err != nil { - return windows.Token(0), err - } - if tokenIsElevated(linkedToken) { - return linkedToken, nil - } - linkedToken.Close() - return windows.Token(0), errors.New("the linked token is not elevated") -} - func TokenIsMemberOfBuiltInAdministrator(token windows.Token) bool { adminSid, err := windows.CreateWellKnownSid(windows.WinBuiltinAdministratorsSid) if err != nil { |