Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

naveen

macrumors member
Original poster
Oct 27, 2004
43
0
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
 

After G

macrumors 68000
Aug 27, 2003
1,583
1
California
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.
 

savar

macrumors 68000
Jun 6, 2003
1,950
0
District of Columbia
naveen said:
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).

You need to look into Authentication Services.

What's the deal with all of the asterixes?
 

caveman_uk

Guest
Feb 17, 2003
2,390
1
Hitchin, Herts, UK
savar said:
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?
 

naveen

macrumors member
Original poster
Oct 27, 2004
43
0
Hi

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


Thanks and Regards
 

naveen

macrumors member
Original poster
Oct 27, 2004
43
0
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.