Comments (3)
Hi,
Thanks for detailed report, quite refreshing to see one! Now lets get to business.
Firstly, your script2
and script3
commands are wrong. script3
will override the log.
echo "echo 2 mounted > ~/log" >> ~/.termux/tasker/script2
echo "echo 3 mounted > ~/log" >> ~/.termux/tasker/script3
It should be following:
echo "echo 2 mounted > ~/log" > ~/.termux/tasker/script2
echo "echo 3 mounted >> ~/log" > ~/.termux/tasker/script3
Secondly, Termux:Tasker does test if a file is an executable regular file or not, but it also automatically sets executable permission if script is under ~/.termux/tasker
when plugin action is run but not when selecting script in configuration screen, note setMissingPermissions
argument.
Anyways, as to detecting your problem, if you were on v0.5
of Termux:Tasker, which I'm thinking you are not, the configuration screen should have shown errors like Regular file not found at path
when entering script3
as executable. Moreover, %errmsg
would have returned same errors when running the plugin action. Check Plugin Variables. Also check Template tasks on how to properly read them.
The real issue seems to be mount namespace. When you mount inside Termux shell, you are not mounting in global mount namespace, but that of the Termux app process. So Termux:Tasker app process does not see the mount point, and does not see the script3
. Although, its weird that script2
that is run is the mounted one because of 2 mounted
in log
file instead of the unmounted one. Currently, not sure why, will need to investigate.
To mount in global namespace, if you are using my version of sudo, you can pass --mount-master
to --su-run-options
option. Or mount directly with su --mount-master -c mount --bind ~/test ~/.termux
sudo --su-run-options='--mount-master' mount --bind ~/test ~/.termux
sudo --su-run-options='--mount-master' mount | grep termux
sudo --su-run-options='--mount-master' umount ~/.termux~
You can confirm if you are in global namespace with the one liner by @mirfatif detailed here, including info on mount namespaces.
sudo su
[ "$(readlink /proc/self/ns/mnt)" = "$(readlink /proc/1/ns/mnt)" ] && echo 'In Global NS.' || echo 'Not in Global NS.'
exit
sudo --su-run-options='--mount-master' su
[ "$(readlink /proc/self/ns/mnt)" = "$(readlink /proc/1/ns/mnt)" ] && echo 'In Global NS.' || echo 'Not in Global NS.'
You can also change the mount namespace for all su
commands run from MagiskManager Mount Nampspace Mode
option, but its not advisable since that will create conflicts between apps, like for rootfs
ro
and rw
remounts.
Note that, I have tested with an internal updated version of Termux:Tasker, which uses my updated implementation of FileUtils
being used in Termux app since v0.109
as per termux/termux-app@d4fc34ca2, so you might in fact be on v0.5
but not get those errors mentioned, cause Java File
APIs are a complete mess.
from termux-tasker.
Hi. Thanks for the quick and detailed answer.
Firstly, your script2 and script3 commands are wrong. script3 will override the log.
Ah, indeed. But this is only a mistake I made writing the issue. I tested it with the correct syntax.
Anyways, as to detecting your problem, if you were on v0.5 of Termux:Tasker, which I'm thinking you are not, the configuration screen should have shown errors like Regular file not found at path when entering script3 as executable
No, that's right. I am on v0.5 and I did see these errors. I just ignored them for this issue as I think it should work.
The real issue seems to be mount namespace. When you mount inside Termux shell, you are not mounting in global mount namespace, but that of the Termux app process.
That actually explains a LOT. I've been having many different issues with mounting things with Termux for other apps, but I never figured out what exactly the reason for that was.
Although, its weird that script2 that is run is the mounted one because of 2 mounted in log file instead of the unmounted one. Currently, not sure why, will need to investigate.
Isn't that because the actual execution of the script is handed over to com.termux.app.TermuxService
, which is in the correct mount namespace?
termux-tasker/app/src/main/java/com/termux/tasker/FireReceiver.java
Lines 127 to 128 in 552d592
To mount in global namespace, if you are using my version of sudo, you can pass --mount-master to --su-run-options option. Or mount directly with su --mount-master -c mount --bind ~/test ~/.termux
I did not know about the different mount namespaces for android apps or the --mount-master
flag. I was under the impression that when we switch to root with su, we've left the Termux environment completely. I will give this a try.
from termux-tasker.
Hi. Thanks for the quick and detailed answer.
Welcome :)
I tested it with the correct syntax.
Oh, okay.
No, that's right. I am on v0.5 and I did see these errors. I just ignored them for this issue as I think it should work.
Well, at least should have mentioned that :p
That actually explains a LOT. I've been having many different issues with mounting things with Termux for other apps, but I never figured out what exactly the reason for that was.
Yeah, that is a pretty common problem.
Isn't that because the actual execution of the script is handed over to com.termux.app.TermuxService, which is in the correct mount namespace?
Yeah, you are right, that would be the reason. If you turn on isolated mount namespace mode in magisk, then it would return 2 normal
. (Will require unmount and app restart)
I did not know about the different mount namespaces for android apps or the --mount-master flag. I was under the impression that when we switch to root with su, we've left the Termux environment completely. I will give this a try.
That probably was true in the SuperSU era (well, my era technically), usually people disabled namespace separation for xposed modules, etc, and mounts worked everywhere. The magisk era is more strict for security and safety reasons. You can check this thread for more info.
Closing since not a Termux issue.
from termux-tasker.
Related Issues (20)
- Is the development of this plugin stopped? I can't install in on Android 14 HOT 1
- bash: extglob off in the plugin - not possible to enable it HOT 4
- Run scripts from the location they are saved in, instead of the destination of the softlink. HOT 3
- The argument not support file paths HOT 2
- App package conflicting HOT 1
- Cannot install: Failure [INSTALL_FAILED_SHARED_USER_INCOMPATIBLE] HOT 4
- change request: make com.termux.permission.RUN_COMMAND permission enforcement optional HOT 3
- Error installing Termux Tasker HOT 1
- I can't install this app on my Android HOT 1
- stdout not working with Tasker HOT 9
- Installation issue HOT 1
- httpie binary doesn't work in background HOT 9
- My script output dissappears immediately after running HOT 2
- Working directory doesn't seem to work if there are spaces in the name
- Actions downloads expired HOT 1
- "other plugin host apps"? HOT 1
- Readme unclear HOT 2
- Script not found HOT 9
- bash - "Arguments" doesn't accept bash commands HOT 3
- App icon stay showed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from termux-tasker.