-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Kernel before 5.6.X (April 2020): superuser rights needed / setsockopt: Operation not permitted #4
Comments
setsockopt normally works as normal user. However I know that systemd enforces some restrictions, like certain directories are not writeable. Please try |
Done, posted at: https://stackoverflow.com/questions/69994803/setsockopt-for-systemd-unit-error-operation-not-permited Let's see if there are any answers. |
I've got the same issue:
however
works perfectly. The problem is I have to run a different application which cannot bind to any interfaces and I don't know what to do. I've found some interesting info and posted it here: https://unix.stackexchange.com/questions/679881/setsockopt-operation-not-permitted-error-when-trying-to-use-bindtointerface-u |
Hi birdie-github. Could it be an Apparmor / SELinux issue? You could try disabling this. Somewhere I've read, that binding to interface needs CAP_NET_RAW privilige. You can try by
To remove all capabilities after testing you can use |
Now it produces no errors but it does NOT work:
And it cannot work: https://stackoverflow.com/questions/18058426/does-using-linux-capabilities-disable-ld-preload
strace however shows that with |
Thanks for giving the hint, that setting capabilities will not work with preloaded libraries.
and try again. Since the source code is public and it is quite it is ok from a security point of view. |
(# - running under root, $ - running under a normal user account). I see no AppArmor related messages in system logs. |
The following commands:
make the errors disappear but the issue remains. |
I could now reproduce the error and try to find a solution. In the meantime you don't need to try anything. |
@birdie-github You seem to have also a lot of linux experience. Soruce-Code of curl #ifdef SO_BINDTODEVICE
/* I am not sure any other OSs than Linux that provide this feature,
* and at the least I cannot test. --Ben
*
* This feature allows one to tightly bind the local socket to a
* particular interface. This will force even requests to other
* local interfaces to go out the external interface.
*
*
* Only bind to the interface when specified as interface, not just
* as a hostname or ip address.
*
* interface might be a VRF, eg: vrf-blue, which means it cannot be
* converted to an IP address and would fail Curl_if2ip. Simply try
* to use it straight away.
*/
if(setsockopt(sockfd, SOL_SOCKET, SO_BINDTODEVICE,
dev, (curl_socklen_t)strlen(dev) + 1) == 0) {
/* This is typically "errno 1, error: Operation not permitted" if
* you're not running as root or another suitable privileged
* user.
* If it succeeds it means the parameter was a valid interface and
* not an IP address. Return immediately.
*/
return CURLE_OK;
}
#endif So sourcecode of curl expects this to fail without root priviliges. Despite it works. Perhaps you have an idea what is different there. |
No, it fails, I've checked it using
curl binds to the IP address instead. Maybe folks at stackexchange have something to say: https://unix.stackexchange.com/questions/679881/setsockopt-operation-not-permitted-error-when-trying-to-use-bindtointerface-u I've no idea either. Not a lot of actual info on the topic and I'm not a good C programmer to read the kernel source code. This is definitely an issue with Ubuntu. I cannot reproduce it locally with Fedora 35 despite having SeLinux enabled. |
Very strange behaviour First I thought it depends on the kernel version, because on Raspberry PI with Debian Buster and Kernel version 4.x it fails, whereas it works with kernel version 5.x. However on Ubuntu with Kernel version 5.x it also fails. Debian Buster amd64 Kernel v4.x
Debian Buster Kernel 5.x (Raspberry PI)
Debian Buster Kernel v4.x (Raspberry PI)
Ubuntu 20.04.3 LTS
|
Please update the bug title to indicate that it affects Ubuntu/Debian and not necessarily other Linux distros. And |
Information (courtesy or https://unix.stackexchange.com/users/325065/uncle-billy ):
So, the issue is down to an old kernel. I wonder if you could code this feature. |
If I understand this correct: You continue executing |
Yeah, I'm now thinking of how to install a newer kernel because doing everything else is just too much hassle. This bug report is probably safe to close. Maybe you could add Linux kernel >= 5.6 as a requirement in README.md. Thank you for your swift response anyways. Really appreciated. |
Thank you for your praise. I've already included that superuser rights are required prior to kernel 5.6.x. Maybe that is also an option for you instead of installing a new kernel that isn't shipped with your Ubuntu version. |
I need to run chromium, so superuser is not an option (even if the application allowed that, I'd never run a web browser under root - too dangerous). Anyways, installing kernel 5.11 has solved all my issues. Thanks again. |
Of course you're right, never run a web browser as root. |
I've tried the 5.11 kernel using the exact setup in the initial post. Unfortunately, although no error is thrown either via systemctl status or journalctl, the deluge process doesn't seem to be bound to that specific interface. This I verify by running network activity monitoring tools (eg: speedometer) that clearly show the deluge process throwing traffic across multiple interfaces. To this end, with kernel 5.11 the deluge process doesn't even seem to obey the metric parameter in network manager configuration. I had to revert to 5.4 kernel, and unfortunately rely on route metric as an overall system priority for traffic. Any suggestions greatly appreciated, some exact scenarios to run on 5.11 kernel to verify bindtointerface actually works as part of systemd units. Thank you! |
What is the result when using
without any systemd unit on kernel 5.11? |
I first stop the daemon via
deluge runs under its own user so first I had to run
I then run
I get no error message and the daemon starts up and I can connect to it via the web interface I use nmcli to edit the ipv4.route-metric value to make it equal between the two interfaces
However, both
Thank you for looking into this. PS: Of course:
|
According to https://torguard.net/knowledgebase.php?action=displayarticle&id=215 deluge supports Sock5 proxy. I think the easiest solution is to use microsocks which can be bound to specific interface and setup deluge to use this socks proxy, see https://github.com/JsBergbau/BindToInterface#microsocks |
Hello,
I'm trying to run BindToInterface in a script as part of a systemd service that runs under its own separate user.
The service file looks like this:
The script is as follows:
when executing:
systemctl status deluged
I get the following output:
bash[503711]: setsockopt: Operation not permitted
Is there a way to run your tool without elevated privileges?
Thanks
The text was updated successfully, but these errors were encountered: