Change:
assert(!(st.st_mode & (S_IWGRP | S_IWOTH))); // Read the path of the real (wrapped) program from <self>.real. <del> char realFN[PATH_MAX + 10]; int realFNSize = snprintf (realFN, sizeof(realFN), "%s.real", selfPath); assert (realFNSize < sizeof(realFN)); </del> <ins> char real_fn[PATH_MAX + 10]; int real_fn_size = snprintf(real_fn, sizeof(real_fn), "%s.real", self_path); assert(real_fn_size < sizeof(real_fn)); </ins> <del> int fdSelf = open(realFN, O_RDONLY); assert (fdSelf != -1); </del> <ins> int fd_self = open(real_fn, O_RDONLY); assert(fd_self != -1); </ins> <del> char sourceProg[PATH_MAX]; len = read(fdSelf, sourceProg, PATH_MAX); assert (len != -1); assert (len < sizeof(sourceProg)); assert (len > 0); sourceProg[len] = 0; </del> <ins> char source_prog[PATH_MAX]; len = read(fd_self, source_prog, PATH_MAX); assert(len != -1); assert(len < sizeof(source_prog)); assert(len > 0); source_prog[len] = 0; </ins> <del> close(fdSelf); </del> <ins> close(fd_self); </ins> // Read the capabilities set on the wrapper and raise them in to <del> // the Ambient set so the program we're wrapping receives the </del> <ins> // the ambient set so the program we're wrapping receives the </ins> // capabilities too! <del> make_caps_ambient(selfPath); </del> <ins> if (make_caps_ambient(self_path) != 0) { free(self_path); return 1; } free(self_path); </ins> <del> execve(sourceProg, argv, environ); </del> <ins> execve(source_prog, argv, environ); </ins> fprintf(stderr, "%s: cannot run `%s': %sn", <del> argv[0], sourceProg, strerror(errno)); </del> <ins> argv[0], source_prog, strerror(errno)); </ins> <del> exit(1); </del> <ins> return 1; </ins> }

Discussion:
Describe the bug After update libcap from to error working capabilites. and Netdata configuration: Wrappers cat: Notify maintainers cc
If it's being denied by apparmor, it should say something along those lines in the kernel log. Are you actually running apparmor though?
The apparmor service is in use. Does not write an error in the logs. Disabling apparmor service doesn't fixed error: Worked with this patch:
Sorry, don't maintain neither netdata nor apparmor.
So basically apparmor 2.13.6 introduced this regression?
Sorry, wrong checked. Working with branch , with branch - not working - . Compare - Looking for a error further.
The diff between these versions is quite small I don't think that should be responsible.
Found. Working with rollback libcap to
In kernel 5.8 new capability - - Service netdata with add not working:
Problem with version . Step to reproduce Add to configuration: and running from user: In version 20.09 correct work, in master - bad work - .
cc libcap contributors -
Working with revert this commit - Need support new output of the program from to
Maybe also report the bug here, since you have a reproducible bug:
cc since the bug tracker seems to be unused.
This error is not reproducible in another distribution. Checked on ArchLinux - not reproduced.
The bug tracker is used. It is just the case that there are no open bugs right now. Please file a bug there if you believe libcap has a bug. Please include an example sufficient to reproduce it.
This error reproduced only NixOS. I can build a live-cd with this error. Can you use this variant?
Ok. Thanks. I think this is not a bug but rather an incompatibility regarding captotext output that changed.
The output format did become more compact in 2.41. This default output format also changed with the resurrection of meaningful support for in 2.29. That change is potentially more significant: Note: the official sources for libcap are here:
FWIW I would have suggested using the iab abstraction in libcap (introduced in libcap-2.33).

What you are trying to do would then look like this: capt working = capgetproc(); capiabt iab = capiabinit(); capiabfill(iab, CAPIABAMB, working, CAPPERMITTED); capiabsetproc(iab); capfree(iab); cap_free(working);
But how does one get the capabilities of a file without string parsing?
capt working = capget_file("/the/file/of/interest");
Perhaps I misunderstood? If you want to load the capabilities from a text string and not from the file-capabilities of the file itself: capt working = capfromtext("..."); That is, capt is libcap's abstraction for a capability set and you are trying to import them from somewhere. There is also a portable binary format capcopyext()/capcopyint(). However, there haven't been many users of this - the draft 1e spec intended it for things like tar and cpio to use.
We basically use both. Our setcap wrapper has capabilities set on its file and it will convert those to ambient capabilities at runtime. It seems that iab abstraction was not there when the original code was written. So there was no obvious way of using capt to set ambient capabilities.