Update
This commit is contained in:
1 parent
3530afb854
commit
6903fcff27
2146 files changed
+112256
-190703
No files matched your search
+25
-3
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Tailscale Inc & AUTHORS
|
||||
// Copyright (c) Tailscale Inc & contributors
|
||||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
package winutil
|
||||
@@ -163,7 +163,7 @@ func getRegStringsInternal(subKey, name string) ([]string, error) {
|
||||
return val, nil
|
||||
}
|
||||
|
||||
// SetRegStrings sets a MULTI_SZ value in the in the local machine path
|
||||
// SetRegStrings sets a MULTI_SZ value in the local machine path
|
||||
// to the strings specified by values.
|
||||
func SetRegStrings(name string, values []string) error {
|
||||
return setRegStringsInternal(regBase, name, values)
|
||||
@@ -577,7 +577,7 @@ func lookupPseudoUser(uid string) (*user.User, error) {
|
||||
}
|
||||
|
||||
// We're looking for SIDs "S-1-5-x" where 17 <= x <= 20.
|
||||
// This is checking for the the "5"
|
||||
// This is checking for the "5"
|
||||
if sid.IdentifierAuthority() != windows.SECURITY_NT_AUTHORITY {
|
||||
return nil, fmt.Errorf(`SID %q does not use "NT AUTHORITY"`, uid)
|
||||
}
|
||||
@@ -972,3 +972,25 @@ func GUIPathFromReg() (string, error) {
|
||||
|
||||
return regPath, nil
|
||||
}
|
||||
|
||||
// IsCurrentProcessLocalSystem checks whether the current process is running
|
||||
// as LocalSystem.
|
||||
func IsCurrentProcessLocalSystem() bool {
|
||||
localSystem, err := windows.CreateWellKnownSid(windows.WinLocalSystemSid)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
token := windows.GetCurrentProcessToken()
|
||||
// The current process token is a pseudo-handle so we don't need to close it.
|
||||
if ok, err := token.IsMember(localSystem); err != nil || !ok {
|
||||
return false
|
||||
}
|
||||
|
||||
u, err := token.GetTokenUser()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
return u.User.Sid.Equals(localSystem)
|
||||
}
|
||||
Reference in new issue
Block a user