Pull request: all: openbsd support

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
This commit is contained in:
Ainar Garipov
2021-06-03 21:04:13 +03:00
parent 084564e6b7
commit 3b87478470
13 changed files with 124 additions and 72 deletions

View File

@@ -11,7 +11,6 @@ import (
"strings"
"syscall"
"github.com/AdguardTeam/golibs/log"
"golang.org/x/sys/unix"
)
@@ -23,14 +22,12 @@ func canBindPrivilegedPorts() (can bool, err error) {
return cnbs == 1 || adm, err
}
func setRlimit(val uint) {
func setRlimit(val uint64) (err error) {
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)
}
rlim.Max = val
rlim.Cur = val
return syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rlim)
}
func haveAdminRights() (bool, error) {