Pull request: 4670-invalid-arg-cap-check
Updates #4670. Squashed commit of the following: commit 9c32739eb92ef57c78a4dc3ec3c0f280aebf7182 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Wed Aug 3 20:04:54 2022 +0300 aghnet: imp port check for older linuxes
This commit is contained in:
parent
eb8e8166c8
commit
8a3d5f046c
|
@ -29,7 +29,13 @@ and this project adheres to
|
||||||
|
|
||||||
- Go 1.18 support. v0.109.0 will require at least Go 1.19 to build.
|
- Go 1.18 support. v0.109.0 will require at least Go 1.19 to build.
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- `invalid argument` errors during update checks on older Linux kernels
|
||||||
|
([#4670]).
|
||||||
|
|
||||||
[#2993]: https://github.com/AdguardTeam/AdGuardHome/issues/2993
|
[#2993]: https://github.com/AdguardTeam/AdGuardHome/issues/2993
|
||||||
|
[#4670]: https://github.com/AdguardTeam/AdGuardHome/issues/4670
|
||||||
|
|
||||||
[ddr-draft]: https://datatracker.ietf.org/doc/html/draft-ietf-add-ddr-08
|
[ddr-draft]: https://datatracker.ietf.org/doc/html/draft-ietf-add-ddr-08
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import (
|
||||||
|
|
||||||
"github.com/AdguardTeam/AdGuardHome/internal/aghos"
|
"github.com/AdguardTeam/AdGuardHome/internal/aghos"
|
||||||
"github.com/AdguardTeam/golibs/errors"
|
"github.com/AdguardTeam/golibs/errors"
|
||||||
|
"github.com/AdguardTeam/golibs/log"
|
||||||
"github.com/AdguardTeam/golibs/stringutil"
|
"github.com/AdguardTeam/golibs/stringutil"
|
||||||
"github.com/google/renameio/maybe"
|
"github.com/google/renameio/maybe"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
|
@ -22,17 +23,27 @@ import (
|
||||||
const dhcpcdConf = "etc/dhcpcd.conf"
|
const dhcpcdConf = "etc/dhcpcd.conf"
|
||||||
|
|
||||||
func canBindPrivilegedPorts() (can bool, err error) {
|
func canBindPrivilegedPorts() (can bool, err error) {
|
||||||
cnbs, err := unix.PrctlRetInt(
|
res, err := unix.PrctlRetInt(
|
||||||
unix.PR_CAP_AMBIENT,
|
unix.PR_CAP_AMBIENT,
|
||||||
unix.PR_CAP_AMBIENT_IS_SET,
|
unix.PR_CAP_AMBIENT_IS_SET,
|
||||||
unix.CAP_NET_BIND_SERVICE,
|
unix.CAP_NET_BIND_SERVICE,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
)
|
)
|
||||||
|
if err != nil {
|
||||||
|
if errors.Is(err, unix.EINVAL) {
|
||||||
|
// Older versions of Linux kernel do not support this. Print a
|
||||||
|
// warning and check admin rights.
|
||||||
|
log.Info("warning: cannot check capability cap_net_bind_service: %s", err)
|
||||||
|
} else {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Don't check the error because it's always nil on Linux.
|
// Don't check the error because it's always nil on Linux.
|
||||||
adm, _ := aghos.HaveAdminRights()
|
adm, _ := aghos.HaveAdminRights()
|
||||||
|
|
||||||
return cnbs == 1 || adm, err
|
return res == 1 || adm, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// dhcpcdStaticConfig checks if interface is configured by /etc/dhcpcd.conf to
|
// dhcpcdStaticConfig checks if interface is configured by /etc/dhcpcd.conf to
|
||||||
|
|
Loading…
Reference in New Issue