View Full Version : How can I open a file for writing from my code if it belongs to root?

Mar 24, 2009, 05:05 AM
Hello all,
I am developing a plug-in using Cocoa/Objective c on Leopard. I need to modify a file located in /etc/cups/ppd for example test.ppd by inserting some lines to it.
But fopen call fails because the file belongs to root, instead of user.

Here are the rights to test.ppd file:
-rw-r--r-- 1 root _lp

Every modification I do to this file I do using:
sudo vi test.ppd

So, is it possible to modify it from my plug-in code? Even asking somehow for the root password?

Thank you in advance!

Mar 24, 2009, 05:44 AM
You use the well documented Authorization Services (http://developer.apple.com/documentation/Security/Conceptual/authorization_concepts/01introduction/introduction.html) API.