2019-07-04 14:26:34 +03:00
|
|
|
// +build aix darwin dragonfly linux netbsd openbsd solaris
|
2019-04-16 18:36:10 +03:00
|
|
|
|
2019-06-10 11:33:19 +03:00
|
|
|
package home
|
2019-04-16 18:36:10 +03:00
|
|
|
|
|
|
|
import (
|
2019-04-01 12:22:54 +03:00
|
|
|
"os"
|
2019-04-16 18:36:10 +03:00
|
|
|
"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)
|
|
|
|
}
|
|
|
|
}
|
2019-04-01 12:22:54 +03:00
|
|
|
|
|
|
|
// Check if the current user has root (administrator) rights
|
|
|
|
func haveAdminRights() (bool, error) {
|
|
|
|
return os.Getuid() == 0, nil
|
|
|
|
}
|