[Q] Detect when superuser permission denied in app - Java for Android App Development

Hi,
I am developing an app that requires root permissions to run some shell commands to capture ouput. I am executing the "su" command to get root permission and it works fine when the su permission is granted. However I would like to know how to detect if the permission was denied? as there does not seem to be any exception or other indication when this is denied.
Any help would be much appreciated.

source.rar said:
Hi,
I am developing an app that requires root permissions to run some shell commands to capture ouput. I am executing the "su" command to get root permission and it works fine when the su permission is granted. However I would like to know how to detect if the permission was denied? as there does not seem to be any exception or other indication when this is denied.
Any help would be much appreciated.
Click to expand...
Click to collapse
Ok I started using the libsuperuser library as that seems to be what I need.

Related

Adb remount help

When i try to do a adb remount i get operation not permitted.
It looks like you dunt have superuser
Sent from my DROID2 using Tapatalk
See if your phone is asking to allow superuser permission. It does not stay on screen very long, so just glance at it and see if it pops up and then push the grant permission button.
i got it. i just had to put the bootstap on it.
driverx125 said:
i got it. i just had to put the bootstap on it.
Click to expand...
Click to collapse
Without bootstrap you do not have a constant root adb shell. In order to get root in adb shell, you would have to type su. Bootstrap patches adbd on the phone to allow for a constant root adb shell.

[Q] Do I have "real" root?

So I have a Samsung Vibrant with the following specs :
Firmware : 2.1-update 1
Baseband : T959UVJI6
Kernel version : 2.6.29
Build : ECLAIR.UVJI6
I used the Samsung Vibrant 1 click root application, have since verified I do have SuperUser installed as well as BusyBox, with quite a few different root based applications such as ClockWorkMod Recovery, One-Click Lag Fix, Set CPU, Titanium Backup, etc., and I have verified that ADB does work from a command prompt, however when I try to access su through ADB by doing the following commands, this happens :
C:/>adb shell
$ su
su
Permission denied
$
I have also tried to use Android Commander from my PC as a kind of root explorer and the program does detect my device and starts, but shows "Root Access : NO". From all threads I have investigated, this would almost seem as though I don't have "true" root access. Can anyone assist me and let me know what I am doing wrong?
bretjrodgers said:
So I have a Samsung Vibrant with the following specs :
Firmware : 2.1-update 1
Baseband : T959UVJI6
Kernel version : 2.6.29
Build : ECLAIR.UVJI6
I used the Samsung Vibrant 1 click root application, have since verified I do have SuperUser installed as well as BusyBox, with quite a few different root based applications such as ClockWorkMod Recovery, One-Click Lag Fix, Set CPU, Titanium Backup, etc., and I have verified that ADB does work from a command prompt, however when I try to access su through ADB by doing the following commands, this happens :
C:/>adb shell
$ su
su
Permission denied
$
I have also tried to use Android Commander from my PC as a kind of root explorer and the program does detect my device and starts, but shows "Root Access : NO". From all threads I have investigated, this would almost seem as though I don't have "true" root access. Can anyone assist me and let me know what I am doing wrong?
Click to expand...
Click to collapse
When you do "Adb shell" > "su" you have to allow it on your phone. A little popup will appear.
If you can su in a terminal on the phone itself then you can be certain you have root.
Are you sure there is not a prompt on the phone when you are attempting su from ADB? It might be asking for su permissions but timing out and showing denied.
bretjrodgers said:
So I have a Samsung Vibrant with the following specs :
Firmware : 2.1-update 1
Baseband : T959UVJI6
Kernel version : 2.6.29
Build : ECLAIR.UVJI6
I used the Samsung Vibrant 1 click root application, have since verified I do have SuperUser installed as well as BusyBox, with quite a few different root based applications such as ClockWorkMod Recovery, One-Click Lag Fix, Set CPU, Titanium Backup, etc., and I have verified that ADB does work from a command prompt, however when I try to access su through ADB by doing the following commands, this happens :
C:/>adb shell
$ su
su
Permission denied
$
I have also tried to use Android Commander from my PC as a kind of root explorer and the program does detect my device and starts, but shows "Root Access : NO". From all threads I have investigated, this would almost seem as though I don't have "true" root access. Can anyone assist me and let me know what I am doing wrong?
Click to expand...
Click to collapse
So after installing SU Terminal & Root Explorer from Android Market, when I did the following :
C:/>adb shell
$ su
su
#
I have verified that SuperUser permissions through ADB are obviously working. However when I do the following command...
C:/>adb root
adbd cannot run as root in production builds
...is displayed. It seems as though, yes, I do have SuperUser access, I don't have root access through ADB and Android Commander still does not recognize root. Is this because I am running the stock ROM, and if so, is there a general thread with all available/recommended Vibrant ROMs to install?
bretjrodgers said:
So after installing SU Terminal & Root Explorer from Android C:/>adb root
adbd cannot run as root in production builds
...is displayed. It seems as though, yes, I do have SuperUser access, I don't have root access through ADB and Android Commander still does not recognize root. Is this because I am running the stock ROM, and if so, is there a general thread with all available/recommended Vibrant ROMs to install?
Click to expand...
Click to collapse
Just to clarify, you realize adb root has nothing to do with your phone?
adb root restarts the adb daemon on the computer you are on as root (something I usually don't recommend).
When you start Android Commander make sure it has permissions on your phone when it makes the request.
d01100100 said:
Just to clarify, you realize adb root has nothing to do with your phone?
adb root restarts the adb daemon on the computer you are on as root (something I usually don't recommend).
When you start Android Commander make sure it has permissions on your phone when it makes the request.
Click to expand...
Click to collapse
Ok so I now understand the purpose of the adb root command after some additional research. I guess the issue is that when I run Android Commander, even though it does detect my device on the PC, it does not ask for/request SU permissions on my device
The FAQ thread for Android Commander:
http://forum.xda-developers.com/showthread.php?t=628138
** If you using Win7/Vista run Program as Administrator or disable UAC, otherwise this function will fail!
Click to expand...
Click to collapse
Guess I never needed for something like this since I'm comfortable with the command line.
d01100100 said:
The FAQ thread for Android Commander:
http://forum.xda-developers.com/showthread.php?t=628138
Guess I never needed for something like this since I'm comfortable with the command line.
Click to expand...
Click to collapse
I am running the program with both UAC disabled, and running as administrator and still the program does not recognize as root. I am only worried not just about Android Commander, but the possibility for functionality of other programs that require root as well.
Type adb shell
You'll see '$' as your prompt, type 'su'
$ su
You'll see '#' as your prompt, type 'id'
# id
uid=0(root) gid=0(root)
That means you have root.
Further proof you can remount /system from ro to rw.
You have root, Android Commander isn't the standard to judge whether your root is working correctly. Just a cursory glance at the app thread, it requires quite a bit of finesse to get working and it's touchy about which rom you're using. If yours doesn't work and you've actually followed the directions, send the developer your logs in the proper thread.
Why not just download the app Terminal Emulator and just type "su".... you'll either get the # or Permission Denied.
Based off everything you said, yes, you have root... ^ easiest way to test though. No need to deal with adb.

Can not access to su with adb

Hy everybody,
I was trying to acces to su (root) using adb but it does not work:
Code:
su -
Permission Denied.
I think I have correctly root my phone using SuperOneClick, and I have the apps SuperUser installed.
Do you know
benpaka said:
Hy everybody,
I was trying to acces to su (root) using adb but it does not work:
Code:
su -
Permission Denied.
I think I have correctly root my phone using SuperOneClick, and I have the apps SuperUser installed.
Do you know
Click to expand...
Click to collapse
check the phone after typing su. Also make sure the phone is unlocked.
Okay it was a really stupid things to do, but unlocking the phone help me

[Q] How can i get ADB ROOT? i want to know rageagainstthecage's working principle

hi,guys!
as this title says i found a tool named "rageagainstthecage",but i want to know how dose it work.Can anyone help me ? thanks
try superoneclick
Are you using Linux to grant root access on your Defy?
I rooted mine yestarday and I was a little confused on how to make it, I have same file as you as I read. rageagainstthecage is the exploit that will you grant root privileges. The instructions for linux are here [1]. I replaced 'exploit.bin' with 'rageagainstthecage' or you can use the one provided in that post 'psneuter', the proccess is simple
1. Copy files to phone using adb (I used /data/local/tmp as directory in the phone): su, busybox, Superuser.apk and exploit (exploit name, let's say: rageagainstthecage)
2. Make the exploit executable and execute it
3. Give permissions to the commands su and busybox
4. There you go
All the credits for the autor of the post on IBM forum
I hope this help you with your question
[1]
PHP:
www_ibm_com/developerworks/mydeveloperworks/blogs/coolwinding/entry/how_to_root_defy_on_linux1
jianbangguo said:
try superoneclick
Click to expand...
Click to collapse
Dose the superoneclick use "rageagainstthecage" to grant adb root access? i just want to know "rageagainstthecage", how dose it work? can you help me? thanks
cristianpark said:
Are you using Linux to grant root access on your Defy?
I rooted mine yestarday and I was a little confused on how to make it, I have same file as you as I read. rageagainstthecage is the exploit that will you grant root privileges. The instructions for linux are here [1]. I replaced 'exploit.bin' with 'rageagainstthecage' or you can use the one provided in that post 'psneuter', the proccess is simple
1. Copy files to phone using adb (I used /data/local/tmp as directory in the phone): su, busybox, Superuser.apk and exploit (exploit name, let's say: rageagainstthecage)
2. Make the exploit executable and execute it
3. Give permissions to the commands su and busybox
4. There you go
All the credits for the autor of the post on IBM forum
I hope this help you with your question
[1]
PHP:
www_ibm_com/developerworks/mydeveloperworks/blogs/coolwinding/entry/how_to_root_defy_on_linux1
Click to expand...
Click to collapse
pardon my poor english,I just want to know how dose it work, for example : rageagainstthecage's Working principle,not how to use "rageagainstthecage" to grant root access,thank you !!
The principle of how it works is very simple, the rageinthecage exploit just forks proccesses until the proccessor hits the max, then the system will kill the olders apps, because you are using adb and running psneuter, the system will kill the adb shell, and here is the magic, when you restart the adb shell it start with root rights, to prevent that, inmediatly adb starts, the system calls setuid function, but because the proccesses list is full, the explot prevents the setuid call, allowing you to maintain the root rights, and in that point, you push Superuser.apk to allow the root access to the apps, changin before the permissions to the su binary allowing you to call that binary with a less rights user, that is the idea beyond the exploit!, wish that help you!
Sorry for the bad english
LeonardoJegigzem said:
The principle of how it works is very simple, the rageinthecage exploit just forks proccesses until the proccessor hits the max, then the system will kill the olders apps, because you are using adb and running psneuter, the system will kill the adb shell, and here is the magic, when you restart the adb shell it start with root rights, to prevent that, inmediatly adb starts, the system calls setuid function, but because the proccesses list is full, the explot prevents the setuid call, allowing you to maintain the root rights, and in that point, you push Superuser.apk to allow the root access to the apps, changin before the permissions to the su binary allowing you to call that binary with a less rights user, that is the idea beyond the exploit!, wish that help you!
Sorry for the bad english
Click to expand...
Click to collapse
Great info, thanks for sharing this with us I was wondering the same

how to allow root for apps?

I have a nvidia shield tv with full android 6.
adb root and and adb remount is working, so I have root access on shell level.
Also I have /system/xbin/su which goes into root if I do not use "adb root".
But root for apps does not work. No app gets root access, RootChecker says "no".
I installed Superuser.apk but this did not help.
What is missing?
I see that this:
java.io.IOException: Error running exec(). Command: [su] Working Directory: null Environment: null
Caused by: java.io.IOException: Permission denied
I saw that RootChecker tells me "SELinux enforcing", is this the problem?
I do not want to download any ready-made root miracle and flash the whole device.
Since I have adb root, I can adb push everything.
Just flash su.zip and all will be fine.
I don't need SuperSU. I want to root my device i.e. that apps can execute su.
I have /system/xbin/su but it seems that apps cannot use it.
SuperSU is required to give root access to apps, even with full Android. You will need to flash the zip file from TWRP recovery.
How does SuperSU work?
As far as I understand, there is a /system/xbin/su which is called by apps wanting root access.
This su binary then starts the app to verify access. Right?
Not sure, but I think that su is just for adb and maybe system apps.
On my system I have "adb root" access. But apps do not have root access, I do not have supersu or su.

Categories

Resources