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

[Bug]: subprocess.Popen not working to run scripts that call /usr/bin/env in the shebang line on Android 14 #22666

Open
finagolfin opened this issue Dec 23, 2024 · 1 comment
Labels
android-14 bug report Something is not working properly

Comments

@finagolfin
Copy link
Member

Problem description

I'm trying out some build scripts on Android 14 AArch64 and seeing execution issues. Here's a reduced example:
foo.bash

#!/usr/bin/env bash
ls

test.py

import subprocess
subprocess.Popen(['/data/data/com.termux/files/home/termux-packages/foo.bash'])

Running source foo.bash works fine, but the commands below fail:

Traceback (most recent call last):
  File "/data/data/com.termux/files/home/termux-packages/test.py", line 2, in <module>
    subprocess.Popen(['/data/data/com.termux/files/home/termux-packages/foo.bash'])
  File "/data/data/com.termux/files/usr/lib/python3.12/subprocess.py", line 1026, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/data/data/com.termux/files/usr/lib/python3.12/subprocess.py", line 1953, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/data/data/com.termux/files/home/termux-packages/foo.bash'

What steps will reproduce the bug?

chmod 700 foo.bash
python test.py

What is the expected behavior?

The build scripts that do this were working fine on Android 13 AArch64. I'm working around it for now by modifying the failing build scripts, as the bash script works through Python if I change the first line to #!/data/data/com.termux/files/usr/bin/env bash.

I thought Termux intercepts such scripts and swaps out the right Termux-prefixed path: is this broken in Android 14?

System information

Termux Variables:
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP__APK_RELEASE=F_DROID
TERMUX_APP__APP_VERSION_CODE=1020
TERMUX_APP__APP_VERSION_NAME=0.119.0-beta.1
TERMUX_APP__DATA_DIR=/data/user/0/com.termux
TERMUX_APP__IS_DEBUGGABLE_BUILD=false
TERMUX_APP__IS_INSTALLED_ON_EXTERNAL_STORAGE=false
TERMUX_APP__PACKAGE_NAME=com.termux
TERMUX_APP__TARGET_SDK=28
TERMUX_VERSION=0.119.0-beta.1
TERMUX__SE_FILE_CONTEXT=u:object_r:app_data_file:s0:c55,c257,c512,c768
TERMUX__SE_INFO=default:targetSdkVersion=28:complete
TERMUX__SE_PROCESS_CONTEXT=u:r:untrusted_app_27:s0:c55,c257,c512,c768
TERMUX__USER_ID=0
Packages CPU architecture:
aarch64
Updatable packages:
All packages up to date
termux-tools version:
1.44.6
Android version:
14
Kernel build information:
Linux localhost 5.15.123-android13-8 #1 SMP PREEMPT Mon Aug 19 2024 aarch64 Android
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
@finagolfin finagolfin added bug report Something is not working properly untriaged android-14 and removed untriaged labels Dec 23, 2024
@agnostic-apollo
Copy link
Member

Install termux-exec package from #18872

termux/termux-exec#24 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android-14 bug report Something is not working properly
Projects
None yet
Development

No branches or pull requests

2 participants