mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-11-23 05:25:35 +03:00
98ff11e1c7
Go's "syscall" package file for FreeBSD (incorrectly?) uses int64 types in syscall.Rlimit struct.
27 lines
609 B
Go
27 lines
609 B
Go
// +build aix darwin dragonfly linux netbsd openbsd solaris
|
|
|
|
package home
|
|
|
|
import (
|
|
"os"
|
|
"syscall"
|
|
|
|
"github.com/AdguardTeam/golibs/log"
|
|
)
|
|
|
|
// Set user-specified limit of how many fd's we can use
|
|
// https://github.com/AdguardTeam/AdGuardHome/issues/659
|
|
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)
|
|
}
|
|
}
|
|
|
|
// Check if the current user has root (administrator) rights
|
|
func haveAdminRights() (bool, error) {
|
|
return os.Getuid() == 0, nil
|
|
}
|