Permission Denied for SO_DEBUG socket option inside docker
I’ve isolated the
Permission Denied exception being thrown inside one of my test case to these lines –
... ASSERT_EQ(0, getsockopt(s.getSocket(), SOL_SOCKET, SO_DEBUG, &optval, &optlen)); ... ... ASSERT_EQ(0, setsockopt(s.getSocket(), SOL_SOCKET, SO_DEBUG, &optval, optlen)); ...
These work fine while running test executable with
sudo on my local machine eg.
sudo ./test/testexe and all test pass, no exception is thrown. To run these without
sudo, I’ve tried setting capabilities prior to executing tests eg.
sudo setcap "cap_net_admin+ep cap_net_raw+ep" test/testexe which again runs fine without
sudo this time on my local machine.
The problem arises with docker where none of the methods work – neither
sudo helps and exception is still thrown nor does the
setcap method which successfully sets the capabilities but an error
Operation not permitted is shown when executing tests.
So is there any other way of running
SO_DEBUG lines successfully but without running docker with elevated privileges since I get control only inside the docker container with my CI platform.