Gain root privileges for writing to files

Discussion in 'iOS Development' started by RazerM, May 15, 2008.

  1. RazerM

    RazerM New Member

    Joined:
    Oct 4, 2007
    Messages:
    279
    Likes Received:
    5
    Code:
    NSData *data = [[textBox text] dataUsingEncoding:NSUTF8StringEncoding];
    [file writeToFile:<etc>];
    I can write to files owned by user 'mobile', but not those owned by user 'root'.

    In other unix systems, I know from experience that root privileges are gained by the user using sudo or su, but I don't know how this would be done within an application.

    Any help would be appreciated. As I am clueless..

    Please Register or Log in to view images



    Edit: The owner of these files cannot be changed, for various reasons.
  2. qbal1

    qbal1 New Member

    Joined:
    May 2, 2008
    Messages:
    254
    Likes Received:
    0
    you need to log into your iPod using openSSH. I use WinSCP.
    you can edit the files from there and I think you can write to them using your iPod if you set the file's permissions to 777 through SSH
  3. RazerM

    RazerM New Member

    Joined:
    Oct 4, 2007
    Messages:
    279
    Likes Received:
    5
    You don't understand the question, if the files I am trying to write to were owned by user 'mobile' it would work fine - but they're not

    Please Register or Log in to view images

  4. qbal1

    qbal1 New Member

    Joined:
    May 2, 2008
    Messages:
    254
    Likes Received:
    0
    well what method did you use to try to write them?
  5. RazerM

    RazerM New Member

    Joined:
    Oct 4, 2007
    Messages:
    279
    Likes Received:
    5
    The code I quoted in the first post...

    Even if this app asks the user for the root password I'll be happy, I just need some help with the code.
  6. optimo

    optimo New Member

    Joined:
    Sep 28, 2007
    Messages:
    535
    Likes Received:
    17
    you cant sudo from within the framework, you would need to use popen() maybe, but not everyone has sudo on their device

    in other words, its not very simple
  7. RazerM

    RazerM New Member

    Joined:
    Oct 4, 2007
    Messages:
    279
    Likes Received:
    5
    Thanks, but I've figured it out.

    I just need to have 'Set UID' bit set in my apps permissions.
  8. PatIsLegend

    PatIsLegend New Member

    Joined:
    Mar 30, 2008
    Messages:
    140
    Likes Received:
    1
    Device:
    iPod touch
    theres a sudo fix u can install through cydia, under the administration section.
  9. RazerM

    RazerM New Member

    Joined:
    Oct 4, 2007
    Messages:
    279
    Likes Received:
    5
    As I said, i've worked it out.

    The sudo in Cydia isn't what i was looking for.

Share This Page