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

Discussion in 'Mac Programming' started by rezeda, Mar 24, 2009.

  1. rezeda macrumors newbie

    Nov 11, 2008
    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!
  2. robbieduncan Moderator emeritus


    Jul 24, 2002

Share This Page