agkozak / agkozak-zsh-prompt

A fast, asynchronous Zsh prompt with color ASCII indicators of Git, exit, SSH, virtual environment, and vi mode status. Framework-agnostic and customizable.
MIT License
292 stars 26 forks source link

Printing error on non-root android termux #29

Closed lainiwa closed 3 years ago

lainiwa commented 4 years ago

On Android >7 (?) the access to /proc seems to be partly restricted by SELinux. This leads to error being printed when using prompt on termux (OSTYPE=linux-android):

_agkozak_async_init:6: permission denied: /proc/version
agkozak commented 4 years ago

Thanks so much for reporting this with all the most useful details. I shall work on a fix as soon as possible, and perhaps you can help me to test it out.

agkozak commented 4 years ago

I just put what should be a one-line fix on the android branch of this repo, but I don't have Android handy -- could you give it a try? Many thanks.

romkatv commented 4 years ago

Comparing $OSTYPE with linux-android is not a very robust way of detecting Android OS. $OSTYPE tells you about the build environment rather than the execution environment, and they aren't always the same. E.g., you can run Zsh compiled against musl libc on Android just fine, which normally would have OSTYPE set to linux-musl.

Since what you really care about is /proc/version being readable, it's a good idea to check that directly.

lainiwa commented 4 years ago

The android branch (0b6256e) is working for me.

However, given what @romkatv commented, I guess you might want to reconsider handling this as a special case? If you do -- I will then also check it against android's hardened /proc to see it is working.

agkozak commented 4 years ago

Thanks, @romkatv. I think I'll have to spin up Android in a VM and do this properly.

@lainiwa, I'm glad I've got something working for you for the time being. I'll try to have something permanent soon (I'm getting used to new eyeglasses, so I'm pacing myself).

agkozak commented 4 years ago

@lainiwa, I did what @romkatv suggested. Please give the android branch another pull and confirm that it works. Thanks!

lainiwa commented 4 years ago

Working great! Thanks for fixing the issue!

agkozak commented 4 years ago

If it's all right, I'll reopen this issue just until I've merged the new code into the master branch. I'll let you know when that's done.

agkozak commented 3 years ago

All right - the bug fix is now part of release v3.8.1 on the master branch. Thanks again for raising this issue.