Change Permissions of /dev/disk*??

Discussion in 'Mac Programming' started by naveen, Sep 10, 2005.

  1. naveen macrumors member

    Joined:
    Oct 27, 2004
    #1
    Hi all
    * * * * I am able to change the permissions of* *disk0,disk1....disk* in the* /dev
    using :-* chmod("/dev/disk0", 777);* I am calling this function in my program, but
    when i login through user other than system administrator (root) then i am not
    able to change the permissions (because the function fails).

    What should i have to do to sought out this problem.

    Thanks and regards
     
  2. After G macrumors 68000

    After G

    Joined:
    Aug 27, 2003
    Location:
    California
    #2
    Calling your function through Applescript or a shell script?

    Perhaps you can use "sudo chmod ... " instead, and use an admin password instead.

    As for details on how to do this, I don't remember off the top of my head. Maybe someone more coding-savvy can tell you.
     
  3. GeeYouEye macrumors 68000

    GeeYouEye

    Joined:
    Dec 9, 2001
    Location:
    State of Denial
    #3
    Why exactly do you need to change the permissions of the raw device?
     
  4. savar macrumors 68000

    savar

    Joined:
    Jun 6, 2003
    Location:
    District of Columbia
    #4
    You need to look into Authentication Services.

    What's the deal with all of the asterixes?
     
  5. superbovine macrumors 68030

    superbovine

    Joined:
    Nov 7, 2003
    #5
    i was wondering the same thing
     
  6. caveman_uk Guest

    caveman_uk

    Joined:
    Feb 17, 2003
    Location:
    Hitchin, Herts, UK
    #6
    There's two ways to do this. The approved (correct but somewhat longer) way and the quick and nasty way.

    The approved way is to write your own self-repairing helper tool (that fixes it's own SETUID bit) and execute that with a special set of authorized priviledges you've obtained using the code described in the above link.

    The other way is to cheat and use AuthorizationExecuteWithPrivileges. Which is dirty and discouraged but does work. You still need a separate helper tool in your bundle but it doesn't need to be self repairing. You can also excute shell commands using this.

    DO NOT make the main app SETUID or try to execute it as root. This is very very bad.

    Check out this and Apple's MoreAuthSample code.

    I will ask like other posters why you want to change the permissions in the first place. Is there not another way to do what you're doing or are you just doing that because you can't be bothered to think of a less drastic solution?
     
  7. naveen thread starter macrumors member

    Joined:
    Oct 27, 2004
    #7
    Hi

    How can I use the authopen(1) for reading the /dev/disk* Programmically.


    Thanks and Regards
     
  8. naveen thread starter macrumors member

    Joined:
    Oct 27, 2004
    #8
    Hi all

    I have used the authopen() but still I am unable to get the hard disks on the user other than root (system administrator). I have used the following code to use the authopen()

    pFile = popen("/usr/libexec/authopen -stdoutpipe sys.openfile.readonly.disk", "r");

    Plz help me what should I have to do or use to get the hard disks attached to my system.


    Thanks and Regards
     

Share This Page