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

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
Let's say I have a user-controlling app, and I want only users who are administrators to be allowed to change the settings. How would I accomplish this?
 
Let's say I have a user-controlling app, and I want only users who are administrators to be allowed to change the settings. How would I accomplish this?

in C (should be compatible with objectiveC) you can call getuid()


Code:
int user;
user = getuid();
if (user == 0)
{
//code to be executed as root
}
else
{
cout << "root privleges needed";
}


you can try your app from the terminal window..

- launch your app with the current user
- launch your app via sudo: sudo /path/myapplication
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.