Tasker sdcard access and root

80 views
Skip to first unread message

adrenochrome

unread,
Oct 6, 2017, 3:49:45 PM10/6/17
to Tasker
Hello,

I made an app exported through App Factory

The app is creating a shell script using a "file/write file" task in mydir/myscript.sh
and then the shell script is executed using a "code/run shell" task using "sh /sdcard/mydir/myscript.sh param1 param2" with root switch enabled.
(i have to explicitly use the sh command since the execute flag cant be set in /sdcard partitions)

Since the shell has to be launched everytime i unlock the phone, there is always a quick popup from the root app like "root perm was given to your app".
I could disable this popup notification in the root app but it would mean no more root warning for any other app too.

So, i would like to run my "code/run shell" task without the root switch,
but it fails because of the shell script not being readable from the user owning the system task.

i could copy the shell script everytime to /data/local/tmp/ to allow it to be executable but it would be ressource consuming and so inelegant.

I tried to add android.permission.READ_EXTERNAL_STORAGE  in the extra permissions from the export module from app factory but there is no impact.
(i checked in the generated AndroidManifest.xml and the perm is present and correctly written)

Any idea on how to run a shell script without root ? (i dont want to put the file somewhere else because it has to be easily accessible for end users modifications)

Then another mystery is how Tasker's "file/write|read file" (or even "code/run shell" on files that have the execute flag set) is able to access files with any root permissions ?


thanks in advance for your advices

adrenochrome

unread,
Oct 6, 2017, 4:23:58 PM10/6/17
to Tasker
a good solution would be to manage to get a permanent global root permission for my app, this way the root granting popup would be seen only a single time at launch. i tried android.permission.ACCESS_SUPERUSER but it did not the trick

adrenochrome

unread,
Oct 7, 2017, 7:43:54 AM10/7/17
to Tasker
ok, there is definately a problem with the user context of shell execution

to compensate to the lack of file access, i tried to put directly the content of the shell script in the task instead of calling it through the sh command
and it fails on writing on a file which i have rights over

TASKER (without root flag) :
ls -l /sys/class/leds/yellow/blink                           
-> -rw-rw-rw- root     root         4096 2017-10-07 12:15 blink
echo 255 >/sys/class/leds/yellow/blink
-> fail sh: <stdin>[2]: can't create /sys/class/leds/yellow/blink: Permission denied
so i check the user :
id
echo "shell is ${SHELL:-undef}"
-> uid=10148(u0_a148) gid=10148(u0_a148) groups=10148(u0_a148), 3001(net_bt_admin),3002(net bt),3003(inet),9997(everybody),50148(all_a148) context=u:r:untrusted_app:s0:c512,c768
shell is undefined

ADB SHELL :
ps | grep tasker
-> u0_a148   30811 753   2156340 163428 SyS_epoll_ 0000000000 S net.dinglisch.android.taskerm
su - u0_a148
->ok
ls -l /sys/class/leds/yellow/blink                           
-> -rw-rw-rw- root     root         4096 2017-10-07 12:15 blink
echo 255 >/sys/class/leds/yellow/blink
-> OK the led is blinking as what i expect from beginning
id
echo "shell is ${SHELL:-undef}"
-> uid=10148(u0_a148) gid=10148(u0_a148) groups=10148(u0_a148) context=u:r:su:s0
shell is /system/bin/sh

why so much differences between the two environments ? and why so much restrictions for tasker environment ?

i even tried in tasker
su - u0_a148
but it grant root permission (root manager display the "root perm was given to your app" ) WITHOUT the root flag checked in the task

i fear there's little hope for me to run things from tasker with a non-root normally permissive user/environment, so my only hope is to find a way for a permanent global root permission if possible.... but how to do this ?
Reply all
Reply to author
Forward
0 new messages