Skip to content

Commit

Permalink
Pull request: fix binding capability defining
Browse files Browse the repository at this point in the history
Merge in DNS/adguard-home from 2391-updating-bug to master

Updates #2391.
Updates #2231.

Squashed commit of the following:

commit b321884
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Fri Dec 4 16:54:20 2020 +0300

    all: log changes

commit 5aa0202
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Fri Dec 4 14:42:10 2020 +0300

    sysutil: fix binding capability defining
  • Loading branch information
EugeneOne1 authored and Blakhard committed Dec 10, 2020
1 parent a2b4dd4 commit e48c4cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ and this project adheres to

### Changed

- Post-updating relaunch possibility is now determined OS-dependently ([#2231]).
- Post-updating relaunch possibility is now determined OS-dependently ([#2231], [#2391]).
- Made the mobileconfig HTTP API more robust and predictable, add parameters and
improve error response ([#2358]).
- Improved HTTP requests handling and timeouts. ([#2343]).
- Our snap package now uses the `core20` image as its base [#2306].
- Improved HTTP requests handling and timeouts ([#2343]).
- Our snap package now uses the `core20` image as its base ([#2306]).
- Various internal improvements ([#2271], [#2297]).

[#2231]: https://github.com/AdguardTeam/AdGuardHome/issues/2231
Expand All @@ -39,6 +39,7 @@ and this project adheres to
[#2306]: https://github.com/AdguardTeam/AdGuardHome/issues/2306
[#2343]: https://github.com/AdguardTeam/AdGuardHome/issues/2343
[#2358]: https://github.com/AdguardTeam/AdGuardHome/issues/2358
[#2391]: https://github.com/AdguardTeam/AdGuardHome/issues/2391

### Fixed

Expand Down
7 changes: 6 additions & 1 deletion internal/sysutil/os_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import (

func canBindPrivilegedPorts() (can bool, err error) {
cnbs, err := unix.PrctlRetInt(unix.PR_CAP_AMBIENT, unix.PR_CAP_AMBIENT_IS_SET, unix.CAP_NET_BIND_SERVICE, 0, 0)
return cnbs == 1, err
// Don't check the error because it's always nil on Linux.
adm, _ := haveAdminRights()

return cnbs == 1 || adm, err
}

func setRlimit(val uint) {
Expand All @@ -26,6 +29,8 @@ func setRlimit(val uint) {
}

func haveAdminRights() (bool, error) {
// The error is nil because the platform-independent function signature
// requires returning an error.
return os.Getuid() == 0, nil
}

Expand Down

0 comments on commit e48c4cf

Please sign in to comment.