Skip to content
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

Permission denied (src/ip_resolver.cpp:542) #248

Closed
HITers2018 opened this issue Dec 29, 2022 · 17 comments
Closed

Permission denied (src/ip_resolver.cpp:542) #248

HITers2018 opened this issue Dec 29, 2022 · 17 comments

Comments

@HITers2018
Copy link

I guess the latest proot or proot-distro may have some bugs. If I install python and jupyter notebook in termux directly , ipykernel can work well. But if I install python and jupyter notebook in alpine (with the latest proot-distro), it gets the err 'Permission denied (src/ip_resolver.cpp:542)' and the ipykernel cannot start. The bug also influence users who upgrade proot and proot-distro.
Here are the codes I use to install python and jupyter notebook.

proot-distro install alpine
proot-distro login alpine
apk add python3
python3 -m ensurepip
pip3 install wheel
apk add gcc python3-dev
apk add build-base libjpeg-turbo-dev zlib-dev libxslt-dev jpeg-dev openjpeg libxft libzmq qhull pixman cairo libgfortran openblas-dev brotli-dev freetype-dev libffi-dev
pip3 install notebook

if you run jupyter notebook --allow-root and open a notebook, console displays the err 'Permission denied (src/ip_resolver.cpp:542)' and the ipykernel cannot start.
Screenshot_2022-12-29-11-21-30-411_com termux

@HITers2018
Copy link
Author

I just found that the bug only appears on my android 13 device (miui14), so the problem may be caused by android 13. It is strange that ipykernel runs well in termux directly but cannot run in termux-proot. Is it possible to solve the problem?

@michalbednarski
Copy link
Collaborator

As a workaround you can LD_PRELOAD following library to make libzmq believe that getifaddrs() is unavailable as in WSL:

#include <errno.h>
#include <ifaddrs.h>
int getifaddrs(struct ifaddrs **ifap) {
	errno = EOPNOTSUPP;
	return -1;
}
gcc skip_getifaddrs.c -o skip_getifaddrs.so -shared
LD_PRELOAD=/root/skip_getifaddrs.so jupyter notebook --allow-root

Proper solution would be probably to ask libzmq to not abort() when getifaddrs() reports EACCES (due to SELinux denial). Bionic, unlike glibc, knows about RTM_GETLINK being unavailable and is able to handle that case, but ultimately I'd say that the bug is libzmq crashing when getifaddrs() reports unexpected errno


Besides RTM_GETLINK unavailability, getifaddrs() in glibc (but not in musl) hiccups at attempting doing bind() on AF_NETLINK socket so errno there comes from bind(). In musl, errno comes from sendto(..., {nlmsg_type=RTM_GETLINK}) (which would also happen in glibc if we'd skip bind()). In both cases errno is set to EACCES

Overriding bind() error however is in my opinion risks breaking other uses and implementing sendto(..., {nlmsg_type=RTM_GETLINK}) would introduce significant amount of state into proot, so I'd like to avoid doing these on proot side

@feer9
Copy link

feer9 commented May 27, 2023

Hey, same issue here trying to run Spyder IDE inside of Termux. The workaround mentioned above works, but is there any chance this gets fixed upstream? Do libzmq maintainers know about this? Just asking to know if I should file an issue there.

@HITers2018
Copy link
Author

i have not reported it to libzmq maintainers, so you can file the issuse there if you want the issuse to be fixed upatream.

@ericli2333
Copy link

@HITers2018 I met the same problem today. So how did you deal with it? Have you found a good solution rather than change the cpp file?

@HITers2018
Copy link
Author

i just use the workaround mentioned above, maybe it is better to get the help from the libzmq maintainers. the workaround is easy and useful, which is just a hook by using LD_PRELOAD. it does not change any cpp source file.

@feer9
Copy link

feer9 commented Aug 30, 2023

Yeah, I ended up using the workaround too. I wanted to report the bug but didn't take the time to present it properly to the devs

@Cateners
Copy link

I asked Bing to help me write the code for using the getifaddrs function in Android within a proot container. This code does work for me.
https://github.com/Cateners/tiny_computer/tree/master/extra/getifaddrs_bridge

@ashengstd
Copy link

i encoutered the same probem in a flutter based code-server gui app, but it seems that no option is available in code-server to add the environment variable, is there any way to fix the problem, or how to make it work in vscode?

@ericli2333
Copy link

i encoutered the same probem in a flutter based code-server gui app, but it seems that no option is available in code-server to add the environment variable, is there any way to fix the problem, or how to make it work in vscode?

Actually, I gave it up long ago.But I remember that before I gave it up, I used the proot environment to run the code-server or the jupyter. And that works. You can refer to my blog And follow my steps to make it work.My blog is written in Chinese, and you may try to use Google translator to understand it.

@josesho
Copy link

josesho commented Jul 13, 2024

The workaround wasn't successful for me. Am on Android 14, running proot-distro Ubuntu. I believe I've linked the library properly; see below.

Any help would be appreciated! Else I will just use virtualenv in Termux itself instead of Conda... :(
Screenshot_20240713_102402_Termux

@josesho
Copy link

josesho commented Jul 14, 2024

OK, I realize you have to run the full command each time.

LD_PRELOAD=/root/skip_getifaddrs.so jupyter lab --allow-root

This works! Yay!!

@ericli2333
Copy link

congratulation, actually even i fail from time to time. this proot is not that stable.

@josesho
Copy link

josesho commented Jul 14, 2024

For reference, this was the full list of steps I followed to successfully install Ubuntu in Termux via proot-distro, then get conda and Jupyter running inside the proot distro, and lastly having to manually create Jupyter kernels in the correct folder so Jupyter can see them.

https://www.notion.so/josesho/Installing-Analytics-Stack-in-Termux-4a6ff82d32974db4a4de27ee5e24ba45

@sofair
Copy link

sofair commented Sep 26, 2024

I managed to patch libzmq by changing EINVAL(22) to EACCES(13), So zmq can return before the assertion fail.
Patch the aarch64 binary with
perl -pi -e "/\x1F\x7C\x01\x71\x04\x18\x56\x7A\x60\x0E\x00\x54/\x1F\x7C\x01\x71\x04\x18\x56\x7A\x6E\x0E\x00\x54/g" /path/to/libzmq.so.5.2.5

@feer9
Copy link

feer9 commented Sep 28, 2024

I managed to patch libzmq by changing EINVAL(22) to EACCES(13), So zmq can return before the assertion fail. Patch the aarch64 binary with perl -pi -e "/\x1F\x7C\x01\x71\x04\x18\x56\x7A\x60\x0E\x00\x54/\x1F\x7C\x01\x71\x04\x18\x56\x7A\x6E\x0E\x00\x54/g" /path/to/libzmq.so.5.2.5

Won't that work only for the specific build you have?

@pedropalb
Copy link

I tried to use @michalbednarski's workaround. But, after starting jupyter with LD_PRELOAD=./skip_getifaddrs.so jupyter notebook, when I create a new notebook with a given kernel, I get a double free or corruption (out) error:

[I 2024-12-26 08:32:52.562 ServerApp] Creating new notebook in /notebooks
[I 2024-12-26 08:32:52.657 ServerApp] Saving Untitled3.ipynb
[I 2024-12-26 08:32:53.561 ServerApp] Saving file at /notebooks/Untitled3.ib
[I 2024-12-26 08:32:53.591 ServerApp] Saving Untitled3.ipynb
double free or corruption (out)
zsh: abort      LD_PRELOAD=./skip_getifaddrs.so jupyter notebook

Did anyone face the same issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants