• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Access to /usr/local from installer plug-in
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Access to /usr/local from installer plug-in


  • Subject: Re: Access to /usr/local from installer plug-in
  • From: Bill Coderre <email@hidden>
  • Date: Wed, 09 Dec 2009 12:43:03 -0800

On Dec 9, 2009, at 11:38 AM, Stanislav Kolar wrote:
Hello,
 
I have to write an installer plug-in that asks for some initial information during the installation process and saves them as a xml file into /usr/local/my_dir directory.
The problem is that in the method "shouldExitPane" I don't have an appropriate rights to modify anything in the directory /usr/local...
Is there a solution of my problem ?

In an install that requires Admin privileges, Installer panes run as the logged in user, so you have to write your info someplace that THAT user can access.

The only good choice is /tmp in some known filename, and then have a preflight or postflight write the info into /usr/local. (You can't use mktemp to generate a temp file securely, because your preflight and postflight need to know the name of the temp file.)

This presents a security risk. (For instance, some badguy knows you will be writing into /tmp/MySecretFile, so they create a symlink at that location, and point it to /kernel.)

So the correct answer is to attempt to open the file with modes to cause it to fail if it already exists. Here's what I do in perl (please test it before you ship it!)

use Fcntl;
sysopen(TEMPFILEHANDLE, $tempfilename, O_WRONLY | O_CREAT | O_EXCL) or die "Can't open $tempfilename!";

which translates to, "open this file for write only, create it, and fail if it already exists."

Yes, you could attempt to handle errors more gracefully, but test test test!


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Installer-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Access to /usr/local from installer plug-in
      • From: Iceberg-Dev <email@hidden>
References: 
 >Access to /usr/local from installer plug-in (From: "Stanislav Kolar" <email@hidden>)

  • Prev by Date: Access to /usr/local from installer plug-in
  • Next by Date: Re: Access to /usr/local from installer plug-in
  • Previous by thread: Access to /usr/local from installer plug-in
  • Next by thread: Re: Access to /usr/local from installer plug-in
  • Index(es):
    • Date
    • Thread