aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/service/securityapi.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-05-11 22:13:31 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-05-11 22:15:02 +0200
commit8e5b2564c8c51ca4428a7244fb52483ffc7c4c25 (patch)
tree4a5bddef7103b4339778f4678b08795eb87c92b6 /service/securityapi.go
parentui: allow editing existing tunnels without changing name (diff)
downloadwireguard-windows-8e5b2564c8c51ca4428a7244fb52483ffc7c4c25.tar.xz
wireguard-windows-8e5b2564c8c51ca4428a7244fb52483ffc7c4c25.zip
service: run UI at high integrity
Diffstat (limited to 'service/securityapi.go')
-rw-r--r--service/securityapi.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/service/securityapi.go b/service/securityapi.go
index bf90625f..cf2e597a 100644
--- a/service/securityapi.go
+++ b/service/securityapi.go
@@ -111,6 +111,7 @@ type ACE_HEADER struct {
//sys initializeAcl(acl *byte, len uint32, revision uint32) (err error) = advapi32.InitializeAcl
//sys makeAbsoluteSd(selfRelativeSecurityDescriptor uintptr, absoluteSecurityDescriptor *byte, absoluteSecurityDescriptorSize *uint32, dacl *byte, daclSize *uint32, sacl *byte, saclSize *uint32, owner *byte, ownerSize *uint32, primaryGroup *byte, primaryGroupSize *uint32) (err error) = advapi32.MakeAbsoluteSD
//sys makeSelfRelativeSd(absoluteSecurityDescriptor *byte, relativeSecurityDescriptor *byte, relativeSecurityDescriptorSize *uint32) (err error) = advapi32.MakeSelfRelativeSD
+//sys setTokenInformation(token windows.Token, infoClass uint32, info *byte, infoSize uint32) (err error) = advapi32.SetTokenInformation
//sys createEnvironmentBlock(block *uintptr, token windows.Token, inheritExisting bool) (err error) = userenv.CreateEnvironmentBlock
//sys destroyEnvironmentBlock(block uintptr) (err error) = userenv.DestroyEnvironmentBlock
@@ -296,3 +297,18 @@ func getSecurityAttributes(mainToken windows.Token, tokenThatHasLogonSession win
return relativeSecurityDescriptor, nil
}
+
+func addElevatedIntegrityToUserToken(elevatedToken, userToken windows.Token) error {
+ //TODO: We really don't want to be doing this. See the note above. We'd rather the UI process have very few permissions in its token, and do everything with its SACL. But we can't.
+ var integrityLevel [0x2000]byte
+ len := uint32(len(integrityLevel))
+ err := windows.GetTokenInformation(elevatedToken, windows.TokenIntegrityLevel, &integrityLevel[0], len, &len)
+ if err != nil {
+ return err
+ }
+ err = setTokenInformation(userToken, windows.TokenIntegrityLevel, &integrityLevel[0], len)
+ if err != nil {
+ return err
+ }
+ return nil
+}