Pull request: all: restore netbsd compat

Updates .

Squashed commit of the following:

commit 4e1bcfd1561f9b927755c5024521d5508ef94b1f
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Mon May 17 13:17:51 2021 +0300

    all: restore netbsd compat
This commit is contained in:
Ainar Garipov 2021-05-17 13:27:40 +03:00
parent a031cae447
commit a0d0ef5cd8
4 changed files with 5 additions and 4 deletions
internal/aghos

36
internal/aghos/os_bsd.go Normal file
View file

@ -0,0 +1,36 @@
// +build darwin netbsd openbsd
package aghos
import (
"os"
"syscall"
"github.com/AdguardTeam/golibs/log"
)
func canBindPrivilegedPorts() (can bool, err error) {
return HaveAdminRights()
}
func setRlimit(val uint) {
var rlim syscall.Rlimit
rlim.Max = uint64(val)
rlim.Cur = uint64(val)
err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim)
if err != nil {
log.Error("Setrlimit() failed: %v", err)
}
}
func haveAdminRights() (bool, error) {
return os.Getuid() == 0, nil
}
func sendProcessSignal(pid int, sig syscall.Signal) error {
return syscall.Kill(pid, sig)
}
func isOpenWrt() (ok bool) {
return false
}