Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 945837 - net-dns/knot-3.4.2: error: cannot bind address […] UDP (operation not permitted) and also `info: process not allowed to set capabilities, skipping`
Summary: net-dns/knot-3.4.2: error: cannot bind address […] UDP (operation not permitt...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Pierre-Olivier Mercier
URL:
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks:
 
Reported: 2024-12-04 02:43 UTC by Thibaud CANALE
Modified: 2024-12-08 01:46 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info net-dns/knot (file_945837.txt,21.21 KB, text/plain)
2024-12-04 02:43 UTC, Thibaud CANALE
Details
net-dns/knot-3.4.2 build log.gz (net-dns:knot-3.4.2:20241204-013055.log.gz,29.74 KB, application/gzip)
2024-12-04 02:45 UTC, Thibaud CANALE
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thibaud CANALE 2024-12-04 02:43:24 UTC
Created attachment 913283 [details]
emerge --info net-dns/knot

Service knot under version 3.4.2 crashes just after calling `rc-service knot start` — not during — with this error in its log:
```
2024-12-04T03:06:54+0100 info: Knot DNS 3.4.2 starting
2024-12-04T03:06:54+0100 info: loaded configuration file '/etc/knot/knot.conf', mapsize 500 MiB
2024-12-04T03:06:54+0100 info: using UDP reuseport, incoming TCP Fast Open
2024-12-04T03:06:54+0100 info: binding to interface <IP addr>
2024-12-04T03:06:54+0100 error: cannot bind address <IP addr> UDP (operation not permitted)
2024-12-04T03:06:54+0100 critical: failed to configure server
```

with `IP addr` the address from the `listen` directive; with the `@port` inside, also tested without.

However, without any `listen` directives, the logs got those messages, the one about capabilities:
```
2024-12-04T03:07:29+0100 info: Knot DNS 3.4.2 starting
2024-12-04T03:07:29+0100 info: loaded configuration file '/etc/knot/knot.conf', mapsize 500 MiB
2024-12-04T03:07:29+0100 warning: no network interface configured
2024-12-04T03:07:29+0100 info: process not allowed to set capabilities, skipping
2024-12-04T03:07:29+0100 info: loading […] zones
../..
```

As we can see in the emerge output, the USE flag `caps` is already set:
```
[ebuild     U ~] net-dns/knot-3.4.2:0/15.9.4::gentoo [3.2.9:0/13.9.4::gentoo] USE="authsignal%* caps cookies daemon%* dnsproxy fastparser idn noudp onlinesign queryacl rrl stats synthrecord utils whoami -dbus% -dnstap -doc -doh -geoip -pkcs11% -quic -systemd -test% -xdp (-libidn2%*)" 1,595 KiB
```

For information, this is the same configuration than previous version 3.2.9, which still works after downgrading to restore service.

Note: I also saw an error about failing to load a zone, a zone which is currently working and was dumped from version 3.2.9, but I guess this is worth another issue, later.
Comment 1 Thibaud CANALE 2024-12-04 02:45:12 UTC
Created attachment 913284 [details]
net-dns/knot-3.4.2 build log.gz
Comment 2 Nicolas PARLANT 2024-12-04 10:20:30 UTC
Two ways to start knot :

- default with 3.2.X and init script :
knotd starts as root and drops itself extra capabilities after the daemon successfully starts. In this way, knot needs useflags caps.

- default with 3.4.X and init-1 script : 
knotd starts with unprivileged user and capabilities are handled by openrc. In this way, openrc needs useflags caps. Capabilities should also be set in init script :
capabilities="^cap_net_bind_service,^cap_setpcap"

You could refer to knot-resolver : https://gitweb.gentoo.org/repo/gentoo.git/tree/net-dns/knot-resolver/files/kresd.initd-r2

Maybe init script needs (commented or not) capabilities by default.

Maybe your issue with file zone is about privileges too.
Comment 3 Nicolas PARLANT 2024-12-04 10:27:10 UTC
Could you post the server block of your config ?
Comment 4 Larry the Git Cow gentoo-dev 2024-12-04 12:58:14 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=76953cdb865f54195a77df8a48899b59db54049e

commit 76953cdb865f54195a77df8a48899b59db54049e
Author:     Nicolas PARLANT <nicolas.parlant@parhuet.fr>
AuthorDate: 2024-12-04 10:45:20 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2024-12-04 12:57:07 +0000

    net-dns/knot: setcap for OpenRC init script. Add confd
    
    Set capabilities by default in init, as systemd service.
    No dep for openrc[caps] as it will be forced soon.
    Bug: https://bugs.gentoo.org/945837
    
    Signed-off-by: Nicolas PARLANT <nicolas.parlant@parhuet.fr>
    Closes: https://github.com/gentoo/gentoo/pull/39588
    Signed-off-by: Sam James <sam@gentoo.org>

 net-dns/knot/files/knot-2.init    |  44 ++++++++++
 net-dns/knot/files/knot.confd     |   7 ++
 net-dns/knot/knot-3.4.2-r1.ebuild | 167 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 218 insertions(+)
Comment 5 Thibaud CANALE 2024-12-04 16:18:16 UTC
Hello,

Thanks Nicolas for your work.

(In reply to Nicolas PARLANT from comment #2)
> Maybe your issue with file zone is about privileges too.

No, I noticed a bit late in "Functionality" from "Upgrade 3.2.x to 3.3.x" this entry:
https://www.knot-dns.cz/docs/3.4/singlehtml/index.html#functionality
> Semantic checks don't allow DS record at non-delegation point.


(In reply to Nicolas PARLANT from comment #3)
> Could you post the server block of your config ?

Here it is:
```
server:
  version: # empty to disable version of the server software TXT response
  rundir: /run/knot
  user: knot:knot
  listen: ["<IPv6_addr>@53", "<IPv4_addr>@53"]
```
Comment 6 Thibaud CANALE 2024-12-04 16:32:04 UTC
I just updated with your new modifications, it works, thanks. (don’t forget to clean the unused init file ;-))

You can mark as resolved IMHO.
Comment 7 Thibaud CANALE 2024-12-04 16:41:00 UTC
One more comment, should we push upstream the issue about `info: process not allowed to set capabilities, skipping`, which is not displayed before the error when binding?

I think it would have save me some time in debugging.
Comment 8 Nicolas PARLANT 2024-12-04 17:02:11 UTC



(In reply to Thibaud CANALE from comment #5)
> No, I noticed a bit late in "Functionality" from "Upgrade 3.2.x to 3.3.x"
> this entry:
> https://www.knot-dns.cz/docs/3.4/singlehtml/index.html#functionality
> > Semantic checks don't allow DS record at non-delegation point.
This is the problem of skipping too many versions.


(In reply to Thibaud CANALE from comment #6)
> You can mark as resolved IMHO.
I can't change status myself, you should.

(In reply to Thibaud CANALE from comment #7)
> One more comment, should we push upstream the issue about `info: process not
> allowed to set capabilities, skipping`, which is not displayed before the
> error when binding?> 
> I think it would have save me some time in debugging.
I think these are normal steps: binding with privileges then set capabilities. But you couldn’t do either.
Comment 9 Thibaud CANALE 2024-12-07 16:36:43 UTC
(In reply to Nicolas PARLANT from comment #8)
> (In reply to Thibaud CANALE from comment #6)
> > You can mark as resolved IMHO.
> I can't change status myself, you should.

Done.

> (In reply to Thibaud CANALE from comment #7)
> > One more comment, should we push upstream the issue about `info: process not
> > allowed to set capabilities, skipping`, which is not displayed before the
> > error when binding?> 
> > I think it would have save me some time in debugging.
> I think these are normal steps: binding with privileges then set
> capabilities. But you couldn’t do either.

Okay, I thought capabilities was necessary to "bind with privileges" without being root (for "privileges" port of course).
Comment 10 Nicolas PARLANT 2024-12-08 01:46:40 UTC
> > (In reply to Thibaud CANALE from comment #7)
> Okay, I thought capabilities was necessary to "bind with privileges" without
> being root (for "privileges" port of course).
Yes, it is. 

For your log :
- When listen is defined, knotd cannot bind because it was started by unprivileged knot user, without capabilities > critical error
- When listen is not defined, knotd does not use any default values, does not consider this as a critical error, continues without binding and then : 
     * sets new uid/gid but process is already run as knot:knot as defined
     * drops capabilities. And log msg can be misinterpreted. For knotd process, "not allowed to set capabilities" = "process has no capabilities to drop".

Confusion comes too from my first message, that was incorrect : 
- default with 3.2.X and init script :
knotd starts as root, *binds to interfaces and updates process to unprivileged user defined* after the daemon successfully starts.