8

I've done some digging and the main ideas I've seen floating around are using setuid/getuid and using the Authorization Services (which, for some reason gives me a symbol error when compiling but appears to be deprecated now).

My application needs to be able to request root access (for accessing a raw disk drive) at a certain point, preferably with the OS X authentication dialog (I'm new to OS X so I have no idea what to call that).

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
Lander
  • 3,369
  • 2
  • 37
  • 53

1 Answers1

5

Authorization Services is pretty well supported, AFAIK.

Here's a link to a tutorial (with sample projects!) which you can use to launch a small tool in which you can get admin priviledges and then you can call the setpriority API on your calling process (documentation linked for you).

Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215
  • Thanks! For some reason I can't find where AuthorizationExecuteWithPrivileges is declared as when I #include I have symbols for pretty much everything else, except that one function – Lander Jan 19 '12 at 16:59
  • 1
    http://developer.apple.com/library/mac/#documentation/Security/Reference/authorization_ref/Reference/reference.html says that AuthorizationExecuteWithPrivileges has been deprecated since 10.7. http://stackoverflow.com/questions/6841937/authorizationexecutewithprivileges-is-deprecated has some related info. – Vishal Jan 19 '12 at 17:48
  • Whooops... `AuthorizationExecuteWithPrivileges` became "deprecated" as of 10.7. I'm looking at Apple's [Authorization Services Tasks](http://developer.apple.com/library/mac/#documentation/Security/Conceptual/authorization_concepts/03authtasks/authtasks.html#//apple_ref/doc/uid/TP30000995-CH206-TP9) documentation to see how you can [`renice`](http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man8/renice.8.html) the calling process. – Michael Dautermann Jan 19 '12 at 17:51
  • @Vishal that's what I noticed as well, but I wasn't too sure why or whether or not it was bad to use it. Thanks for linking to the related question! – Lander Jan 19 '12 at 19:34
  • Both links are dead – Casper B. Hansen Nov 28 '17 at 17:42
  • 1
    I just fixed them @CasperB.Hansen – Michael Dautermann Nov 28 '17 at 17:50