mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-17 02:48:28 -07:00
3b87478470
Updates #2439. Squashed commit of the following: commit 3ff109e43751132d77500256c8869938680ac281 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Jun 3 20:46:17 2021 +0300 all: imp code, docs commit 512ee6d78cfee511f429d09c8366bb7dd8019aa8 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Jun 3 20:06:41 2021 +0300 all: openbsd support
50 lines
895 B
Go
50 lines
895 B
Go
// +build windows
|
|
|
|
//go:build windows
|
|
|
|
package aghos
|
|
|
|
import (
|
|
"fmt"
|
|
"syscall"
|
|
|
|
"golang.org/x/sys/windows"
|
|
)
|
|
|
|
func canBindPrivilegedPorts() (can bool, err error) {
|
|
return HaveAdminRights()
|
|
}
|
|
|
|
func setRlimit(val uint64) (err error) {
|
|
return ErrUnsupported
|
|
}
|
|
|
|
func haveAdminRights() (bool, error) {
|
|
var token windows.Token
|
|
h := windows.CurrentProcess()
|
|
err := windows.OpenProcessToken(h, windows.TOKEN_QUERY, &token)
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
|
|
info := make([]byte, 4)
|
|
var returnedLen uint32
|
|
err = windows.GetTokenInformation(token, windows.TokenElevation, &info[0], uint32(len(info)), &returnedLen)
|
|
token.Close()
|
|
if err != nil {
|
|
return false, err
|
|
}
|
|
if info[0] == 0 {
|
|
return false, nil
|
|
}
|
|
return true, nil
|
|
}
|
|
|
|
func sendProcessSignal(pid int, sig syscall.Signal) error {
|
|
return fmt.Errorf("not supported on Windows")
|
|
}
|
|
|
|
func isOpenWrt() (ok bool) {
|
|
return false
|
|
}
|