su commands and superuser permissions

Discussion in 'Android Hacks and Help' started by jdx, Feb 26, 2010.

  1. jdx
    Offline

    jdx New Member

    Joined:
    Feb 2, 2010
    Messages:
    69
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    MN
    I've posted it in another forum, but it doesnt look like anyone knows how to fix the problem there. Soooo....
    I've created a native library, which allows me to run the c 'system' command with my android app.
    But somehow, the "superuser permissions app" asks me for permission for every different command, that i am executing. For example: I do a 'su -c "busybox free"'. The superuser app will ask me whether i want to allow or not, i select allow always and next time I call 'su -c "busybox free"' it does not ask again. However, if i do a 'su -c "whatever"', the superuser app will ask again, even though its the same process. So i end up with having a list in my superuser permissions app, with the same process, but different commands. Does anyone know how to avoid this? I would like to grant permission once for this process and being able to start different su commands.

    Thanks
  2. Fraxinus
    Offline

    Fraxinus New Member

    Joined:
    Dec 11, 2009
    Messages:
    141
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    New Haven, CT
    Can you give a little more info? I won't claim to be a shell ninja, but I've had some experience. It would seem to me that you're using a *parameter* of the command you are issuing with superuser permissions. su -c "busybox free" would execute the busybox free command with the -c parameter specified yes? In that case you would have to allow permission for every command you issue (busybox, chmod, gzip, etc., etc.) regardless of whether or not you're using the -c parameter. Also, this should mean completely different things to different commands right? Maybe I'm missing something....

    EDIT:
    My mistake - I shouldn't have responded before doing a little more research - I never had need of the -c command before. I'll take a stab at this anyway (even though I'm clearly no expert).

    When you specify -c, you're indicating that the shell should execute the command string that follows. From what I see you would typically want to do this when chaining commands --> i.e. 'find ..... -c "mv .... "'. I'm not sure how actual execution happens with -c, but it must still be calling the shell to run that program. That seems to be causing your superuser application to check for permission to execute it. Your problem is that the shell is still executing the command that appears in your string. For each command the permission has to be granted.

    Is there a particular reason you're using -c in the first place?
  3. jdx
    Offline

    jdx New Member

    Joined:
    Feb 2, 2010
    Messages:
    69
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    MN
    Well, its not about a specific command. It could be "reboot", "busybox something" or anything else.I mean, it works in the terminal emulator too, right?! You type su once, and then you can execute all commands as root, without granting permission for every command.
  4. Fraxinus
    Offline

    Fraxinus New Member

    Joined:
    Dec 11, 2009
    Messages:
    141
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    New Haven, CT
    Are you executing these commands directly from a terminal emulator? From my experience, yes, when you allow access to su once all subsequent su commands will simply execute. As soon as you leave that particular session though, you would have to grant permission again. I'm basing this off desktop linux systems though, I haven't played much with a terminal in Android.
  5. jdx
    Offline

    jdx New Member

    Joined:
    Feb 2, 2010
    Messages:
    69
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    MN
    Its like that:
    - I have a native lib, which executes the c command "system"
    - I am calling this function in my android app with params (like myfunction("reboot"))
    I thought, once i do a myfunction("su"), my app will have su rights (if 'white listed' in the superuser permissions app). But i have to white list every command. What am i doing wrong?
  6. Fraxinus
    Offline

    Fraxinus New Member

    Joined:
    Dec 11, 2009
    Messages:
    141
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    New Haven, CT
    Sorry in advance if I'm being slow on this...a question:
    When you say you're launching this from your "Android app" are you writing a custom application that makes calls to the c 'system' function?

    Or are you issuing a command like 'su -c "busybox free"' from the command line?

    If the latter is the case then for your example all you're doing is telling one shell to launch another shell to execute the command. This is useful for chaining commands together

    (taken from: Commands using bash | commandlinefu.com)

    but there isn't really any benefit from calling a single command...that I'm aware of.

    I'll throw this out there too. I have *no* idea if this will help you, but you can check this link out:

    calling "system" command from C - Mac Forums

    If this is going nowhere for you and I'm not being helpful let me know and we can stop going in circles! :laugh:
Search tags for this page

android su command

,

android su commands

,

android superuser commands

,
android superuser library
,
android terminal superuser
,
busybox su command
,
command to add superuser'
,
linux busybox su
,

su command android

,

su commands android

,
super user commands
,
superuser android commands
,
superuser commands
,
superuser commands android
,
superuser commands for android