Cannot bind to port 80 with normal user despite setting cap_net_bind_service=ep on binary
0
votes
0
answers
43
views
I want to bind to port 80 using
cap_net_bind_service
using normal user.
I enabled cap_net_bind_service
capability on the binary using sudo setcap cap_net_bind_service+ep server
Inside the code, I make sure the correct cap is set by writing out what the current caps are
cap_t cap = cap_get_pid(pid);
if (cap == NULL) {
perror("cap_get_pid");
}
caps_text = cap_to_text(cap, NULL);
if (caps_text) {
printf("capturing: %s\n", caps_text);
}
And I got the expected output capturing: cap_net_bind_service=ep
.
When checking the process cap by cat /proc/pid/status | grep Cap
, I found
CapInh: 0000000000000000
CapPrm: 0000000000000400
CapEff: 0000000000000400
CapBnd: 000001ffffffffff
CapAmb: 0000000000000000
Questions:
1. But when I still got the error binding: Permission denied
2. How do know which bit correspond to which cap in such output 0000000000000400
?
Asked by Tran Triet
(715 rep)
Feb 18, 2025, 09:43 PM