Giter Site home page Giter Site logo

Comments (3)

agnostic-apollo avatar agnostic-apollo commented on July 24, 2024

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.

Neo-Oli avatar Neo-Oli commented on July 24, 2024

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?

// Send execution intent to TERMUX_SERVICE
PluginResultsService.sendExecuteIntentToExecuteService(context, this, intent, executionIntent, !inTerminal);

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.

agnostic-apollo avatar agnostic-apollo commented on July 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.